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.

Required tools

  • snapcraft — must be installed and on PATH. Install via sudo snap install snapcraft --classic.

Platform

Snapcraft only runs against Linux binary artifacts. Builds targeting other operating systems are ignored.

Minimal config

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

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.
summarystring"<name> snap package"Single-line description (max 79 characters).
descriptionstringExtended description shown in the store.
iconstringPath to the snap icon image file.
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.
slotslistShared interface slots for other snaps.
assumeslistRequired snapd features or minimum versions.
appsmapautoNamed app entries. Auto-generates a default entry from the first binary if omitted.
layoutsmapFilesystem layout mappings for sandbox accessibility.
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 }}).
disableboolfalseSkip this snapcraft config.

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.
argsstringAdditional arguments appended to the command.
daemonstringRun as a daemon: simple, forking, oneshot, notify.
stop_modestringSignal used to stop the daemon: sigterm, sigkill, etc.
restart_conditionstringWhen to restart: on-failure, always, never, etc.
plugslistInterfaces this app needs.
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 (layouts)

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