Self-Updating¶
New in version 1.9.
Add self-updating capabilities to your workflow. It regularly (every day by default) fetches the latest releases from the specified GitHub repository.
Currently, only updates from GitHub releases are supported.
Note
Alfred-Workflow will check for updates, but will neither install them nor notify the user that an update is available.
Please see Self-updating in the User Manual for information on how to enable automatic updates in your workflow.
API¶
Self-updating from GitHub
New in version 1.9.
Note
This module is not intended to be used directly. Automatic updates are controlled by the update_settings dict passed to Workflow objects.
- class workflow.update.Version(vstr)¶
Bases: object
Mostly semantic versioning
The main difference to proper semantic versioning is that this implementation doesn’t require a minor or patch version.
- static match_version()¶
Match version and pre-release/build information in version strings
- tuple¶
Return version number as a tuple of major, minor, patch, pre-release
- workflow.update.build_api_url(slug)¶
Generate releases URL from GitHub slug
Parameters: slug – Repo name in form username/repo Returns: URL to the API endpoint for the repo’s releases
- workflow.update.check_update(github_slug, current_version)¶
Check whether a newer release is available on GitHub
Parameters: - github_slug – username/repo for workflow’s GitHub repo
- current_version (unicode) – the currently installed version of the workflow. Semantic versioning is required.
Returns: True if an update is available, else False
If an update is available, its version number and download URL will be cached.
- workflow.update.download_workflow(url)¶
Download workflow at url to a local temporary file
Parameters: url – URL to .alfredworkflow file in GitHub repo Returns: path to downloaded file
- workflow.update.get_valid_releases(github_slug)¶
Return list of all valid releases
Parameters: github_slug – username/repo for workflow’s GitHub repo Returns: list of dicts. Each dict has the form {'version': '1.1', 'download_url': 'http://github.com/...'} A valid release is one that contains one .alfredworkflow file.
If the GitHub version (i.e. tag) is of the form v1.1, the leading v will be stripped.
- workflow.update.install_update(github_slug, current_version)¶
If a newer release is available, download and install it
Parameters: - github_slug – username/repo for workflow’s GitHub repo
- current_version (unicode) – the currently installed version of the workflow. Semantic versioning is required.
If an update is available, it will be downloaded and installed.
Returns: True if an update is installed, else False
- workflow.update.wf()¶