Skip to main content

Snapcraft

Build and publish Snap packages for the Snapcraft store

The snapcraft stage builds .snap packages from your Linux binaries and optionally publishes them to the Snap Store.

Classification

Packager + optional Submitter — builds snap packages from Linux binaries and, when publish: true is set, uploads them to the Snap Store. The Snap Store upload is a Submitter-group operation (no rollback; already-installed snaps keep the revision).

Minimal config

crates:
  - name: myapp
    snapcrafts:
      - summary: "My application"
        description: "A longer description shown in the Snap Store."

Full config reference

crates:
  - name: myapp
    snapcrafts:
      - id: ""                         # optional; unique identifier
        ids: []                        # optional; filter by build IDs
        name: ""                       # optional; snap package name (default: binary name)
        title: ""                      # optional; user-facing application title
        summary: ""                    # optional; single-line description (max 78 chars)
        description: ""                # optional; extended description
        icon: ""                       # optional; path to .png or .svg icon
        base: core22                   # optional; core | core18 | core20 | core22 | core24 | bare
        grade: ""                      # optional; stable | devel
        license: ""                    # optional; SPDX identifier
        confinement: strict            # optional; strict | devmode | classic
        plugs: {}                      # optional; interface plug definitions
        assumes: []                    # optional; required snapd features
        apps: {}                       # optional; named app entries (auto-generated if omitted)
        layout: {}                     # optional; filesystem layout mappings (accepts `layouts:` alias)
        extra_files: []                # optional; additional static files to bundle
        name_template: ""              # optional; output filename template
        publish: false                 # optional; upload to Snap Store after building
        channel_templates: []          # optional; store channels to release to
        replace: false                 # optional; remove archive artifacts, keep snap only
        mod_timestamp: ""             # optional; fixed timestamp for reproducible builds
        skip: false                    # optional; accepts `disable:` alias (deprecation-warned)

Authentication

VariableDescription
SNAPCRAFT_STORE_CREDENTIALSSnapcraft login credentials (base64-encoded). Obtain via snapcraft export-login --snaps myapp --channels stable -.

Alternatively, run snapcraft login before releasing to authenticate interactively.

Common gotchas

  • snapcraft must be on PATH: install via sudo snap install snapcraft --classic.
  • Linux only: the stage ignores non-Linux artifacts. Ensure at least one Linux build target is configured.
  • Icon auto-write: the icon field copies the file to meta/gui/<name>.<ext> inside the staged prime directory before snapcraft pack runs. The source path may be absolute or relative to the project root. The icon does NOT appear in snap.json.
  • grade: stable + confinement: devmode: snapcraft will warn that devmode snaps cannot be published to the stable channel.

Republish / update behavior

Not applicable — once a snap revision is uploaded to the Snap Store, it cannot be removed. Already-installed snaps keep the revision they installed. Use a different channel_templates target (e.g., edge) for pre-release builds.

Config fields

FieldTypeDefaultDescription
idstringUnique identifier for referencing this config from other stages.
idslistallFilter to specific build IDs.
namestringbinary nameSnap package name in the store.
titlestringUser-facing application title.
summarystringcrate descriptionSingle-line description (max 78 characters). Falls back to the resolved description (which itself falls back to the crate's Cargo.toml package.description); the result is hard-capped at 78 characters.
descriptionstringExtended description shown in the store.
iconstringPath to the snap icon image (.png or .svg). Anodizer copies the file to meta/gui/<name>.<ext> inside the staged prime directory before snapcraft pack runs. The icon is picked up by snapcraft via the GUI metadata channel and does NOT appear in snap.json, keeping uploads schema-clean. The source path may be absolute or relative to the project root.
basestringcore22Base snap: core, core18, core20, core22, core24, bare.
gradestringRelease quality: stable or devel.
licensestringSPDX license identifier.
confinementstringstrictSecurity model: strict, devmode, or classic.
plugsmapInterface plug definitions (HashMap<String, Value>). Keys are plug names; values are plug attributes.
assumeslistRequired snapd features or minimum versions.
appsmapautoNamed app entries. Auto-generates a default entry from the first binary if omitted.
layoutmapFilesystem layout mappings for sandbox accessibility. The plural layouts: spelling is still accepted via serde alias.
extra_fileslistAdditional static files to bundle in the snap.
name_templatestring<name>_<version>_<arch>.snapOutput filename template.
publishboolfalseUpload to the Snap Store after building.
channel_templateslistStore channels to release to (e.g. edge, beta, stable).
replaceboolfalseRemove matching archive artifacts, keeping only the snap.
mod_timestampstringFixed timestamp for reproducible builds (e.g. {{ CommitTimestamp }}).
skipbool/templatefalseSkip this snapcraft config. The GoReleaser disable: spelling is accepted as a deprecation-warned alias.

Confinement values

ValueDescription
strictFully confined to declared interfaces (default, recommended for production).
devmodeDevelopment mode — no confinement enforcement, useful for testing.
classicTraditional package — no sandbox, requires Snap Store approval.

App config (apps)

Each entry under apps describes an application exposed by the snap.

FieldTypeDescription
commandstringCommand path relative to the snap root. Defaults to the app's name when omitted.
argsstringAdditional arguments appended to the command.
daemonstringRun as a daemon: simple, forking, oneshot, notify, dbus.
stop_modestringSignal used to stop the daemon: sigterm, sigkill, etc.
restart_conditionstringWhen to restart: on-failure, always, never, etc.
plugslistInterfaces this app needs.
slotslistInterface slots this app provides (this is the only place snap slots are configured; there is no top-level slots).
environmentmapEnvironment variables for the app.

When no apps map is provided, a default entry is generated using the first binary's name with the command bin/<name>.

Layout config (layout)

FieldTypeDescription
bindstringBind-mount a host directory into the snap.
symlinkstringCreate a symlink within the snap's layout.

Architecture mapping

Target triple components are mapped to Snapcraft architecture names:

Rust targetSnap arch
x86_64 / amd64amd64
aarch64 / arm64arm64
armv7armhf
i686 / i386i386
s390xs390x
ppc64leppc64el
riscv64riscv64

Publishing to the Snap Store

Set publish: true and authenticate with snapcraft login (or set SNAPCRAFT_STORE_CREDENTIALS) before running anodizer. When channel_templates is provided, the snap is released to those channels automatically via snapcraft upload --release.

Full example

crates:
  - name: myapp
    snapcrafts:
      - name: myapp
        title: "My Application"
        summary: "A fast, cross-platform tool"
        description: |
          A longer description displayed in the Snap Store.
          Supports multiple paragraphs.
        base: core22
        grade: stable
        confinement: strict
        license: MIT
        plugs:
          home: {}
          network: {}
        apps:
          myapp:
            command: bin/myapp
            plugs:
              - home
              - network
        extra_files:
          - LICENSE
        publish: true
        channel_templates:
          - edge
          - stable
        replace: true