Travis

Snap Store

This page documents deployments using dpl v1 which is currently the legacy version. The dpl v2 is released, and we recommend useig it. Please see our blog post for details. dpl v2 documentation can be found here.

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. You publish and update at your pace while still reaching everyone; you’re not locked to the release cycle of Ubuntu or any other distribution. The updates apply automatically and roll back if anything goes wrong. They’re secure; each update is cryptographically signed and is tamper-proof once installed. The applications are locked down using the same container primitives found in Docker and LXD.

To upload your snap, add the following to your .travis.yml:

dist: xenial

deploy:
  provider: snap
  snap: my_*.snap
  channel: edge
  skip_cleanup: true

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, as shown in the example above.

Provide credentials and Upload the Snap #

To upload snaps from Travis CI, export a Snap Store login token, and provide it as an environment variable $SNAP_TOKEN.

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. For Travis CI, export a token that can only upload this snap to the channel you specified above (in this example, edge):

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

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

The token will be printed out.

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

Use the CLI client #

Using our CLI client, define $SNAP_TOKEN:

# in the repository root
travis env set SNAP_TOKEN "<token>"

Use the Settings page #

Equivalently, you can do this on the Settings page of your repository at Travis CI.

Use the Uploaded Snap #

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

Build Config Reference #

You can find more information on the build config format for Snaps in our Travis CI Build Config Reference.