From d7bfd2648c36dea318d29369dc5aee2512ab6961 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 14 Dec 2025 12:31:00 +0100 Subject: [PATCH] feat(ci): add GitHub Action job to publish Snap on tags Add a publish-snap job to the CI workflow that runs after build and only triggers for version tags (refs/tags/v*). The job downloads the linux build artifacts, installs snapcraft, locates the generated .snap file and uploads it to the Snapcraft Store releasing to the stable channel. It validates the presence of a snap file and fails if none is found. This enables automated Snap distribution for tagged releases using the SNAPCRAFT_STORE_CREDENTIALS secret. --- .github/workflows/build-and-make.yaml | 44 ++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-make.yaml b/.github/workflows/build-and-make.yaml index e45e7cd15..a5e09e23c 100644 --- a/.github/workflows/build-and-make.yaml +++ b/.github/workflows/build-and-make.yaml @@ -72,16 +72,16 @@ jobs: - name: Build backend run: npm run build:backend - - name: Override macOS arch in package.json + - name: Override macOS arch in electron-builder.json if: matrix.os == 'macos' run: | - # Replace the mac arch array with just the target architecture - node -e " - const fs = require('fs'); - const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); - pkg.build.mac.target.arch = ['${{ matrix.arch }}']; - fs.writeFileSync('package.json', JSON.stringify(pkg, null, 4)); - " + # Replace the mac arch array with just the target architecture + node -e " + const fs = require('fs'); + const pkg = JSON.parse(fs.readFileSync('electron-builder.json', 'utf8')); + pkg.mac.target.arch = ['${{ matrix.arch }}']; + fs.writeFileSync('electron-builder.json', JSON.stringify(pkg, null, 4)); + " - name: Make Electron app run: npm run make:app @@ -170,3 +170,31 @@ jobs: artifacts/windows-artifacts/*.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-snap: + name: Publish to Snapcraft Store + needs: build + runs-on: ubuntu-latest + # if: startsWith(github.ref, 'refs/tags/v') # Only publish on version tags + + steps: + - name: Download snap artifact + uses: actions/download-artifact@v4 + with: + name: linux-artifacts + path: artifacts + + - name: Setup Snapcraft + uses: samuelmeuli/action-snapcraft@v3 + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.snapcraft_token }} + + - name: Publish all snaps to edge channel + run: | + # Find and publish all snap files + for SNAP_FILE in artifacts/*.snap; do + if [ -f "$SNAP_FILE" ]; then + echo "Publishing: $SNAP_FILE" + snapcraft upload --release=edge "$SNAP_FILE" + fi + done