From 546a5931a0588ae7157a1eb7088964b1012f0e4b Mon Sep 17 00:00:00 2001
From: Yazawa Hiroki <47569369+zunda-pixel@users.noreply.github.com>
Date: Tue, 24 Nov 2026 19:39:52 +0900
Subject: [PATCH 1/2] Publish notarized GitHub releases from version tags
---
.github/workflows/release.yml | 574 +++++++--------------------
.github/workflows/resume-release.yml | 8 +-
Docs/maintainer-architecture.md | 11 +-
Homebrew/README.md | 176 ++++----
scripts/sign-release.sh | 96 +++++
5 files changed, 314 insertions(+), 551 deletions(-)
create mode 100755 scripts/sign-release.sh
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 46e49604..74d67013 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,498 +1,206 @@
name: Release
-run-name: Release draft ${{ inputs.release_id }} at ${{ inputs.target_sha }}
-
on:
- workflow_dispatch:
- inputs:
- release_id:
- description: Draft ID supplied by scripts/release.py start
- required: true
- type: string
- target_sha:
- description: Approved full commit SHA
- required: true
- type: string
- content_digest:
- description: Approved draft fingerprint supplied by scripts/release.py start
- required: true
- type: string
+ push:
+ tags:
+ - 'v*'
permissions:
contents: read
concurrency:
- group: release-${{ inputs.release_id }}
+ group: release-${{ github.ref }}
cancel-in-progress: false
+env:
+ VERSION: ${{ github.ref_name }}
+ BINARY_ASSET: xcode-mcpkit-${{ github.ref_name }}-macOS-arm64.zip
+
jobs:
prepare:
- name: Check approved draft
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- permissions:
- # GitHub requires push access to read unpublished drafts.
- contents: write
- outputs:
- version: ${{ steps.draft.outputs.version }}
- prerelease: ${{ steps.draft.outputs.prerelease }}
- release_url: ${{ steps.draft.outputs.release_url }}
- steps:
- - name: Require default branch
- env:
- WORKFLOW_REF: ${{ github.ref }}
- RELEASE_BRANCH: ${{ github.event.repository.default_branch }}
- run: test "$WORKFLOW_REF" = "refs/heads/$RELEASE_BRANCH"
-
- - name: Checkout workflow scripts
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ github.workflow_sha }}
- persist-credentials: false
-
- - name: Verify approved draft
- id: draft
- env:
- GH_TOKEN: ${{ github.token }}
- RELEASE_ID: ${{ inputs.release_id }}
- TARGET_SHA: ${{ inputs.target_sha }}
- CONTENT_DIGEST: ${{ inputs.content_digest }}
- run: |
- python3 scripts/release.py verify \
- --repo "$GITHUB_REPOSITORY" --release-id "$RELEASE_ID" \
- --target "$TARGET_SHA" --digest "$CONTENT_DIGEST" \
- --github-output "$GITHUB_OUTPUT"
-
- source-approval-summary:
- name: Review prepared source before tap dispatch
- needs: [prepare, package-tests, source-tag, package-source]
- if: needs.prepare.outputs.prerelease == 'false'
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- steps:
- - name: Summarize the candidate before release approval
- env:
- VERSION: ${{ needs.prepare.outputs.version }}
- TARGET_SHA: ${{ inputs.target_sha }}
- RELEASE_URL: ${{ needs.prepare.outputs.release_url }}
- CONTENT_DIGEST: ${{ inputs.content_digest }}
- WORKFLOW_SHA: ${{ github.workflow_sha }}
- ARTIFACT_ID: ${{ needs.package-source.outputs.artifact_id }}
- run: |
- {
- echo '## Prepared source awaiting tap dispatch approval'
- echo
- printf 'Version: %s\n\n' "$VERSION"
- printf 'Source commit: %s\n\n' "$TARGET_SHA"
- printf 'Approved content digest: %s\n\n' "$CONTENT_DIGEST"
- printf '[Review draft title and notes](%s)\n\n' "$RELEASE_URL"
- printf '[Review code receiving the private key](https://github.com/%s/blob/%s/.github/workflows/release.yml)\n\n' "$GITHUB_REPOSITORY" "$WORKFLOW_SHA"
- printf '[Prepared source and Formula](https://github.com/%s/actions/runs/%s/artifacts/%s)\n\n' "$GITHUB_REPOSITORY" "$GITHUB_RUN_ID" "$ARTIFACT_ID"
- echo 'The approved source tag and assets are prepared. Approving release-publish permits the GitHub App private key to start the tap update. Matching bottle CI, publication, and source release verification then proceed automatically.'
- } >> "$GITHUB_STEP_SUMMARY"
-
- source-tag:
- name: Prepare public approved source tag
- needs: [prepare, package-tests]
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- permissions:
- contents: write
- outputs:
- source_url: ${{ steps.source.outputs.source_url }}
- steps:
- - name: Checkout workflow scripts
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ github.workflow_sha }}
- persist-credentials: false
- - name: Create only the approved tested tag
- id: source
- env:
- GH_TOKEN: ${{ github.token }}
- RELEASE_ID: ${{ inputs.release_id }}
- TARGET_SHA: ${{ inputs.target_sha }}
- CONTENT_DIGEST: ${{ inputs.content_digest }}
- run: |
- python3 scripts/release.py prepare-source \
- --repo "$GITHUB_REPOSITORY" --release-id "$RELEASE_ID" \
- --target "$TARGET_SHA" --digest "$CONTENT_DIGEST" \
- --github-output "$GITHUB_OUTPUT"
-
- dispatch-tap:
- name: Start approved stable tap update
- needs: [prepare, source-tag, package-source, source-approval-summary]
- if: needs.prepare.outputs.prerelease == 'false'
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- environment: release-publish
- permissions:
- # Reading the approved Draft requires Contents write.
- contents: write
- steps:
- - name: Checkout trusted notification code
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ github.workflow_sha }}
- persist-credentials: false
- - name: Revalidate approved content before using the App key
- env:
- GH_TOKEN: ${{ github.token }}
- RELEASE_ID: ${{ inputs.release_id }}
- TARGET_SHA: ${{ inputs.target_sha }}
- CONTENT_DIGEST: ${{ inputs.content_digest }}
- run: |
- python3 scripts/release.py verify --repo "$GITHUB_REPOSITORY" \
- --release-id "$RELEASE_ID" --target "$TARGET_SHA" --digest "$CONTENT_DIGEST"
- - name: Download the prepared source and Formula
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- with:
- artifact-ids: ${{ needs.package-source.outputs.artifact_id }}
- path: release
- digest-mismatch: error
- - name: Verify prepared release assets
- env:
- VERSION: ${{ needs.prepare.outputs.version }}
- CHECKSUMS_SHA256: ${{ needs.package-source.outputs.checksums_sha256 }}
- run: |
- python3 scripts/package_release.py verify --version "$VERSION" \
- --release-dir release --checksums-sha256 "$CHECKSUMS_SHA256"
- - name: Create a token scoped to tap workflow dispatch
- id: tap-token
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
- with:
- client-id: ${{ vars.TAP_DISPATCH_APP_CLIENT_ID }}
- private-key: ${{ secrets.TAP_DISPATCH_APP_PRIVATE_KEY }}
- owner: lynnswap
- repositories: homebrew-tap
- permission-actions: write
- - name: Start the matching stable tap update
- env:
- GH_TOKEN: ${{ steps.tap-token.outputs.token }}
- VERSION: ${{ needs.prepare.outputs.version }}
- TARGET_SHA: ${{ inputs.target_sha }}
- run: |
- python3 scripts/release.py dispatch-tap \
- --source-repository "$GITHUB_REPOSITORY" --version "$VERSION" \
- --target "$TARGET_SHA" --release-dir release
-
- package-source:
- name: Package approved source and Formula
- needs: [prepare, source-tag]
+ name: Check release tag
runs-on: ubuntu-24.04
- timeout-minutes: 10
outputs:
- checksums_sha256: ${{ steps.digest.outputs.checksums_sha256 }}
- artifact_id: ${{ steps.assets.outputs.artifact-id }}
+ prerelease: ${{ steps.tag.outputs.prerelease }}
+ commit: ${{ steps.tag.outputs.commit }}
steps:
- - name: Checkout workflow scripts
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ github.workflow_sha }}
- persist-credentials: false
-
- - name: Checkout approved source
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- ref: ${{ inputs.target_sha }}
- path: source
+ fetch-depth: 0
persist-credentials: false
-
- - name: Package source and Formula
+ - id: tag
env:
- VERSION: ${{ needs.prepare.outputs.version }}
- COMMIT: ${{ inputs.target_sha }}
- SOURCE_URL: ${{ needs.source-tag.outputs.source_url }}
+ DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
- curl --fail --location "$SOURCE_URL" --output source.tar.gz
- python3 scripts/package_release.py create \
- --source-root source --commit "$COMMIT" --version "$VERSION" \
- --repo "$GITHUB_REPOSITORY" --output-dir release --source-archive source.tar.gz
- python3 scripts/package_release.py verify --version "$VERSION" --release-dir release
-
- - name: Record release checksums digest
- id: digest
- run: echo "checksums_sha256=$(sha256sum release/SHA256SUMS.txt | cut -d ' ' -f 1)" >> "$GITHUB_OUTPUT"
-
- - name: Upload source release assets
- id: assets
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- with:
- name: release-assets-${{ github.run_attempt }}
- path: release/*
- if-no-files-found: error
- compression-level: 0
- retention-days: 35
+ python3 -c 'import sys; from scripts.package_release import is_prerelease; print("prerelease=" + str(is_prerelease(sys.argv[1])).lower())' "$VERSION" >> "$GITHUB_OUTPUT"
+ git merge-base --is-ancestor HEAD "refs/remotes/origin/$DEFAULT_BRANCH"
+ echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- package-tests:
- name: Test approved source
+ tests:
+ name: Test tagged source
needs: prepare
uses: ./.github/workflows/ci.yml
with:
- source_sha: ${{ inputs.target_sha }}
+ source_sha: ${{ needs.prepare.outputs.commit }}
run_process_tests: true
- concurrency_group: release-package-checks-${{ inputs.release_id }}
+ concurrency_group: release-tests-${{ github.ref }}
- record-plan:
- name: Record prepared release
- needs: [prepare, source-tag, package-source]
- if: needs.prepare.outputs.prerelease == 'false'
- runs-on: ubuntu-24.04
- timeout-minutes: 5
+ package:
+ name: Build release assets
+ needs: prepare
+ runs-on: xcode-27
+ timeout-minutes: 45
+ outputs:
+ artifact_id: ${{ steps.package.outputs.artifact-id }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- ref: ${{ github.workflow_sha }}
persist-credentials: false
- - name: Record the approved run and prepared artifact identity
- env:
- RELEASE_ID: ${{ inputs.release_id }}
- VERSION: ${{ needs.prepare.outputs.version }}
- TARGET_SHA: ${{ inputs.target_sha }}
- CONTENT_DIGEST: ${{ inputs.content_digest }}
- ARTIFACT_ID: ${{ needs.package-source.outputs.artifact_id }}
- CHECKSUMS_SHA256: ${{ needs.package-source.outputs.checksums_sha256 }}
- run: |
- python3 scripts/release_sync.py record --release-id "$RELEASE_ID" \
- --version "$VERSION" --target "$TARGET_SHA" --content-digest "$CONTENT_DIGEST" \
- --source-artifact-id "$ARTIFACT_ID" --checksums-sha256 "$CHECKSUMS_SHA256" \
- --output "$RUNNER_TEMP/release-plan.json"
+ - name: Build the CLI and native host
+ run: |
+ xcodebuild -version
+ scripts/build-release.sh --version "$VERSION" --dist-root "$RUNNER_TEMP/dist"
+ mkdir -p xcode-mcpkit/bin release
+ mv "$RUNNER_TEMP/dist/arm64/bin" xcode-mcpkit/libexec
+ ln -s ../libexec/xcode-mcp-server xcode-mcpkit/bin/xcode-mcp-server
+ ditto -c -k --keepParent xcode-mcpkit unsigned.zip
+ - name: Prepare source and Formula
+ env:
+ TAG_COMMIT: ${{ needs.prepare.outputs.commit }}
+ run: |
+ curl --fail --location --retry 3 \
+ "https://github.com/$GITHUB_REPOSITORY/archive/refs/tags/$VERSION.tar.gz" \
+ --output "$RUNNER_TEMP/source.tar.gz"
+ python3 scripts/package_release.py create --source-root . --commit "$TAG_COMMIT" \
+ --version "$VERSION" --repo "$GITHUB_REPOSITORY" --output-dir release \
+ --source-archive "$RUNNER_TEMP/source.tar.gz"
+ python3 scripts/package_release.py verify --version "$VERSION" --release-dir release
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ id: package
with:
- name: release-plan-${{ github.run_attempt }}
- path: ${{ runner.temp }}/release-plan.json
+ name: release-inputs-${{ github.run_attempt }}
+ path: |
+ unsigned.zip
+ release/
if-no-files-found: error
- retention-days: 35
- homebrew:
- name: Test prerelease Formula and installed bottle
- needs: [prepare, package-source]
- if: needs.prepare.outputs.prerelease == 'true'
+ sign:
+ name: Sign and notarize release archive
+ needs: [tests, package]
runs-on: xcode-27
- timeout-minutes: 60
- env:
- DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
+ timeout-minutes: 40
+ environment: release-signing
+ outputs:
+ artifact_id: ${{ steps.signed.outputs.artifact-id }}
steps:
- - name: Checkout workflow scripts
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- ref: ${{ github.workflow_sha }}
persist-credentials: false
-
- - name: Download source release assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
- artifact-ids: ${{ needs.package-source.outputs.artifact_id }}
- path: release
+ artifact-ids: ${{ needs.package.outputs.artifact_id }}
digest-mismatch: error
+ - name: Sign staged code and submit the archive to Apple
+ env:
+ APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
+ DEVELOPER_ID_P12_BASE64: ${{ secrets.DEVELOPER_ID_P12_BASE64 }}
+ DEVELOPER_ID_P12_PASSWORD: ${{ secrets.DEVELOPER_ID_P12_PASSWORD }}
+ NOTARY_API_PRIVATE_KEY: ${{ secrets.NOTARY_API_PRIVATE_KEY }}
+ NOTARY_API_KEY_ID: ${{ vars.NOTARY_API_KEY_ID }}
+ NOTARY_API_ISSUER_ID: ${{ vars.NOTARY_API_ISSUER_ID }}
+ run: |
+ ditto -x -k unsigned.zip "$RUNNER_TEMP"
+ scripts/sign-release.sh sign "$RUNNER_TEMP/xcode-mcpkit" "$PWD/$BINARY_ASSET"
+ shasum -a 256 "$BINARY_ASSET" > macOS-arm64-SHA256SUMS.txt
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ id: signed
+ with:
+ name: signed-macos-arm64-${{ github.run_attempt }}
+ path: |
+ ${{ env.BINARY_ASSET }}
+ macOS-arm64-SHA256SUMS.txt
+ if-no-files-found: error
- - name: Verify transferred assets
- env:
- VERSION: ${{ needs.prepare.outputs.version }}
- CHECKSUMS_SHA256: ${{ needs.package-source.outputs.checksums_sha256 }}
- run: |
- python3 scripts/package_release.py verify --version "$VERSION" \
- --release-dir release --checksums-sha256 "$CHECKSUMS_SHA256"
-
- - name: Build, bottle, reinstall and exercise the native helper and server
- run: scripts/test-homebrew.sh release
-
- tap-status:
- name: Check stable tap delivery
- needs: [prepare, package-source, package-tests, record-plan, dispatch-tap]
- if: >-
- always() && needs.prepare.result == 'success' && needs.package-source.result == 'success' &&
- needs.package-tests.result == 'success' &&
- (needs.prepare.outputs.prerelease == 'true' ||
- (needs.record-plan.result == 'success' && needs.dispatch-tap.result == 'success'))
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- outputs:
- ready: ${{ steps.tap.outputs.ready }}
+ verify:
+ name: Verify the signed release archive
+ needs: sign
+ runs-on: xcode-27
+ timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- ref: ${{ github.workflow_sha }}
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
- artifact-ids: ${{ needs.package-source.outputs.artifact_id }}
- path: release
+ artifact-ids: ${{ needs.sign.outputs.artifact_id }}
digest-mismatch: error
- - name: Inspect prepared tap delivery
- id: tap
+ - name: Verify the extracted distribution and exercise MCP
env:
- GH_TOKEN: ${{ github.token }}
- VERSION: ${{ needs.prepare.outputs.version }}
- CHECKSUMS_SHA256: ${{ needs.package-source.outputs.checksums_sha256 }}
+ APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
run: |
- python3 scripts/package_release.py verify --version "$VERSION" \
- --release-dir release --checksums-sha256 "$CHECKSUMS_SHA256"
- python3 scripts/release.py tap-status --version "$VERSION" \
- --release-dir release --github-output "$GITHUB_OUTPUT"
- - name: Report normal tap preparation wait
- if: steps.tap.outputs.ready == 'false'
- run: |
- echo 'The approved release remains a Draft while the tap PR awaits CI and publication. Resume prepared releases will retry this probe and its dependents after matching public delivery; completed package checks are reused.' >> "$GITHUB_STEP_SUMMARY"
+ shasum -a 256 -c macOS-arm64-SHA256SUMS.txt
+ ditto -x -k "$BINARY_ASSET" "$RUNNER_TEMP"
+ scripts/sign-release.sh verify "$RUNNER_TEMP/xcode-mcpkit"
+ python3 scripts/smoke-homebrew.py --prefix "$RUNNER_TEMP/xcode-mcpkit" \
+ --version "$VERSION" --fixture Fixtures/ProxyToolVerifierFixture
- homebrew-ready:
- name: Verify published tap installation
- needs: [prepare, package-source, tap-status]
- if: >-
- always() && needs.prepare.result == 'success' && needs.package-source.result == 'success' &&
- needs.tap-status.result == 'success' && needs.tap-status.outputs.ready == 'true'
- runs-on: xcode-27
- timeout-minutes: 15
- env:
- DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
- outputs:
- required: ${{ steps.tap.outputs.required }}
- tap_sha: ${{ steps.tap.outputs.tap_sha }}
- formula_sha256: ${{ steps.tap.outputs.formula_sha256 }}
- bottle_sha256: ${{ steps.tap.outputs.bottle_sha256 }}
- bottle_url: ${{ steps.tap.outputs.bottle_url }}
+ publish:
+ name: Publish GitHub Release
+ needs: [prepare, package, sign, verify]
+ runs-on: ubuntu-24.04
+ permissions:
+ contents: write
steps:
- - name: Checkout workflow scripts
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
- ref: ${{ github.workflow_sha }}
- persist-credentials: false
- - name: Download prepared release assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ artifact-ids: ${{ needs.package.outputs.artifact_id }}
+ digest-mismatch: error
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
- artifact-ids: ${{ needs.package-source.outputs.artifact_id }}
- path: release
+ artifact-ids: ${{ needs.sign.outputs.artifact_id }}
digest-mismatch: error
- - name: Verify transferred assets
- env:
- VERSION: ${{ needs.prepare.outputs.version }}
- CHECKSUMS_SHA256: ${{ needs.package-source.outputs.checksums_sha256 }}
- run: |
- python3 scripts/package_release.py verify --version "$VERSION" \
- --release-dir release --checksums-sha256 "$CHECKSUMS_SHA256"
- - name: Verify public Formula and bottle metadata
- id: tap
+ - name: Publish verified assets
env:
GH_TOKEN: ${{ github.token }}
- VERSION: ${{ needs.prepare.outputs.version }}
- run: |
- python3 scripts/release.py homebrew-ready --version "$VERSION" \
- --release-dir release --github-output "$GITHUB_OUTPUT"
- - name: Install and test the published stable bottle
- if: steps.tap.outputs.required == 'true'
- env:
- VERSION: ${{ needs.prepare.outputs.version }}
- TAP_SHA: ${{ steps.tap.outputs.tap_sha }}
- HOMEBREW_NO_AUTO_UPDATE: "1"
- HOMEBREW_NO_INSTALL_CLEANUP: "1"
- run: |
- formula=lynnswap/tap/xcode-mcpkit
- brew tap lynnswap/tap
- tap_root="$(brew --repository lynnswap/tap)"
- git -C "$tap_root" fetch origin "$TAP_SHA"
- git -C "$tap_root" checkout --detach "$TAP_SHA"
- brew trust --formula "$formula"
- brew install --include-test "$formula"
- brew info --json=v2 "$formula" | python3 -c '
- import json, sys
- installed = json.load(sys.stdin)["formulae"][0]["installed"][0]
- if not installed["poured_from_bottle"]:
- sys.exit("Published tap verification expected a bottle installation.")
- '
- installed_binary="$(brew --prefix "$formula")/bin/xcode-mcp-server"
- test "$("$installed_binary" --version)" = "$VERSION"
- brew test "$formula"
- "$(brew --prefix python@3.14)/bin/python3.14" \
- "$(brew --prefix "$formula")/share/xcode-mcpkit/smoke-homebrew.py" \
- --prefix "$(brew --prefix "$formula")" --version "$VERSION"
+ GH_REPO: ${{ github.repository }}
+ PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
+ TAG_COMMIT: ${{ needs.prepare.outputs.commit }}
+ run: |
+ tag_commit="$(gh api "repos/$GH_REPO/commits/$VERSION" --jq .sha)"
+ test "$tag_commit" = "$TAG_COMMIT"
+ sha256sum --check macOS-arm64-SHA256SUMS.txt
+ (cd release && sha256sum --check SHA256SUMS.txt)
+ flags=()
+ if [[ "$PRERELEASE" == true ]]; then flags+=(--prerelease); fi
+ gh release create --generate-notes --verify-tag "${flags[@]}" -- "$VERSION" \
+ "$BINARY_ASSET" macOS-arm64-SHA256SUMS.txt release/*
- publication-summary:
- name: Review verified release outputs
- needs: [prepare, package-source, package-tests, homebrew, homebrew-ready]
- if: >-
- always() && needs.prepare.result == 'success' && needs.package-source.result == 'success' &&
- needs.package-tests.result == 'success' && needs.homebrew-ready.result == 'success' &&
- (needs.prepare.outputs.prerelease == 'false' || needs.homebrew.result == 'success')
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- steps:
- - name: Summarize the candidate before publication
- env:
- VERSION: ${{ needs.prepare.outputs.version }}
- TARGET_SHA: ${{ inputs.target_sha }}
- RELEASE_URL: ${{ needs.prepare.outputs.release_url }}
- CONTENT_DIGEST: ${{ inputs.content_digest }}
- CHECKSUMS_SHA256: ${{ needs.package-source.outputs.checksums_sha256 }}
- ARTIFACT_ID: ${{ needs.package-source.outputs.artifact_id }}
- TAP_REQUIRED: ${{ needs.homebrew-ready.outputs.required }}
- TAP_SHA: ${{ needs.homebrew-ready.outputs.tap_sha }}
- BOTTLE_SHA256: ${{ needs.homebrew-ready.outputs.bottle_sha256 }}
- BOTTLE_URL: ${{ needs.homebrew-ready.outputs.bottle_url }}
- run: |
- {
- echo '## Approved release verification complete'
- echo
- printf 'Version: %s\n\n' "$VERSION"
- printf 'Source commit: %s\n\n' "$TARGET_SHA"
- printf 'Approved content digest: %s\n\n' "$CONTENT_DIGEST"
- printf 'Checksums file SHA-256: %s\n\n' "$CHECKSUMS_SHA256"
- printf '[Draft release](%s)\n\n' "$RELEASE_URL"
- printf '[Verified source and Formula artifact](https://github.com/%s/actions/runs/%s/artifacts/%s)\n\n' "$GITHUB_REPOSITORY" "$GITHUB_RUN_ID" "$ARTIFACT_ID"
- if [[ "$TAP_REQUIRED" == true ]]; then
- printf '[Published tap Formula](https://github.com/lynnswap/homebrew-tap/blob/%s/Formula/xcode-mcpkit.rb)\n\n' "$TAP_SHA"
- printf '[Installed published bottle](%s), SHA-256: %s\n\n' "$BOTTLE_URL" "$BOTTLE_SHA256"
- echo 'The matching public tap bottle was installed and tested successfully.'
- fi
- echo 'The approved candidate and matching published tap passed verification. The publisher will revalidate their identity and publish automatically.'
- } >> "$GITHUB_STEP_SUMMARY"
-
- publish:
- name: Publish verified source release
- needs: [prepare, source-tag, package-source, homebrew-ready, publication-summary]
- if: >-
- always() && needs.prepare.result == 'success' && needs.source-tag.result == 'success' &&
- needs.package-source.result == 'success' && needs.homebrew-ready.result == 'success' &&
- needs.publication-summary.result == 'success'
+ homebrew:
+ name: Request Homebrew update after publication
+ needs: [prepare, package, publish]
+ if: needs.prepare.outputs.prerelease == 'false'
runs-on: ubuntu-24.04
- timeout-minutes: 10
- permissions:
- contents: write
+ environment: release-publish
steps:
- - name: Checkout workflow scripts
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- # Publication credentials never execute code from the release target.
- ref: ${{ github.workflow_sha }}
persist-credentials: false
-
- - name: Download release assets
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
- artifact-ids: ${{ needs.package-source.outputs.artifact_id }}
- path: release
+ artifact-ids: ${{ needs.package.outputs.artifact_id }}
digest-mismatch: error
-
- - name: Verify transferred assets
- env:
- VERSION: ${{ needs.prepare.outputs.version }}
- CHECKSUMS_SHA256: ${{ needs.package-source.outputs.checksums_sha256 }}
- run: |
- python3 scripts/package_release.py verify --version "$VERSION" \
- --release-dir release --checksums-sha256 "$CHECKSUMS_SHA256"
-
- - name: Upload assets and publish approved draft
+ - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
+ id: tap-token
+ with:
+ client-id: ${{ vars.TAP_DISPATCH_APP_CLIENT_ID }}
+ private-key: ${{ secrets.TAP_DISPATCH_APP_PRIVATE_KEY }}
+ owner: lynnswap
+ repositories: homebrew-tap
+ permission-actions: write
+ - name: Dispatch the tap workflow
env:
- GH_TOKEN: ${{ github.token }}
- RELEASE_ID: ${{ inputs.release_id }}
- TARGET_SHA: ${{ inputs.target_sha }}
- CONTENT_DIGEST: ${{ inputs.content_digest }}
- TESTED_FORMULA_SHA256: ${{ needs.homebrew-ready.outputs.formula_sha256 }}
- TESTED_BOTTLE_SHA256: ${{ needs.homebrew-ready.outputs.bottle_sha256 }}
- TESTED_BOTTLE_URL: ${{ needs.homebrew-ready.outputs.bottle_url }}
+ GH_TOKEN: ${{ steps.tap-token.outputs.token }}
+ TAG_COMMIT: ${{ needs.prepare.outputs.commit }}
run: |
- python3 scripts/release.py publish \
- --repo "$GITHUB_REPOSITORY" --release-id "$RELEASE_ID" \
- --target "$TARGET_SHA" --digest "$CONTENT_DIGEST" \
- --release-dir release --tested-formula-sha256 "$TESTED_FORMULA_SHA256" \
- --tested-bottle-sha256 "$TESTED_BOTTLE_SHA256" \
- --tested-bottle-url "$TESTED_BOTTLE_URL"
+ python3 scripts/release.py dispatch-tap --source-repository "$GITHUB_REPOSITORY" \
+ --version "$VERSION" --target "$TAG_COMMIT" --release-dir release
diff --git a/.github/workflows/resume-release.yml b/.github/workflows/resume-release.yml
index f5bd3a91..c759ca46 100644
--- a/.github/workflows/resume-release.yml
+++ b/.github/workflows/resume-release.yml
@@ -1,10 +1,6 @@
name: Resume prepared releases
on:
- workflow_run:
- workflows: [Release]
- types: [completed]
- branches: [main]
workflow_dispatch:
permissions: {}
@@ -19,9 +15,7 @@ concurrency:
jobs:
resume:
- if: >-
- github.ref == 'refs/heads/main' &&
- (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')
+ if: github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
diff --git a/Docs/maintainer-architecture.md b/Docs/maintainer-architecture.md
index 48d80e5a..e500bf56 100644
--- a/Docs/maintainer-architecture.md
+++ b/Docs/maintainer-architecture.md
@@ -364,12 +364,11 @@ discovery file for tests. Match verification claims to the operations actually r
## Release
-[Homebrew distribution](../Homebrew/README.md) owns approval, publication, bottle
-verification, and recovery. Approved releases use `scripts/release.py start` to
-create the approved tag and Draft before CI; source CI pins the commit and
-content, prepares the Formula, and waits
-for publication approval before tap dispatch. Both source and Homebrew installs
-keep the signed helper beside the commands. Release orchestration tests use:
+[Release and Homebrew distribution](../Homebrew/README.md) documents the tag
+trigger, Developer ID signing environment, and validation. GitHub Release
+publication depends on verification of the notarized macOS archive. The stable
+Homebrew update starts after publication. Both distributions keep the signed
+helper beside the server binary. Release orchestration tests use:
```sh
python3 -B -m unittest discover -s scripts/tests -v
diff --git a/Homebrew/README.md b/Homebrew/README.md
index c4fead8b..2ec53e43 100644
--- a/Homebrew/README.md
+++ b/Homebrew/README.md
@@ -21,116 +21,82 @@ release also verifies the public bottle on that image without forcing selection.
A host without a matching bottle can build from source with Xcode 27. The
package's macOS 15.4 deployment target is separate from bottle availability.
-## Release an approved revision
+## Publish a tagged release
-After approving the version, full commit SHA, title, and release notes, run:
+After the target commit reaches the default branch, tag the reviewed commit and
+push the tag:
```sh
-python3 scripts/release.py start vX.Y.Z --repo lynnswap/XcodeMCPKit \
- --target FULL_COMMIT_SHA --notes-file /path/to/notes.md
+git tag vX.Y.Z FULL_COMMIT_SHA
+git push origin refs/tags/vX.Y.Z
```
-The script creates or reuses the matching Draft and approved source tag before
-dispatching `release.yml` from the default branch. The version is available to
-package consumers immediately. CI tests the approved source, verifies GitHub's
-tag archive against that commit, and prepares the source
-archive, `xcode-mcpkit.rb`, stable `install.sh`, and `SHA256SUMS.txt`. The Release remains a Draft.
-The generated Formula uses the public tag archive, so tap CI can build it before
-the Release is published.
-
-Tag creation uses the caller's GitHub CLI credentials. If GitHub rejects it,
-check tag rules and the caller's Contents and Workflows write permissions, then
-repeat the same start command. The matching Draft is reused.
-
-Review the version, target, notes, Formula artifact, and trusted workflow commit
-in the Actions summary. Approve the `release-publish` deployment to allow the job
-to use the GitHub App key. It revalidates the approved content, then creates a
-short-lived token restricted to `homebrew-tap` and `Actions: write`.
-
-The job dispatches the tap's `update-formula.yml` with the source tag, commit,
-and source/Formula digests. The tap checks those inputs against the public source,
-creates or reuses a Formula PR, and starts bottle CI for its exact head. This path
-handles the first Formula and subsequent versions; it does not use Renovate.
-The tap prepares a candidate with the tested bottle artifact ID and digest.
-Approve its `release-signing` deployment to allow Developer ID signing and
-notarization. The signing job handles the bottle as data and does not build or
-execute its payload. A separate job installs the signed bottle, checks the Team
-ID and stable helper signing identifier, validates its notarization ticket, and
-runs the native/server smoke tests. The tap then uploads that exact signed bottle
-and merges the Formula PR automatically using its own `GITHUB_TOKEN`.
-
-The source workflow installs the public bottle, checks its CLI versions and
-signature, and exercises native and server MCP sessions against a disposable
-project. The Formula test covers CLI options and signatures; Xcode integration
-runs outside Homebrew's test sandbox in both tap CI and source-release CI.
-The source publisher rechecks the tested delivery before publishing the approved Draft.
-Stable publication never runs when the bottle is missing or installation fails.
-An existing running server must be restarted to use an upgraded payload.
-
-Prerelease tags such as `v1.0.0-rc.1` use an isolated verification tap to build,
-bottle, reinstall, and test the Formula. They do not update the stable tap or
-replace the latest stable release.
-
-## Configure the GitHub App and approval
-
-The existing `lynnswap-homebrew-release-dispatch` App can be reused. Its
-installation must include `homebrew-tap` with `Actions: write`. Adding this source
-repository to the installation is unnecessary for dispatching to the tap; the
-source workflow uses its own `GITHUB_TOKEN` for releases. The local start command
-uses the caller's GitHub CLI credentials to create the approved source tag.
-
-In XcodeMCPKit's `release-publish` Environment:
-
-- Require the maintainer as reviewer and restrict deployment branches to `main`.
-- Disable administrator bypass. Leave **Prevent self-review** off for the sole maintainer.
-- Set `TAP_DISPATCH_APP_CLIENT_ID` to the existing App's Client ID.
-- Register the same PEM key as `TAP_DISPATCH_APP_PRIVATE_KEY`. Environment secrets
- are scoped to each repository; another repository's registration is not inherited.
-
-```sh
-gh variable set TAP_DISPATCH_APP_CLIENT_ID --repo lynnswap/XcodeMCPKit \
- --env release-publish --body APP_CLIENT_ID
-gh secret set TAP_DISPATCH_APP_PRIVATE_KEY --repo lynnswap/XcodeMCPKit \
- --env release-publish < /path/to/existing-app.private-key.pem
-```
-
-In the tap's separate `release-signing` Environment, require the maintainer as
-reviewer, restrict branches to `main`, and disable administrator bypass. Register
-`DEVELOPER_ID_P12_BASE64`, `DEVELOPER_ID_P12_PASSWORD`, and
-`NOTARY_API_PRIVATE_KEY` as Environment secrets. Set `APPLE_TEAM_ID`,
-`NOTARY_API_KEY_ID`, and `NOTARY_API_ISSUER_ID` as Environment variables. The
-installed helper uses signing identifier `com.lynnswap.XcodeMCPNativeHost`; its
-Team ID and signing identifier remain stable across bottle upgrades.
-
-Only the source dispatch job receives the GitHub App key. The job executes the workflow's pinned
-trusted scripts and revokes its installation token when it finishes. The tap
-maintains its own CI, publication permissions, and approval settings; see its
-[maintenance guide](https://github.com/lynnswap/homebrew-tap/blob/main/CONTRIBUTING.md).
-
-## Retry and resume
-
-While tap delivery is pending, the source workflow leaves the Draft and immutable
-prepared assets. After publishing the bottle and updating its Formula on `main`,
-the tap's notification job waits for `source-notification` approval before using
-its dedicated App key to dispatch `resume-release.yml`. A successful source-release run also
-triggers the same check, covering a tap notification that arrives before source
-preparation finishes. There is no scheduled polling.
-
-The resume workflow reruns delivery verification and its dependent jobs only after
-the matching bottle is public. It reuses the completed source tests, source
-archive, and tap-dispatch approval. It can also be dispatched manually from `main`.
-
-Actual build, install, authentication, or publication failures need attention;
-the resumer does not repeatedly retry them. Rerun the failed jobs after fixing
-the reported cause. A failed dispatch can have an uncertain acceptance outcome:
-inspect tap Actions before retrying. Repeated notifications reuse the same PR
-and CI; changed or closed proposals require inspection.
-
-Keep the approved target and publication content unchanged during a run. Changed
-notes or tag identity stop publication. Artifacts are retained for 35 days, while
-GitHub's job-rerun window also applies; expired preparation requires a new run.
-Public source tags and any already-published tap bottles remain if a later step
-fails. Previously published binary releases and their installer assets are retained.
+The Release workflow tests the tagged commit, builds the arm64 macOS CLI and
+native host, and prepares the source archive and Formula. Approve the
+`release-signing` deployment after checking the tag and commit in the run.
+That job signs the distribution with Developer ID Application, submits the
+archive for Apple notarization, and staples the ticket to the native host app.
+A separate job verifies signatures and the ticket from the extracted ZIP, then
+runs an MCP smoke test. After verification passes, the workflow publishes the
+GitHub Release with generated notes, the signed ZIP, and checksums. Tags such
+as `v1.0.0-rc.1` publish as prereleases and skip stable tap dispatch.
+
+After publication, the stable release workflow requests a Formula update in
+`lynnswap/homebrew-tap`. The tap builds, signs, notarizes, and checks its bottle
+using its own pipeline. A pending approval or failed tap job leaves the
+published GitHub Release available. The `install.sh` asset uses Homebrew and
+follows the tap's available version. To use the GitHub distribution directly,
+extract the macOS arm64 ZIP, keep `bin` and `libexec` together, and run
+`./xcode-mcpkit/bin/xcode-mcp-server`.
+
+## Set up XcodeMCPKit release signing
+
+1. In **Settings → Environments**, create `release-signing` in XcodeMCPKit.
+ Require a maintainer reviewer and allow deployment from release tags
+ matching `v*`. Restrict who can create or update those tags using a
+ repository ruleset.
+2. Export a **Developer ID Application** certificate **with its private key**
+ as a password-protected `.p12` file. Use a team App Store Connect API key
+ authorized for notarization and keep its `.p8` file.
+3. Set the following secrets on the XcodeMCPKit environment. The tap's secrets
+ are scoped to the tap repository.
+
+ ```sh
+ base64 -i /path/to/DeveloperID.p12 | tr -d '\n' |
+ gh secret set DEVELOPER_ID_P12_BASE64 --repo lynnswap/XcodeMCPKit --env release-signing
+ gh secret set DEVELOPER_ID_P12_PASSWORD --repo lynnswap/XcodeMCPKit --env release-signing
+ gh secret set NOTARY_API_PRIVATE_KEY --repo lynnswap/XcodeMCPKit --env release-signing \
+ < /path/to/AuthKey_KEY_ID.p8
+ ```
+
+4. Set `APPLE_TEAM_ID` as a repository Actions variable so both signing and
+ verification can check the signing team. Set the notarization key ID and
+ issuer ID on `release-signing`.
+
+ ```sh
+ gh variable set APPLE_TEAM_ID --repo lynnswap/XcodeMCPKit --body TEAM_ID
+ gh variable set NOTARY_API_KEY_ID --repo lynnswap/XcodeMCPKit --env release-signing --body KEY_ID
+ gh variable set NOTARY_API_ISSUER_ID --repo lynnswap/XcodeMCPKit --env release-signing --body ISSUER_ID
+ ```
+
+The post-publication tap dispatch uses the existing `release-publish`
+environment. Allow deployment from release tags matching `v*` and keep
+`TAP_DISPATCH_APP_CLIENT_ID` and `TAP_DISPATCH_APP_PRIVATE_KEY` there. The
+GitHub App installation needs `Actions: write` on `lynnswap/homebrew-tap`.
+The tap retains its own `release-signing` environment and bottle verification.
+
+## Retry and legacy drafts
+
+Rerun failed jobs in the tagged Release workflow after resolving the failure.
+Inspect an existing GitHub Release for the tag before rerunning publication.
+If only Homebrew dispatch failed, rerun that job or inspect the tap Actions
+run if the dispatch may have reached it.
+
+Tags created before this workflow change retain the workflows from their
+tagged commits. Existing drafts can use the legacy manual
+`resume-release.yml` workflow on `main` where applicable. To use the
+tag-triggered process, create a new version tag on a commit containing this
+workflow.
## Local verification
diff --git a/scripts/sign-release.sh b/scripts/sign-release.sh
new file mode 100755
index 00000000..6d2a5c21
--- /dev/null
+++ b/scripts/sign-release.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+host_identifier=com.lynnswap.XcodeMCPNativeHost
+
+verify_signature() {
+ local file="$1" details
+ codesign --verify --deep --strict "$file"
+ details="$(codesign -d --verbose=4 "$file" 2>&1)"
+ grep -Fx "TeamIdentifier=$APPLE_TEAM_ID" <<< "$details"
+ grep -q '^Authority=Developer ID Application: ' <<< "$details"
+ grep -q '^CodeDirectory .*flags=.*runtime' <<< "$details"
+ grep -Eq '^Timestamp=.+$' <<< "$details"
+ ! grep -Fxq 'Timestamp=none' <<< "$details"
+}
+
+verify_release() {
+ local host="$1/libexec/XcodeMCPNativeHost.app"
+ verify_signature "$1/libexec/xcode-mcp-server"
+ verify_signature "$host"
+ codesign -d --verbose=4 "$host" 2>&1 | grep -Fx "Identifier=$host_identifier"
+ xcrun stapler validate "$host"
+ spctl --assess --type execute "$host"
+}
+
+: "${APPLE_TEAM_ID:?Set APPLE_TEAM_ID}"
+if [[ $# == 2 && "$1" == verify ]]; then
+ verify_release "$2"
+ exit
+fi
+if [[ $# != 3 || "$1" != sign ]]; then
+ echo 'Usage: sign-release.sh sign PREFIX OUTPUT_ZIP | sign-release.sh verify PREFIX' >&2
+ exit 2
+fi
+
+prefix="$2"
+output="$3"
+payload="$prefix/libexec"
+host="$payload/XcodeMCPNativeHost.app"
+test -f "$payload/xcode-mcp-server"
+test -d "$host"
+: "${DEVELOPER_ID_P12_BASE64:?Set DEVELOPER_ID_P12_BASE64}"
+: "${DEVELOPER_ID_P12_PASSWORD:?Set DEVELOPER_ID_P12_PASSWORD}"
+: "${NOTARY_API_PRIVATE_KEY:?Set NOTARY_API_PRIVATE_KEY}"
+: "${NOTARY_API_KEY_ID:?Set NOTARY_API_KEY_ID}"
+: "${NOTARY_API_ISSUER_ID:?Set NOTARY_API_ISSUER_ID}"
+
+umask 077
+credentials="$(mktemp -d)"
+keychain="$credentials/signing.keychain-db"
+previous_keychains=()
+while IFS= read -r line; do
+ [[ "$line" =~ \"(.*)\" ]] && previous_keychains+=("${BASH_REMATCH[1]}")
+done < <(security list-keychains -d user)
+cleanup() {
+ security list-keychains -d user -s "${previous_keychains[@]}" || true
+ security delete-keychain "$keychain" || true
+ rm -rf "$credentials"
+}
+trap cleanup EXIT
+
+printf '%s' "$DEVELOPER_ID_P12_BASE64" | base64 -D > "$credentials/identity.p12"
+printf '%s\n' "$NOTARY_API_PRIVATE_KEY" > "$credentials/notary.p8"
+unset DEVELOPER_ID_P12_BASE64 NOTARY_API_PRIVATE_KEY
+password="$(openssl rand -hex 32)"
+security create-keychain -p "$password" "$keychain"
+security set-keychain-settings -lut 7200 "$keychain"
+security unlock-keychain -p "$password" "$keychain"
+security import "$credentials/identity.p12" -k "$keychain" -f pkcs12 -x -P "$DEVELOPER_ID_P12_PASSWORD" -T /usr/bin/codesign
+unset DEVELOPER_ID_P12_PASSWORD
+rm "$credentials/identity.p12"
+security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$password" "$keychain" >/dev/null
+security list-keychains -d user -s "$keychain" "${previous_keychains[@]}"
+identity="$(security find-identity -v -p codesigning "$keychain" |
+ awk -v team="($APPLE_TEAM_ID)" 'index($0, "Developer ID Application: ") && index($0, team) {print $2; count++} END {if (count != 1) exit 1}')"
+
+sign=(codesign --force --sign "$identity" --keychain "$keychain" --timestamp --options runtime)
+while IFS= read -r -d '' file; do
+ "${sign[@]}" "$file"
+ verify_signature "$file"
+done < <(find "$payload" -type f \( -name '*.dylib' -o -name XcodeMCPPreviewRenderer -o -name xcode-mcp-server \) -print0)
+"${sign[@]}" --identifier "$host_identifier" --preserve-metadata=entitlements "$host"
+
+report="$credentials/notary.json"
+ditto -c -k --keepParent "$prefix" "$credentials/payload.zip"
+auth=(--key "$credentials/notary.p8" --key-id "$NOTARY_API_KEY_ID" --issuer "$NOTARY_API_ISSUER_ID")
+xcrun notarytool submit "$credentials/payload.zip" "${auth[@]}" --wait --timeout 30m --output-format json > "$report"
+status="$(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["status"])' "$report")"
+if [[ "$status" != Accepted ]]; then
+ submission="$(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["id"])' "$report")"
+ xcrun notarytool log "$submission" "${auth[@]}"
+ exit 1
+fi
+xcrun stapler staple "$host"
+verify_release "$prefix"
+ditto -c -k --keepParent "$prefix" "$output"
From 9b1ccb763268bf6f43a924c24fe90b89ff84c218 Mon Sep 17 00:00:00 2001
From: Yazawa Hiroki <47569369+zunda-pixel@users.noreply.github.com>
Date: Tue, 24 Nov 2026 20:10:44 +0900
Subject: [PATCH 2/2] Resume tagged release publication on job retries
---
.github/workflows/release.yml | 12 ++--
Homebrew/README.md | 4 +-
scripts/release.py | 77 +++++++++++++++++++++++-
scripts/tests/test_tagged_publication.py | 72 ++++++++++++++++++++++
4 files changed, 156 insertions(+), 9 deletions(-)
create mode 100644 scripts/tests/test_tagged_publication.py
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 74d67013..30b0b092 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -151,6 +151,9 @@ jobs:
permissions:
contents: write
steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
artifact-ids: ${{ needs.package.outputs.artifact_id }}
@@ -162,17 +165,12 @@ jobs:
- name: Publish verified assets
env:
GH_TOKEN: ${{ github.token }}
- GH_REPO: ${{ github.repository }}
- PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
TAG_COMMIT: ${{ needs.prepare.outputs.commit }}
run: |
- tag_commit="$(gh api "repos/$GH_REPO/commits/$VERSION" --jq .sha)"
- test "$tag_commit" = "$TAG_COMMIT"
sha256sum --check macOS-arm64-SHA256SUMS.txt
(cd release && sha256sum --check SHA256SUMS.txt)
- flags=()
- if [[ "$PRERELEASE" == true ]]; then flags+=(--prerelease); fi
- gh release create --generate-notes --verify-tag "${flags[@]}" -- "$VERSION" \
+ python3 scripts/release.py publish-tagged --repo "$GITHUB_REPOSITORY" \
+ --version "$VERSION" --target "$TAG_COMMIT" --run-id "$GITHUB_RUN_ID" \
"$BINARY_ASSET" macOS-arm64-SHA256SUMS.txt release/*
homebrew:
diff --git a/Homebrew/README.md b/Homebrew/README.md
index 2ec53e43..a30dbec5 100644
--- a/Homebrew/README.md
+++ b/Homebrew/README.md
@@ -88,7 +88,9 @@ The tap retains its own `release-signing` environment and bottle verification.
## Retry and legacy drafts
Rerun failed jobs in the tagged Release workflow after resolving the failure.
-Inspect an existing GitHub Release for the tag before rerunning publication.
+Publication resumes the draft created by the same Actions run and checks the
+SHA-256 digests of uploaded assets. If publication already finished, the
+rerun checks the published assets and succeeds.
If only Homebrew dispatch failed, rerun that job or inspect the tap Actions
run if the dispatch may have reached it.
diff --git a/scripts/release.py b/scripts/release.py
index d30600fc..1bd05dd1 100644
--- a/scripts/release.py
+++ b/scripts/release.py
@@ -144,6 +144,73 @@ def matching_releases(github, tag):
page += 1
+def publish_tagged(github, tag, sha, run_id, paths):
+ prerelease = is_prerelease(tag)
+ check_sha(sha)
+ if not re.fullmatch(r"[0-9]+", run_id):
+ raise ReleaseError("Use the GitHub Actions run ID.")
+
+ marker = f""
+ files = {path.name: path for path in paths}
+ if not files or len(files) != len(paths):
+ raise ReleaseError("Release assets must have distinct names.")
+ digests = {}
+ for name, path in files.items():
+ with path.open("rb") as source:
+ digests[name] = "sha256:" + hashlib.file_digest(source, "sha256").hexdigest()
+
+ def require_tag():
+ if check_tag(github, tag, sha) is None:
+ raise ReleaseError(f"Missing release tag {tag}.")
+
+ def check_release(release):
+ if (release["tag_name"] != tag or release["prerelease"] != prerelease
+ or marker not in (release.get("body") or "").splitlines()):
+ raise ReleaseError(f"Release {tag} belongs to a different publication.")
+
+ def missing_assets(release):
+ remaining = dict(files)
+ seen = set()
+ for asset in release["assets"]:
+ name = asset["name"]
+ if name not in files or name in seen:
+ raise ReleaseError(f"Unexpected asset on release {tag}: {name}")
+ seen.add(name)
+ if release["draft"] and asset["state"] == "starter":
+ continue
+ if asset["state"] != "uploaded" or asset.get("digest") != digests[name]:
+ raise ReleaseError(f"Release asset does not match the verified file: {name}")
+ del remaining[name]
+ return list(remaining.values())
+
+ require_tag()
+ matches = matching_releases(github, tag)
+ if len(matches) > 1:
+ raise ReleaseError(f"Multiple releases use {tag}.")
+ release = matches[0] if matches else github.api(
+ "releases", "POST", dict(tag_name=tag, target_commitish=sha,
+ body=marker, draft=True, prerelease=prerelease,
+ generate_release_notes=True))
+ check_release(release)
+ pending = missing_assets(release)
+ if release["draft"]:
+ if pending:
+ github.upload(tag, pending)
+ release_path = f"releases/{release['id']}"
+ release = github.api(release_path)
+ check_release(release)
+ pending = missing_assets(release)
+ if pending:
+ raise ReleaseError(f"Release {tag} is missing verified assets.")
+ require_tag()
+ if release["draft"]:
+ release = github.api(release_path, "PATCH", dict(draft=False))
+ check_release(release)
+ if release["draft"] or missing_assets(release):
+ raise ReleaseError(f"Release {tag} is not fully published.")
+ print(f"Published: {release['html_url']}")
+
+
def dispatch_tap(github, source_repository, tag, sha, release_dir):
if is_prerelease(tag):
print("Prereleases do not start stable tap updates.")
@@ -384,6 +451,12 @@ def main():
launch.add_argument("--notes-file", required=True, type=Path)
launch.add_argument("--title", help="Defaults to the version")
launch.add_argument("--repo", required=True)
+ tagged = commands.add_parser("publish-tagged", help="Publish or resume a tagged release")
+ tagged.add_argument("--repo", required=True)
+ tagged.add_argument("--version", required=True)
+ tagged.add_argument("--target", required=True)
+ tagged.add_argument("--run-id", required=True)
+ tagged.add_argument("assets", nargs="+", type=Path)
notify = commands.add_parser("dispatch-tap", help="Start the tap update after approved stable tag creation")
notify.add_argument("--source-repository", required=True)
notify.add_argument("--version", required=True)
@@ -436,7 +509,9 @@ def main():
print(json.dumps(evidence) if required else "Prereleases do not require stable tap publication.")
return 0
github = GitHub(arguments.repo)
- if arguments.command == "start":
+ if arguments.command == "publish-tagged":
+ publish_tagged(github, arguments.version, arguments.target, arguments.run_id, arguments.assets)
+ elif arguments.command == "start":
start(github, arguments.version, arguments.target,
arguments.title or arguments.version,
arguments.notes_file.read_text(encoding="utf-8"))
diff --git a/scripts/tests/test_tagged_publication.py b/scripts/tests/test_tagged_publication.py
new file mode 100644
index 00000000..cdd5334b
--- /dev/null
+++ b/scripts/tests/test_tagged_publication.py
@@ -0,0 +1,72 @@
+"""Check retry behavior at each GitHub release publication boundary."""
+import hashlib
+from pathlib import Path
+import sys
+import tempfile
+import unittest
+from unittest.mock import Mock, patch
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+import release
+
+
+class TaggedPublicationTests(unittest.TestCase):
+ def setUp(self):
+ directory = self.enterContext(tempfile.TemporaryDirectory())
+ self.paths = [Path(directory) / name for name in ("package.zip", "SHA256SUMS.txt")]
+ for path in self.paths:
+ path.write_text(path.name)
+ self.tag = "v1.2.3"
+ self.sha = "a" * 40
+ self.release = dict(id=42, tag_name=self.tag, target_commitish=self.sha,
+ prerelease=False, draft=True, assets=[], html_url="release-url",
+ body=f"\n\nGenerated notes")
+ self.github = Mock()
+ self.matches = self.enterContext(patch.object(release, "matching_releases", return_value=[self.release]))
+ self.enterContext(patch.object(release, "check_tag", return_value=self.sha))
+
+ def asset(self, path, state="uploaded"):
+ return dict(name=path.name, state=state,
+ digest="sha256:" + hashlib.sha256(path.read_bytes()).hexdigest())
+
+ def publish(self):
+ release.publish_tagged(self.github, self.tag, self.sha, "123", self.paths)
+
+ def test_creates_draft_then_publishes_verified_assets(self):
+ self.matches.return_value = []
+ uploaded = dict(self.release, assets=[self.asset(path) for path in self.paths])
+ self.github.api.side_effect = [self.release, uploaded, dict(uploaded, draft=False)]
+ self.publish()
+ self.assertEqual(self.github.api.call_args_list[0].args[0:2], ("releases", "POST"))
+ self.assertTrue(self.github.api.call_args_list[0].args[2]["draft"])
+ self.github.upload.assert_called_once_with(self.tag, self.paths)
+ self.github.api.assert_called_with("releases/42", "PATCH", {"draft": False})
+
+ def test_retries_incomplete_upload_on_existing_draft(self):
+ uploaded = [self.asset(path) for path in self.paths]
+ self.release["assets"] = [uploaded[0], self.asset(self.paths[1], "starter")]
+ complete = dict(self.release, assets=uploaded)
+ self.github.api.side_effect = [complete, dict(complete, draft=False)]
+ self.publish()
+ self.github.upload.assert_called_once_with(self.tag, self.paths[1:])
+ self.github.api.assert_called_with("releases/42", "PATCH", {"draft": False})
+
+ def test_already_published_release_is_verified_without_writes(self):
+ self.release.update(draft=False, assets=[self.asset(path) for path in self.paths])
+ self.publish()
+ self.github.upload.assert_not_called()
+ self.github.api.assert_not_called()
+
+ def test_rejects_unrelated_draft(self):
+ self.release["body"] = "Release notes from a different run."
+ with self.assertRaisesRegex(release.ReleaseError, "different publication"):
+ self.publish()
+ self.github.upload.assert_not_called()
+ self.github.api.assert_not_called()
+
+ def test_rejects_asset_with_wrong_digest(self):
+ self.release["assets"] = [dict(self.asset(self.paths[0]), digest="sha256:wrong")]
+ with self.assertRaisesRegex(release.ReleaseError, "does not match"):
+ self.publish()
+ self.github.upload.assert_not_called()
+ self.github.api.assert_not_called()