Fix Windows artifact filename for electron-updater metadata #13
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| attestations: write | |
| actions: write | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Delete old artifacts | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api repos/${{ github.repository }}/actions/artifacts \ | |
| --paginate --jq '.artifacts[].id' | while read id; do | |
| gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$id || true | |
| done | |
| - name: Delete old caches | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api repos/${{ github.repository }}/actions/caches \ | |
| --jq '.actions_caches[].id' | while read id; do | |
| gh api -X DELETE repos/${{ github.repository }}/actions/caches/$id || true | |
| done | |
| test: | |
| needs: [cleanup] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test | |
| - name: Run backend tests | |
| working-directory: backend | |
| run: npm ci && npm test | |
| build-mac: | |
| needs: [test] | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Set version from tag | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: npm version "${GITHUB_REF#refs/tags/v}" --no-git-tag-version | |
| - name: Build app | |
| run: npm run build | |
| env: | |
| PURROXY_BUILD_SECRET: ${{ secrets.PURROXY_BUILD_SECRET }} | |
| - name: Import signing certificate | |
| env: | |
| CERT_BASE64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }} | |
| CERT_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
| run: | | |
| echo "$CERT_BASE64" | base64 --decode > /tmp/cert.p12 | |
| security create-keychain -p actions build.keychain | |
| security default-keychain -s build.keychain | |
| security unlock-keychain -p actions build.keychain | |
| security import /tmp/cert.p12 -k build.keychain -P "$CERT_PASSWORD" -T /usr/bin/codesign | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k actions build.keychain | |
| - name: Build Electron (macOS) | |
| run: npx electron-builder --mac dmg --publish never | |
| env: | |
| CSC_LINK: /tmp/cert.p12 | |
| CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
| APPLE_ID: ${{ secrets.APPLE_ID_EMAIL }} | |
| APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload macOS artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: purroxy-mac | |
| path: release/*.dmg | |
| retention-days: 1 | |
| build-win: | |
| needs: [test] | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Set version from tag | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: npm version "${GITHUB_REF#refs/tags/v}" --no-git-tag-version | |
| shell: bash | |
| - name: Build app | |
| run: npm run build | |
| env: | |
| PURROXY_BUILD_SECRET: ${{ secrets.PURROXY_BUILD_SECRET }} | |
| - name: Build Electron (Windows) | |
| run: npx electron-builder --win nsis --publish never | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Windows artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: purroxy-win | |
| path: release/*.exe | |
| retention-days: 1 | |
| build-linux: | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Set version from tag | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: npm version "${GITHUB_REF#refs/tags/v}" --no-git-tag-version | |
| - name: Build app | |
| run: npm run build | |
| env: | |
| PURROXY_BUILD_SECRET: ${{ secrets.PURROXY_BUILD_SECRET }} | |
| - name: Build Electron (Linux) | |
| run: npx electron-builder --linux AppImage --publish never | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Linux artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: purroxy-linux | |
| path: release/*.AppImage | |
| retention-days: 1 | |
| release: | |
| needs: [build-mac, build-win, build-linux] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Generate checksums | |
| run: | | |
| cd artifacts | |
| find . -type f \( -name "*.dmg" -o -name "*.exe" -o -name "*.AppImage" \) | while read f; do | |
| cp "$f" . | |
| done | |
| shasum -a 256 *.dmg *.exe *.AppImage > checksums.txt 2>/dev/null || true | |
| cat checksums.txt | |
| - name: Attest build provenance for binaries | |
| uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-path: | | |
| artifacts/*.dmg | |
| artifacts/*.exe | |
| artifacts/*.AppImage | |
| - name: Generate version.json | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| echo "{\"version\":\"${VERSION}\",\"date\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"dmg\":\"Purroxy-${VERSION}-arm64.dmg\",\"exe\":\"Purroxy-Setup-${VERSION}.exe\",\"appimage\":\"Purroxy-${VERSION}.AppImage\"}" > artifacts/version.json | |
| - name: Generate electron-updater metadata | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| DATE=$(date -u +%Y-%m-%dT%H:%M:%S.000Z) | |
| DMG="artifacts/Purroxy-${VERSION}-arm64.dmg" | |
| EXE="artifacts/Purroxy-Setup-${VERSION}.exe" | |
| APPIMAGE="artifacts/Purroxy-${VERSION}.AppImage" | |
| gen_yml() { | |
| local FILE="$1" OUTPUT="$2" | |
| local BASENAME=$(basename "$FILE") | |
| local SHA512=$(openssl dgst -sha512 -binary "$FILE" | base64 -w 0 2>/dev/null || openssl dgst -sha512 -binary "$FILE" | base64) | |
| local SIZE=$(stat --format=%s "$FILE" 2>/dev/null || stat -f%z "$FILE") | |
| cat > "$OUTPUT" <<EOF | |
| version: ${VERSION} | |
| files: | |
| - url: ${BASENAME} | |
| sha512: ${SHA512} | |
| size: ${SIZE} | |
| path: ${BASENAME} | |
| sha512: ${SHA512} | |
| releaseDate: '${DATE}' | |
| EOF | |
| } | |
| gen_yml "$DMG" "artifacts/latest-mac.yml" | |
| gen_yml "$EXE" "artifacts/latest.yml" | |
| gen_yml "$APPIMAGE" "artifacts/latest-linux.yml" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| artifacts/**/*.dmg | |
| artifacts/**/*.exe | |
| artifacts/**/*.AppImage | |
| artifacts/checksums.txt | |
| artifacts/version.json | |
| artifacts/latest-mac.yml | |
| artifacts/latest.yml | |
| artifacts/latest-linux.yml | |
| generate_release_notes: true | |
| - name: Delete old releases | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| CURRENT_TAG="${{ github.ref_name }}" | |
| gh release list --json tagName --jq '.[].tagName' | while read tag; do | |
| if [ "$tag" != "$CURRENT_TAG" ]; then | |
| gh release delete "$tag" --yes --cleanup-tag || true | |
| fi | |
| done | |
| publish-npm: | |
| needs: [release] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Set version from tag | |
| run: npm version "${GITHUB_REF#refs/tags/v}" --no-git-tag-version | |
| - name: Publish to npm | |
| run: bash scripts/publish-npm.sh | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| cleanup-after: | |
| needs: [release, publish-npm] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Delete artifacts from this run | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts \ | |
| --jq '.artifacts[].id' | while read id; do | |
| gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$id || true | |
| done |