Snap Store

This page documents deployments using the next major version dpl v2, which currently is in a beta release phase. Please see our blog post for details. The current default version is dpl v1. Check dpl v1 documentation here.

Be sure to read the v2 deployment overview.

Travis CI can automatically upload and release your app to the Snap Store after a successful build.

Snapcraft lets you distribute to all Ubuntu releases and a growing set of Linux distributions with a single artefact.

For a minimal configuration, add the following to your .travis.yml:

deploy:
  provider: snap
  token: <encrypted token>
  edge: true # opt in to dpl v2

The snap value should be a string that matches exactly one file when the deployment starts. If the name of the snap file is not known ahead of time, you can use a shell glob pattern, e.g. *.snap.

Status #

Support for deployments to Snap is *stable**.

Known options #

Use the following options to further configure the deployment.

token Snap API token — required, secret, type: string
snap Path to the snap to be pushed (can be a glob) — type: string, default: **/*.snap
channel Channel into which the snap will be released — type: string, default: edge

Shared options #

cleanup Clean up build artifacts from the Git working directory before the deployment — type: boolean
run Commands to execute after the deployment finished successfully — type: string or array of strings

Environment variables #

All options can be given as environment variables if prefixed with SNAP_.

For example, token can be given as SNAP_TOKEN=<token>.

Securing secrets #

Secret option values should be given as either encrypted strings in your build configuration (.travis.yml file) or environment variables in your repository settings.

Environment variables can be set on the settings page of your repository, or using travis env set:

travis env set SNAP_TOKEN <token>

In order to encrypt option values when adding them to your .travis.yml file use travis encrypt:

travis encrypt <token>

Or use --add to directly add it to your .travis.yml file. Note that this command has to be run in your repository’s root directory:

travis encrypt --add deploy.token <token>

Obtaining credentials #

If you have not done so already, enable snap support on your system.

sudo snap install snapcraft --classic

Login tokens can specify how, when, and where they can be used, thus minimising damage from compromise.

Export a token that can only upload this snap to the channel you are going to upload to (in this example, edge):

snapcraft export-login --snaps my-snap-name --channels edge -

The token will be printed out.

Note: The final - requests the login be exported to stdout instead of a file. It is required.

Note: The edge channel is intended for the bleeding edge: your every commit to master will be built and uploaded.

Using uploaded Snaps #

Your community of early-adopters and testers can install your app in any of the supported Linux distributions with:

sudo snap install my-snap-name --edge

Each upload gets a monotonically increasing integer. When you’re ready, you can release one of these built commits to the stable channel for public discovery in the Snap storefront. For example, you could promote the very first upload to stable:

snapcraft release my-snap-name 1 stable

Pull Requests #

Note that pull request builds skip the deployment step altogether.

See also #