snap/README.md
2026-01-02 I used an Ubuntu 24.04 EC2 instance. I followed https://documentation.ubuntu.com/snapcraft/stable/. Error messages said things like
A network related operation failed in a context of no network access.
Recommended resolution: Verify that the environment has internet connectivity; see https://canonical-craft-providers.readthedocs-hosted.com/en/latest/explanation/ for further reference.
Full execution log: '/home/ubuntu/.local/state/snapcraft/log/snapcraft-20260102-170252.488632.log'
when there was in fact no network problem. I remained confused.
$ sudo snapcraft pack
$ lxc list
$ snapcraft pack --destructive-mode
$ snapcraft pack --use-multipass
$ sudo snap install multipass
$ snapcraft pack --use-multipass
$ sudo lxd init --auto
$ lxc network list
$ sudo snapcraft pack
$ sudo snap set snapcraft provider=multipass
$ sudo snapcraft pack --destructive-mode
[This created miller_6.15.0_arm64.snap]
$ snapcraft upload --release=stable *.snap
No keyring found to store or retrieve credentials from.
Recommended resolution: Ensure the keyring is working or SNAPCRAFT_STORE_CREDENTIALS is correctly exported into the environment
For more information, check out: https://documentation.ubuntu.com/snapcraft/stable/how-to/publishing/authenticate
Full execution log: '/home/ubuntu/.local/state/snapcraft/log/snapcraft-20260102-172357.599171.log'
$ ll *.snap
-rw-r--r-- 1 root root 8994816 Jan 2 17:22 miller_6.15.0_arm64.snap
$ snap install *.snap
error: access denied (try with sudo)
$ sudo snap install *.snap
error: cannot find signatures with metadata for snap/component "miller_6.15.0_arm64.snap"
Conclusion:
.snap file with sudo and multipass and --destructive-mode..snap file only for the current machine's arch, and the resulting .snap file was not locally installable.Here's how to set up automatic Snap publishing from GitHub releases:
First, ensure you have a proper snapcraft.yaml in your repo root (or in a snap/ directory):
name: your-app-name
base: core22 # or core24 for Ubuntu 24.04
version: git # automatically uses git tags
summary: Single-line summary
description: |
Longer description of your application
grade: stable # or devel
confinement: strict # or classic, devmode
apps:
your-app-name:
command: bin/your-binary
plugs:
- home
- network
parts:
your-app:
plugin: nil # change based on your build system (go, python, etc.)
source: .
# Add build steps as needed
Export your Snapcraft login credentials:
snapcraft export-login --snaps=miller --channels=stable,candidate,beta,edge snapcraft-token.txt
This creates a token file with limited permissions for just your snap.
SNAPCRAFT_TOKENsnapcraft-token.txtCreate .github/workflows/release.yml:
name: Release to Snap Store
on:
release:
types: [published]
jobs:
snap:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build snap
uses: snapcore/action-build@v1
id: build
- name: Publish to Snap Store
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
with:
snap: ${{ steps.build.outputs.snap }}
# release: stable # or edge, beta, candidate
release: edge
version: git in snapcraft.yaml automatically uses your git tag as the versionedge channel for testing, then promote to stable once confidentcandidate or beta first, then manually promote to stable after testingNow when you create a GitHub release with a tag (e.g., v1.0.0), the workflow will automatically build and publish your snap!