From d9fd18474f6dd517ccd5212e00e7ea87cb1ae0ea Mon Sep 17 00:00:00 2001 From: Zeno Jiricek Date: Tue, 18 Aug 2026 22:22:51 +0930 Subject: [PATCH] feat(release): split desktop builds by platform --- .github/actions/build-linux/action.yml | 35 +++++++++++ .github/actions/build-mac/action.yml | 77 +++++++++++++++++++++++ .github/actions/build-win32/action.yml | 44 +++++++++++++ .github/workflows/desktop-release.yml | 86 ++++++++++++-------------- apps/desktop/electron-builder.yml | 1 + 5 files changed, 197 insertions(+), 46 deletions(-) create mode 100644 .github/actions/build-linux/action.yml create mode 100644 .github/actions/build-mac/action.yml create mode 100644 .github/actions/build-win32/action.yml diff --git a/.github/actions/build-linux/action.yml b/.github/actions/build-linux/action.yml new file mode 100644 index 0000000..5a2f4ae --- /dev/null +++ b/.github/actions/build-linux/action.yml @@ -0,0 +1,35 @@ +name: Build Linux desktop + +description: Build and store the Linux desktop package. + +inputs: + version: + description: Package version. + required: true + artifact-name: + description: GitHub Actions artifact name. + required: true + +runs: + using: composite + steps: + - name: Build Linux package + shell: bash + run: npm run desktop:dist -- --publish never --linux --x64 + + - name: Verify Linux artifacts + shell: bash + env: + VERSION: ${{ inputs.version }} + run: | + test -f "dist/desktop/SketchForge-$VERSION-x86_64.AppImage" + test -f dist/desktop/latest-linux.yml + + - name: Store Linux artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: | + dist/desktop/SketchForge-*.AppImage + dist/desktop/latest-linux.yml + if-no-files-found: error diff --git a/.github/actions/build-mac/action.yml b/.github/actions/build-mac/action.yml new file mode 100644 index 0000000..2c9bc69 --- /dev/null +++ b/.github/actions/build-mac/action.yml @@ -0,0 +1,77 @@ +name: Build macOS desktop + +description: Build and store the macOS desktop package. + +inputs: + version: + description: Package version. + required: true + artifact-name: + description: GitHub Actions artifact name. + required: true + csc-link: + description: Developer ID Application certificate. + required: false + csc-key-password: + description: Developer ID Application certificate password. + required: false + apple-api-key: + description: App Store Connect API private key path. + required: false + apple-api-key-id: + description: App Store Connect API key ID. + required: false + apple-api-issuer: + description: App Store Connect API issuer ID. + required: false + +runs: + using: composite + steps: + - name: Resolve macOS signing state + id: signing + shell: bash + env: + CSC_LINK: ${{ inputs.csc-link }} + CSC_KEY_PASSWORD: ${{ inputs.csc-key-password }} + APPLE_API_KEY: ${{ inputs.apple-api-key }} + APPLE_API_KEY_ID: ${{ inputs.apple-api-key-id }} + APPLE_API_ISSUER: ${{ inputs.apple-api-issuer }} + run: | + suffix="" + if [[ -z "$CSC_LINK" || -z "$CSC_KEY_PASSWORD" || -z "$APPLE_API_KEY" || -z "$APPLE_API_KEY_ID" || -z "$APPLE_API_ISSUER" ]]; then + suffix="-unsigned" + fi + echo "artifact_suffix=$suffix" >> "$GITHUB_OUTPUT" + + - name: Build macOS package + shell: bash + env: + CSC_LINK: ${{ inputs.csc-link }} + CSC_KEY_PASSWORD: ${{ inputs.csc-key-password }} + APPLE_API_KEY: ${{ inputs.apple-api-key }} + APPLE_API_KEY_ID: ${{ inputs.apple-api-key-id }} + APPLE_API_ISSUER: ${{ inputs.apple-api-issuer }} + run: | + npm run desktop:dist -- --publish never --mac --universal \ + "-c.mac.artifactName=\${productName}-\${version}-\${arch}${{ steps.signing.outputs.artifact_suffix }}.\${ext}" + + - name: Verify macOS artifacts + shell: bash + env: + VERSION: ${{ inputs.version }} + run: | + suffix="${{ steps.signing.outputs.artifact_suffix }}" + test -f "dist/desktop/SketchForge-$VERSION-universal${suffix}.dmg" + test -f "dist/desktop/SketchForge-$VERSION-universal${suffix}.zip" + test -f dist/desktop/latest-mac.yml + + - name: Store macOS artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: | + dist/desktop/SketchForge-*-universal*.dmg + dist/desktop/SketchForge-*-universal*.zip + dist/desktop/latest-mac.yml + if-no-files-found: error diff --git a/.github/actions/build-win32/action.yml b/.github/actions/build-win32/action.yml new file mode 100644 index 0000000..5174b45 --- /dev/null +++ b/.github/actions/build-win32/action.yml @@ -0,0 +1,44 @@ +name: Build Windows desktop + +description: Build and store the Windows desktop package. + +inputs: + version: + description: Package version. + required: true + artifact-name: + description: GitHub Actions artifact name. + required: true + +runs: + using: composite + steps: + - name: Build Windows package + shell: bash + run: npm run desktop:dist -- --publish never --win --x64 + + - name: Verify Windows artifacts + shell: pwsh + env: + VERSION: ${{ inputs.version }} + run: | + $required = @( + "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe", + "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe.blockmap", + "dist/desktop/latest.yml" + ) + foreach ($file in $required) { + if (-not (Test-Path $file -PathType Leaf)) { + throw "Missing Windows artifact: $file" + } + } + + - name: Store Windows artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: | + dist/desktop/SketchForge-Setup-*-x64.exe + dist/desktop/SketchForge-Setup-*-x64.exe.blockmap + dist/desktop/latest.yml + if-no-files-found: error diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml index 046b4e3..5a036e6 100644 --- a/.github/workflows/desktop-release.yml +++ b/.github/workflows/desktop-release.yml @@ -31,6 +31,9 @@ jobs: - platform: linux runner: ubuntu-latest artifact: desktop-linux + - platform: macos + runner: macos-latest + artifact: desktop-macos runs-on: ${{ matrix.runner }} timeout-minutes: 45 steps: @@ -86,55 +89,28 @@ jobs: - name: Run tests run: npm test - - name: Build desktop package - run: npm run desktop:dist -- --publish never - - - name: Verify Windows artifacts - if: matrix.platform == 'windows' - shell: pwsh - env: - VERSION: ${{ steps.package.outputs.version }} - run: | - $required = @( - "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe", - "dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe.blockmap", - "dist/desktop/latest.yml" - ) - foreach ($file in $required) { - if (-not (Test-Path $file -PathType Leaf)) { - throw "Missing Windows artifact: $file" - } - } - - - name: Verify Linux artifacts - if: matrix.platform == 'linux' - shell: bash - env: - VERSION: ${{ steps.package.outputs.version }} - run: | - test -f "dist/desktop/SketchForge-$VERSION-x86_64.AppImage" - test -f dist/desktop/latest-linux.yml - - - name: Store Windows artifacts - if: matrix.platform == 'windows' - uses: actions/upload-artifact@v4 + - uses: ./.github/actions/build-mac + if: matrix.platform == 'macos' with: - name: ${{ matrix.artifact }} - path: | - dist/desktop/SketchForge-Setup-*-x64.exe - dist/desktop/SketchForge-Setup-*-x64.exe.blockmap - dist/desktop/latest.yml - if-no-files-found: error + version: ${{ steps.package.outputs.version }} + artifact-name: ${{ matrix.artifact }} + csc-link: ${{ secrets.CSC_LINK }} + csc-key-password: ${{ secrets.CSC_KEY_PASSWORD }} + apple-api-key: ${{ secrets.APPLE_API_KEY }} + apple-api-key-id: ${{ secrets.APPLE_API_KEY_ID }} + apple-api-issuer: ${{ secrets.APPLE_API_ISSUER }} - - name: Store Linux artifacts + - uses: ./.github/actions/build-linux if: matrix.platform == 'linux' - uses: actions/upload-artifact@v4 with: - name: ${{ matrix.artifact }} - path: | - dist/desktop/SketchForge-*.AppImage - dist/desktop/latest-linux.yml - if-no-files-found: error + version: ${{ steps.package.outputs.version }} + artifact-name: ${{ matrix.artifact }} + + - uses: ./.github/actions/build-win32 + if: matrix.platform == 'windows' + with: + version: ${{ steps.package.outputs.version }} + artifact-name: ${{ matrix.artifact }} attach: name: Attach packages to release @@ -207,6 +183,12 @@ jobs: name: desktop-linux path: dist/release + - name: Download macOS artifacts + uses: actions/download-artifact@v4 + with: + name: desktop-macos + path: dist/release + - name: Create draft release env: GH_TOKEN: ${{ github.token }} @@ -238,16 +220,28 @@ jobs: GH_TOKEN: ${{ github.token }} TAG: ${{ steps.version.outputs.tag }} VERSION: ${{ steps.package.outputs.version }} + CSC_LINK: ${{ secrets.CSC_LINK }} + CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} + APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} + APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} + APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }} run: | assets=$(gh release view "$TAG" --json isDraft,assets) test "$(jq -r '.isDraft' <<< "$assets")" = "true" names=$(jq -r '.assets[].name' <<< "$assets") + suffix="" + if [[ -z "$CSC_LINK" || -z "$CSC_KEY_PASSWORD" || -z "$APPLE_API_KEY" || -z "$APPLE_API_KEY_ID" || -z "$APPLE_API_ISSUER" ]]; then + suffix="-unsigned" + fi for expected in \ "SketchForge-Setup-$VERSION-x64.exe" \ "SketchForge-Setup-$VERSION-x64.exe.blockmap" \ "latest.yml" \ "SketchForge-$VERSION-x86_64.AppImage" \ - "latest-linux.yml"; do + "latest-linux.yml" \ + "SketchForge-$VERSION-universal${suffix}.dmg" \ + "SketchForge-$VERSION-universal${suffix}.zip" \ + "latest-mac.yml"; do grep -Fxq "$expected" <<< "$names" || { echo "GitHub release is missing $expected" >&2 exit 1 diff --git a/apps/desktop/electron-builder.yml b/apps/desktop/electron-builder.yml index c15996e..458f9b9 100644 --- a/apps/desktop/electron-builder.yml +++ b/apps/desktop/electron-builder.yml @@ -42,6 +42,7 @@ mac: icon: apps/web/public/assets/sketchforge/sketchforge-logo.png target: - dmg + - zip category: public.app-category.graphics-design artifactName: ${productName}-${version}-${arch}.${ext}