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.
Version strings may also be prefixed with “v”, e.g.:
>>> v = Version('v1.1.1') >>> v.tuple (1, 1, 1, '')
>>> v = Version('2.0') >>> v.tuple (2, 0, 0, '')
>>> Version('3.1-beta').tuple (3, 1, 0, 'beta')
>>> Version('1.0.1') > Version('0.0.1') True
-
__eq__
(other)¶ Implement comparison.
-
__ge__
(other)¶ Implement comparison.
-
__gt__
(other)¶ Implement comparison.
-
__le__
(other)¶ Implement comparison.
-
__lt__
(other)¶ Implement comparison.
-
__ne__
(other)¶ Implement comparison.
-
__repr__
()¶ Return ‘code’ representation of Version.
-
__str__
()¶ Return semantic version string.
-
match_version
()¶ Match version and pre-release/build information in version strings
-
tuple
¶ 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, prereleases=False)¶ 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. - prereleases – Whether to include pre-releases.
Returns: True
if an update is available, elseFalse
If an update is available, its version number and download URL will be cached.
- github_slug –
-
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, prereleases=False)¶ Return list of all valid releases.
Parameters: - github_slug –
username/repo
for workflow’s GitHub repo - prereleases – Whether to include pre-releases.
Returns: list of dicts. Each
dict
has the form{'version': '1.1', 'download_url': 'http://github.com/...', 'prerelease': False }
A valid release is one that contains one
.alfredworkflow
file.If the GitHub version (i.e. tag) is of the form
v1.1
, the leadingv
will be stripped.- github_slug –
-
workflow.update.
install_update
()¶ 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, elseFalse
- github_slug –
-
workflow.update.
wf
()¶ Lazy Workflow object.