-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add unsigned macOS release pipeline #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+139
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: macos-14 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - uses: actions/setup-python@v7 | ||
| with: | ||
| python-version: "3.14" | ||
|
|
||
| - name: Verify tag and version | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| version="$(cat VERSION)" | ||
| test "$GITHUB_REF_NAME" = "v$version" | ||
| PYTHONPATH=src python -c 'import agent_switch; print(agent_switch.__version__)' | ||
|
|
||
| - name: Run release tests | ||
| run: | | ||
| PYTHONPATH=src python -m unittest discover -s tests -v | ||
| PYTHONPATH=src python -m unittest discover -s tests/integration -v | ||
|
|
||
| - name: Build release artifacts | ||
| run: | | ||
| python -m pip install --upgrade build | ||
| python -m build --sdist --outdir dist | ||
| ./scripts/build-release.sh dist | ||
| cd dist | ||
| shasum -a 256 "agent_switch-$(cat ../VERSION).tar.gz" \ | ||
| > "agent_switch-$(cat ../VERSION).tar.gz.sha256" | ||
|
|
||
| - name: Create GitHub prerelease | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| version="$(cat VERSION)" | ||
| cat > "$RUNNER_TEMP/release-notes.md" <<EOF | ||
| Agent Switch $version is an alpha release for macOS 14 and newer. | ||
|
|
||
| ## Install | ||
|
|
||
| \`\`\`bash | ||
| brew tap JNHFlow21/tap && brew trust --tap JNHFlow21/tap && HOMEBREW_CASK_OPTS=--no-quarantine brew install --cask JNHFlow21/tap/agent-switch | ||
| \`\`\` | ||
|
|
||
| This build is ad-hoc signed and not notarized because the project does | ||
| not yet have an Apple Developer ID. The install command deliberately | ||
| disables Gatekeeper quarantine for this cask installation. Review the | ||
| public source and checksums before installing. | ||
| EOF | ||
| gh release create "$GITHUB_REF_NAME" \ | ||
| dist/Agent-Switch-"$version"-macos-universal.zip \ | ||
| dist/Agent-Switch-"$version"-macos-universal.zip.sha256 \ | ||
| dist/agent_switch-"$version".tar.gz \ | ||
| dist/agent_switch-"$version".tar.gz.sha256 \ | ||
| --title "Agent Switch $version" \ | ||
| --notes-file "$RUNNER_TEMP/release-notes.md" \ | ||
| --prerelease | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/bin/zsh | ||
| set -euo pipefail | ||
|
|
||
| ROOT="${0:A:h:h}" | ||
| VERSION="$(<"$ROOT/VERSION")" | ||
| PROJECT="$ROOT/macos-app/AgentSwitch/AgentSwitch.xcodeproj" | ||
| SCHEME="AgentSwitch" | ||
| OUTPUT_DIR="${1:-$ROOT/dist}" | ||
| DERIVED_DATA="$(mktemp -d "${TMPDIR:-/tmp}/agent-switch-release.XXXXXX")" | ||
| APP="$DERIVED_DATA/Build/Products/Release/Agent Switch.app" | ||
| ARCHIVE="$OUTPUT_DIR/Agent-Switch-$VERSION-macos-universal.zip" | ||
|
|
||
| cleanup() { | ||
| rm -rf "$DERIVED_DATA" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| fail() { | ||
| print -u2 "Agent Switch release build failed: $*" | ||
| exit 1 | ||
| } | ||
|
|
||
| [[ "$(uname -s)" == "Darwin" ]] || fail "macOS is required." | ||
| for command in xcodebuild codesign ditto lipo shasum; do | ||
| command -v "$command" >/dev/null 2>&1 || fail "$command is required." | ||
| done | ||
|
|
||
| mkdir -p "$OUTPUT_DIR" | ||
| rm -f "$ARCHIVE" "$ARCHIVE.sha256" | ||
|
|
||
| xcodebuild \ | ||
| -project "$PROJECT" \ | ||
| -scheme "$SCHEME" \ | ||
| -configuration Release \ | ||
| -destination "generic/platform=macOS" \ | ||
| -derivedDataPath "$DERIVED_DATA" \ | ||
| -quiet \ | ||
| ARCHS="arm64 x86_64" \ | ||
| ONLY_ACTIVE_ARCH=NO \ | ||
| CODE_SIGNING_ALLOWED=NO \ | ||
| build | ||
|
|
||
| [[ -d "$APP" ]] || fail "Xcode did not produce $APP" | ||
|
|
||
| APP_VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")" | ||
| [[ "$APP_VERSION" == "$VERSION" ]] || fail "App version $APP_VERSION does not match VERSION $VERSION." | ||
|
|
||
| ARCHS="$(lipo -archs "$APP/Contents/MacOS/Agent Switch")" | ||
| [[ " $ARCHS " == *" arm64 "* ]] || fail "Release is missing arm64." | ||
| [[ " $ARCHS " == *" x86_64 "* ]] || fail "Release is missing x86_64." | ||
|
|
||
| # The public alpha is intentionally ad-hoc signed until a Developer ID is | ||
| # available. Homebrew installation documents the resulting Gatekeeper tradeoff. | ||
| xattr -cr "$APP" | ||
| codesign --force --sign - --options runtime --timestamp=none "$APP" | ||
| codesign --verify --deep --strict --verbose=2 "$APP" | ||
|
|
||
| ditto -c -k --sequesterRsrc --keepParent "$APP" "$ARCHIVE" | ||
| (cd "$OUTPUT_DIR" && shasum -a 256 "${ARCHIVE:t}" > "${ARCHIVE:t}.sha256") | ||
|
|
||
| print "Built $ARCHIVE" | ||
| print "Architectures: $ARCHS" | ||
| print "Signing: ad-hoc (not notarized)" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brew truststepWhen a tag creates this prerelease, the only advertised install command stops at
brew trust --tap JNHFlow21/tap, so the subsequent cask installation never runs. Homebrew documentstapasbrew tap [options] [user/repo]and does not provide atrustsubcommand; remove this step (or replace it with a supported quarantine-handling instruction) so the release notes are executable. Homebrew manpageUseful? React with 👍 / 👎.