EDIT: Okay, I think I can see why this doesn’t work. You must be ending up with files in the arm64 snap that are actually amd64 binaries?
One way around this is to use snapcraft remote-build with a token in your CI, which uses Canonical’s build farm to build the snap on multiple architectures (you can actually build any of the supported snapcraft architectures this way).
Something like this (though I’ve just typed this into Discourse so there may be some small errors):
jobs:
build-snap-package:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- name: Setup LXD
uses: canonical/setup-lxd@0.1.2
- Setup snapcraft
run: |
sudo snap install snapcraft --classic
# Setup launchpad credentials
mkdir -p ~/.local/share/snapcraft/provider/launchpad ~/.local/share/snapcraft
echo "${{ secrets.LP_TOKEN }}" > ~/.local/share/snapcraft/launchpad-credentials
git config --global user.email "some@email.com"
git config --global user.name "Yazi CI"
- name: Build snap for arch
run: |
# Modify the `platforms` to use a single arch only, but run this in a matrix so they
# all get hit
yq -i '.platforms |= {env(arch): {"build-on": env(arch)}}' snapcraft.yaml
# Now run a remote-build, targeting just the single arch specified
snapcraft remote-build --launchpad-accept-public-upload
echo "snap=${name}_${version}_${arch}.snap" >> "$GITHUB_OUTPUT"
env:
arch: ${{ matrix.arch }}
- uses: actions/upload-artifact@v4
with:
name: snap-${{matrix.arch}}
path: ${{ steps.build-snap.outputs.snap }}
retention-days: 2
You can get the LP credentials by running snapcraft remote-build locally, then looking inside ~/.local/share/snapcraft/launchpad-credentials.