|
| 1 | +name: Build macOS DMG |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write # required to upload assets to GitHub Releases |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-mac-dmg: |
| 13 | + name: Build macOS DMG |
| 14 | + runs-on: macos-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
| 19 | + |
| 20 | + - name: Set up pnpm |
| 21 | + uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 |
| 22 | + |
| 23 | + - name: Set up Node.js |
| 24 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 25 | + with: |
| 26 | + node-version: 24 |
| 27 | + cache: pnpm |
| 28 | + cache-dependency-path: pnpm-lock.yaml |
| 29 | + |
| 30 | + - name: Set up uv |
| 31 | + uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2 |
| 32 | + with: |
| 33 | + version: "latest" |
| 34 | + enable-cache: true |
| 35 | + cache-dependency-glob: "backend/uv.lock" |
| 36 | + |
| 37 | + - name: Install Node dependencies |
| 38 | + run: pnpm install --frozen-lockfile |
| 39 | + |
| 40 | + - name: Cache embedded Python environment |
| 41 | + id: python-cache |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: python-embed |
| 45 | + key: python-embed-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('backend/uv.lock', 'backend/.python-version') }} |
| 46 | + |
| 47 | + - name: Prepare embedded Python |
| 48 | + if: steps.python-cache.outputs.cache-hit != 'true' |
| 49 | + run: bash scripts/prepare-python.sh |
| 50 | + |
| 51 | + - name: Generate Python dependency hash |
| 52 | + run: shasum -a 256 backend/uv.lock | awk '{print $1}' > python-deps-hash.txt |
| 53 | + |
| 54 | + - name: Build frontend |
| 55 | + run: pnpm run build:frontend |
| 56 | + |
| 57 | + - name: Build macOS DMG |
| 58 | + env: |
| 59 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + CSC_LINK: ${{ secrets.CSC_LINK }} |
| 61 | + CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} |
| 62 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 63 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 64 | + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} |
| 65 | + run: | |
| 66 | + # Publish to the GitHub Release only when triggered by a release event. |
| 67 | + # For workflow_dispatch, the DMG is available as a workflow artifact below. |
| 68 | + PUBLISH_MODE="never" |
| 69 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 70 | + PUBLISH_MODE="always" |
| 71 | + fi |
| 72 | +
|
| 73 | + # Build electron-builder argument list |
| 74 | + BUILD_ARGS=( |
| 75 | + "--mac" |
| 76 | + "--publish" "$PUBLISH_MODE" |
| 77 | + "--config.publish.owner=${{ github.repository_owner }}" |
| 78 | + "--config.publish.repo=${{ github.event.repository.name }}" |
| 79 | + ) |
| 80 | +
|
| 81 | + # Skip code signing and notarization when secrets are not configured. |
| 82 | + # This allows unsigned DMG builds without requiring an Apple Developer account. |
| 83 | + if [ -z "$CSC_LINK" ] || [ -z "$APPLE_ID" ]; then |
| 84 | + echo "::notice::Code signing secrets not configured — building unsigned DMG" |
| 85 | + export CSC_IDENTITY_AUTO_DISCOVERY=false |
| 86 | + BUILD_ARGS+=("--config.mac.notarize=false") |
| 87 | + fi |
| 88 | +
|
| 89 | + pnpm exec electron-builder "${BUILD_ARGS[@]}" |
| 90 | +
|
| 91 | + - name: Upload DMG artifact |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + with: |
| 94 | + name: macos-dmg |
| 95 | + path: release/*.dmg |
| 96 | + if-no-files-found: error |
| 97 | + retention-days: 30 |
0 commit comments