@@ -175,9 +175,6 @@ jobs:
175175 > "completions/restorekit.$shell"
176176 done
177177
178- - name : Install snapcraft
179- run : sudo snap install snapcraft --classic
180-
181178 - uses : goreleaser/goreleaser-action@v6
182179 with :
183180 distribution : goreleaser
@@ -187,4 +184,55 @@ jobs:
187184 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
188185 # One token for both the Homebrew tap and the Scoop bucket.
189186 TAP_GITHUB_TOKEN : ${{ secrets.GORELEASER_GITHUB_TOKEN }}
187+
188+ # Pack the CLI binary into a snap and publish it to the Snap Store as
189+ # `restorekit-cli` (the plain `restorekit` name is the desktop app, published
190+ # from release-app.yml). GoReleaser can't do this: the binary links libusb
191+ # dynamically, core24 doesn't ship libusb-1.0.so.0, and its `snapcrafts`
192+ # block has no `stage-packages` escape hatch.
193+ #
194+ # One runner per arch — destructive mode builds on the host directly, so
195+ # stage-packages can only pull the host's debs, and ubuntu-24.04 matches the
196+ # snap's core24 base. Pack runs under sudo (snapcraft shells out to `snap`,
197+ # which snapd only allows as root) and swallows snap's stderr, so dump its
198+ # log on failure to see the real error.
199+ snap :
200+ # After `release`, not just `build`, so a failed GitHub release can't leave
201+ # a published snap behind (the ordering GoReleaser gave us before).
202+ needs : [release]
203+ strategy :
204+ fail-fast : false
205+ matrix :
206+ include :
207+ - os : ubuntu-24.04
208+ goarch : amd64
209+ - os : ubuntu-24.04-arm
210+ goarch : arm64
211+ runs-on : ${{ matrix.os }}
212+ steps :
213+ - uses : actions/checkout@v4
214+
215+ - name : Download the prebuilt binary
216+ uses : actions/download-artifact@v4
217+ with :
218+ name : restorekit_linux_${{ matrix.goarch }}
219+ path : snapbuild/bin
220+
221+ - name : Build & publish the snap
222+ env :
190223 SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
224+ run : |
225+ set -euo pipefail
226+ version="${GITHUB_REF_NAME#v}"
227+ sudo snap install snapcraft --classic
228+ # The executable bit doesn't survive the artifact round-trip.
229+ chmod +x snapbuild/bin/restorekit
230+ sed "s/VERSION_PLACEHOLDER/${version}/" crates/restorekit-cli/snap/snapcraft.yaml \
231+ > snapbuild/snapcraft.yaml
232+ cd snapbuild
233+ sudo snapcraft pack --destructive-mode || {
234+ sudo cat /root/.local/state/snapcraft/log/*.log
235+ exit 1
236+ }
237+ snapcraft upload --release=stable \
238+ "restorekit-cli_${version}_${{ matrix.goarch }}.snap"
0 commit comments