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.UpdateManager(update_settings, update_interval=86400)

Bases: object

cache_key_fmt = u'__aw_updater-{0}'
check_for_update(force=False)
get_updater()

Return Updater instance for update_settings

install_update()
update_available
class workflow.update.Updater(update_settings)

Bases: object

Base class for auto-updaters

Subclasses must override the following methods:

get_latest_version_info()

Check web/filesystem/whatever for new version

Returns:Version instance and URL to .alfredworkflow file
Return type:tuple
static get_updater(update_settings)

Return Updater instance for update_settings

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_slugusername/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_slugusername/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_slugusername/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()