diff --git a/.github/workflows/apple-notarization-readiness.yml b/.github/workflows/apple-notarization-readiness.yml new file mode 100644 index 000000000..4a4381b2c --- /dev/null +++ b/.github/workflows/apple-notarization-readiness.yml @@ -0,0 +1,44 @@ +name: Apple Notarization Readiness + +on: + pull_request: + branches: + - main + +permissions: {} + +concurrency: + group: apple-notarization-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + readiness: + name: Apple notarization readiness + # This check must report on every pull request so it can be required on + # `main`. Only release PRs need the macOS-only notary service check; every + # other PR gets a fast no-op on Ubuntu. + runs-on: ${{ startsWith(github.head_ref, 'release-please--') && github.event.pull_request.head.repo.full_name == github.repository && 'macos-latest' || 'ubuntu-latest' }} + timeout-minutes: 10 + permissions: + contents: read + steps: + - name: Not a release PR + if: ${{ !startsWith(github.head_ref, 'release-please--') || github.event.pull_request.head.repo.full_name != github.repository }} + run: echo "No Apple notarization check needed for this pull request." + + - name: Checkout trusted verification script + if: ${{ startsWith(github.head_ref, 'release-please--') && github.event.pull_request.head.repo.full_name == github.repository }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + # Never execute pull request code with the Apple release secrets. + # The script comes from the base branch (main), not the release PR. + ref: ${{ github.event.pull_request.base.sha }} + + - name: Verify Apple notarization access + if: ${{ startsWith(github.head_ref, 'release-please--') && github.event.pull_request.head.repo.full_name == github.repository }} + env: + APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }} + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + APPLE_ID_TEAM_ID: ${{ secrets.APPLE_ID_TEAM_ID }} + run: ./scripts/verifyAppleNotarization.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2f05006e2..85ecfe6f9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,8 +36,31 @@ on: permissions: {} jobs: + # Fail in seconds instead of after a build, sign, and notarize cycle. The + # release PR gate should already have caught this, but manual dispatches and + # expired agreements still deserve a clear, early error. + preflight: + name: Apple notarization preflight + runs-on: macos-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Verify Apple notarization access + env: + APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }} + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + APPLE_ID_TEAM_ID: ${{ secrets.APPLE_ID_TEAM_ID }} + run: ./scripts/verifyAppleNotarization.sh + release: name: Publish ${{ matrix.platform }} [electron-builder] + needs: preflight permissions: contents: write strategy: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 984cbf39f..4fd3aac62 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -222,6 +222,11 @@ Releases are automated with [release-please][release-please]. There is no releas 1. **Merge changes into `main`.** Use [Conventional Commits][conventional-commits] for PR titles (`feat:`, `fix:`, `docs:`, `chore(deps):`, ...). The commit type decides the version bump and the changelog section it lands in. 2. **Review the release PR.** release-please keeps an open `chore: release X.Y.Z` pull request up to date as commits land. It bumps the version in `package.json`, regenerates `CHANGELOG.md`, and updates `sonar.projectVersion` in `sonar-project.properties`. Check the [Renovate Dependency Dashboard][github-dependency-dashboard] for any dependency updates you want to include first. + + Before merging, wait for the **Apple notarization readiness** check. It authenticates to Apple's notary service with the same credentials the release uses and fails when a required Apple agreement is missing or expired. Only the Account Holder can accept the [Apple Developer Program License Agreement](https://developer.apple.com/account) or a pending agreement in [App Store Connect](https://appstoreconnect.apple.com/business/agreements), so surface the failure to them instead of re-running the build. + + release-please opens the PR with `GITHUB_TOKEN`, so GitHub holds its workflow runs for approval. A maintainer with write access must select **Approve workflows to run** before CI and the Apple check execute. + 3. **Merge the release PR when you are ready to ship.** Merging is the "go" decision. GitHub Actions then automatically: - builds, signs, and notarizes the app on macOS, Windows, and Linux, @@ -238,6 +243,7 @@ No manual milestone creation, renaming, or closing is required. #### 🔐 Release automation permissions +- release-please uses `GITHUB_TOKEN`, so its release PR workflow runs require approval from a user with write access. - Packaging and publication use `contents: write`. - The milestone automation uses `issues: write`. - Pull request notification uses `issues: write`, `pull-requests: write`, and `contents: read`. diff --git a/scripts/verifyAppleNotarization.sh b/scripts/verifyAppleNotarization.sh new file mode 100755 index 000000000..a8ec9c093 --- /dev/null +++ b/scripts/verifyAppleNotarization.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Verify that the Apple credentials used by the release pipeline can reach the +# notary service and that all required Apple agreements are in effect. +# +# Apple exposes no API for pending agreement status, so `notarytool history` is +# the only reliable signal: it authenticates without submitting an artifact and +# returns the same 403 that a real notarization submission would. Retrying here +# would only hide propagation lag; a failed check is easier to understand and +# re-run once the agreement is actually in effect. +set -euo pipefail + +: "${APPLE_ID_USERNAME:?APPLE_ID_USERNAME is required}" +: "${APPLE_ID_PASSWORD:?APPLE_ID_PASSWORD is required}" +: "${APPLE_ID_TEAM_ID:?APPLE_ID_TEAM_ID is required}" + +if output=$(xcrun notarytool history \ + --apple-id "${APPLE_ID_USERNAME}" \ + --password "${APPLE_ID_PASSWORD}" \ + --team-id "${APPLE_ID_TEAM_ID}" 2>&1); then + printf '%s\n' "${output}" + echo "Apple notarization access verified." + exit 0 +fi + +printf '%s\n' "${output}" + +if grep -q "required agreement is missing or has expired" <<<"${output}"; then + echo "::error title=Apple agreement missing or expired::Notarization is blocked because a required Apple agreement is missing or expired. The Account Holder (not an Admin) must accept the pending agreement at https://developer.apple.com/account and any pending agreement at https://appstoreconnect.apple.com/business/agreements. If the agreement was just accepted, Apple can take a few minutes to propagate; re-run this check." >&2 + exit 1 +fi + +echo "::error title=Apple notarization check failed::notarytool could not authenticate. Check that APPLE_ID_PASSWORD is an app-specific password and APPLE_ID_TEAM_ID matches the Developer ID team." >&2 +exit 1