|
| 1 | +name: Release menubar |
| 2 | + |
| 3 | +# Tag-driven release of the Mac menu bar app, draft-first: |
| 4 | +# |
| 5 | +# git tag v0.0.2 && git push origin v0.0.2 |
| 6 | +# → this workflow builds, signs, notarizes, and uploads |
| 7 | +# dmg + zip + blockmap + latest-mac.yml to a DRAFT GitHub release |
| 8 | +# → smoke-test the draft's dmg locally, then click "Publish release" |
| 9 | +# |
| 10 | +# electron-updater only sees PUBLISHED releases, so the draft is the safety |
| 11 | +# gate: installed apps' periodic checks (electron/updater.ts, 6h) start |
| 12 | +# picking the version up only at the moment of manual publish. A bad build |
| 13 | +# never reaches users — delete the draft and re-tag. |
| 14 | +# |
| 15 | +# Required repo secrets (Settings → Secrets and variables → Actions): |
| 16 | +# CSC_LINK base64 of the Developer ID Application .p12 export |
| 17 | +# CSC_KEY_PASSWORD password chosen at .p12 export |
| 18 | +# APPLE_API_KEY_P8 base64 of the App Store Connect API .p8 key |
| 19 | +# APPLE_API_KEY_ID the key's ID |
| 20 | +# APPLE_API_ISSUER the ASC issuer UUID |
| 21 | +# (electron-builder imports the cert into a temp keychain via CSC_LINK and |
| 22 | +# notarizes via notarytool with the API key — same env contract as the local |
| 23 | +# `package:mac:notarize` script's .env.local.) |
| 24 | + |
| 25 | +on: |
| 26 | + push: |
| 27 | + tags: ["v*"] |
| 28 | + |
| 29 | +permissions: |
| 30 | + contents: write # create the draft release + upload assets |
| 31 | + |
| 32 | +jobs: |
| 33 | + release: |
| 34 | + runs-on: macos-15 # Apple Silicon — we ship arm64-only (V0) |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 0 # full history + tags for the commit-log release notes |
| 39 | + |
| 40 | + - uses: pnpm/action-setup@v4 # version from root package.json `packageManager` |
| 41 | + |
| 42 | + - uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + node-version: 24 |
| 45 | + cache: pnpm |
| 46 | + |
| 47 | + - run: pnpm install --frozen-lockfile |
| 48 | + |
| 49 | + # The feed (latest-mac.yml) advertises the package.json version; if the |
| 50 | + # tag disagrees, installed apps would update to something other than |
| 51 | + # what the tag claims. Fail fast instead. |
| 52 | + - name: Assert tag matches menubar package version |
| 53 | + run: | |
| 54 | + TAG_VERSION="${GITHUB_REF_NAME#v}" |
| 55 | + PKG_VERSION=$(node -p "require('./packages/menubar/package.json').version") |
| 56 | + if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then |
| 57 | + echo "::error::tag $GITHUB_REF_NAME but packages/menubar/package.json is $PKG_VERSION — bump the package version (or re-tag) so the update feed stays truthful" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Typecheck + tests |
| 62 | + run: | |
| 63 | + pnpm -r typecheck |
| 64 | + pnpm test |
| 65 | +
|
| 66 | + - name: Write App Store Connect API key |
| 67 | + env: |
| 68 | + APPLE_API_KEY_P8: ${{ secrets.APPLE_API_KEY_P8 }} |
| 69 | + run: | |
| 70 | + echo "$APPLE_API_KEY_P8" | base64 --decode > "$RUNNER_TEMP/asc-api-key.p8" |
| 71 | + echo "APPLE_API_KEY=$RUNNER_TEMP/asc-api-key.p8" >> "$GITHUB_ENV" |
| 72 | +
|
| 73 | + - name: Build, sign, notarize, upload to draft release |
| 74 | + env: |
| 75 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + CSC_LINK: ${{ secrets.CSC_LINK }} |
| 77 | + CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} |
| 78 | + # APPLE_API_KEY exported by the previous step; its presence flips |
| 79 | + # electron-builder.cjs's `notarize` gate on. |
| 80 | + APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} |
| 81 | + APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }} |
| 82 | + run: | |
| 83 | + pnpm --filter '@sidecodeapp/menubar...' run build |
| 84 | + pnpm --filter @sidecodeapp/menubar exec electron-builder --mac --arm64 --publish always |
| 85 | +
|
| 86 | + # electron-builder creates the draft with an empty body; fill it with the |
| 87 | + # commit log since the previous tag. Direct-to-main workflow means GitHub's |
| 88 | + # PR-based auto-notes would be empty — the commit subjects ARE the |
| 89 | + # changelog here. Hand-write a short "What's new" above the list before |
| 90 | + # publishing. |
| 91 | + - name: Attach commit log to the draft release |
| 92 | + env: |
| 93 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + run: | |
| 95 | + TAG="$GITHUB_REF_NAME" |
| 96 | + PREV=$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true) |
| 97 | + RANGE="${PREV:+$PREV..}$TAG" |
| 98 | + { |
| 99 | + echo "<!-- Add a short user-facing What's New above the commit list before publishing. -->" |
| 100 | + echo "" |
| 101 | + echo "## Commits${PREV:+ since $PREV}" |
| 102 | + echo "" |
| 103 | + git log --no-merges --pretty='- %s' "$RANGE" |
| 104 | + } > "$RUNNER_TEMP/notes.md" |
| 105 | + gh release edit "$TAG" --draft=true --notes-file "$RUNNER_TEMP/notes.md" |
0 commit comments