ci: change snapcraft config (#373)

Drew Smirnoff created

Change summary

.github/workflows/release.yml | 23 +++++++++++++----------
snapcraft.yaml                | 26 ++++++++++++++++++++------
2 files changed, 33 insertions(+), 16 deletions(-)

Detailed changes

.github/workflows/release.yml 🔗

@@ -52,19 +52,21 @@ jobs:
           HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
 
   snapcraft:
-    runs-on: ubuntu-latest
+    runs-on: ${{ matrix.runner }}
     needs: goreleaser
+    strategy:
+      matrix:
+        include:
+          - arch: amd64
+            runner: ubuntu-latest
+          - arch: arm64
+            runner: ubuntu-24.04-arm
     steps:
       - name: Checkout
         uses: actions/checkout@v6
         with:
           fetch-depth: 0
 
-      - name: Set up Go
-        uses: actions/setup-go@v6
-        with:
-          go-version: "1.26.1"
-
       - name: Install Snapcraft and LXD
         run: |
           sudo snap install snapcraft --classic
@@ -73,9 +75,10 @@ jobs:
           sudo iptables -P FORWARD ACCEPT
           sudo usermod -aG lxd $USER
 
-      - name: Build and publish snap
+      - name: Build snap
+        run: sg lxd -c 'snapcraft pack --use-lxd --build-for=${{ matrix.arch }}'
+
+      - name: Upload snap
         env:
           SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
-        run: |
-          sg lxd -c 'snapcraft pack'
-          snapcraft upload --release=stable *.snap
+        run: snapcraft upload --release=stable *.snap

snapcraft.yaml 🔗

@@ -1,20 +1,25 @@
 name: matcha
-base: core22 # The base snap for a modern Ubuntu LTS
-version: "0.1" # This will be replaced by GoReleaser or can be set manually
+base: core22
+adopt-info: matcha
 summary: A beautiful and functional email client for your terminal.
 description: |
   A beautiful and functional email client for your terminal, built with Go and the charming Bubble Tea TUI library.
   Never leave your command line to check your inbox or send an email again!
 
-grade: stable # must be 'stable' to release into candidate, stable channels
-confinement: strict # use 'strict' confinement for security
+grade: stable
+confinement: strict
+architectures:
+  - build-on: [amd64]
+    build-for: [amd64]
+  - build-on: [arm64]
+    build-for: [arm64]
 
 apps:
   matcha:
     command: bin/matcha
     plugs:
-      - network # Required for network access
-      - home # To access the user's home directory for config files
+      - network
+      - home
 
 parts:
   matcha:
@@ -22,3 +27,12 @@ parts:
     source: .
     build-snaps:
       - go/1.26/stable
+    build-packages:
+      - gcc
+      - libc6-dev
+    build-environment:
+      - CGO_ENABLED: "1"
+    override-pull: |
+      craftctl default
+      version="$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo 0.1)"
+      craftctl set version="$version"