Skip to content

Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.

ci: switch notarization to App Store Connect API key

moamen3aeaab740346
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f605635..5269ba3 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -155,18 +155,28 @@ jobs:
codesign --sign "Developer ID Application: Moamen Basel (H3WXHVTP97)" --timestamp "${DMG}"
codesign --verify --verbose=2 "${DMG}"
+ - name: Write App Store Connect API key
+ env:
+ APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }}
+ run: |
+ set -euo pipefail
+ KEY_PATH="${RUNNER_TEMP}/asc_api_key.p8"
+ printf '%s' "${APP_STORE_CONNECT_PRIVATE_KEY}" > "${KEY_PATH}"
+ chmod 600 "${KEY_PATH}"
+ echo "ASC_KEY_PATH=${KEY_PATH}" >> "$GITHUB_ENV"
+
- name: Notarize DMG
env:
- APPLE_ID: ${{ secrets.APPLE_ID }}
- APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
+ ASC_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
+ ASC_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
VERSION: ${{ steps.ver.outputs.version }}
run: |
set -euo pipefail
DMG="build/PureMac-${VERSION}.dmg"
xcrun notarytool submit "${DMG}" \
- --apple-id "${APPLE_ID}" \
- --password "${APPLE_APP_PASSWORD}" \
- --team-id "${TEAM_ID}" \
+ --key "${ASC_KEY_PATH}" \
+ --key-id "${ASC_KEY_ID}" \
+ --issuer "${ASC_ISSUER_ID}" \
--wait \
--timeout 30m
xcrun stapler staple "${DMG}"
@@ -175,6 +185,8 @@ jobs:
- name: Build notarized zip
env:
+ ASC_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
+ ASC_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
VERSION: ${{ steps.ver.outputs.version }}
run: |
set -euo pipefail
@@ -182,9 +194,9 @@ jobs:
# Notarize the .app inside a zip too (homebrew cask uses zip)
ditto -c -k --keepParent --sequesterRsrc build/export/PureMac.app build/PureMac-app.zip
xcrun notarytool submit build/PureMac-app.zip \
- --apple-id "${{ secrets.APPLE_ID }}" \
- --password "${{ secrets.APPLE_APP_PASSWORD }}" \
- --team-id "${TEAM_ID}" \
+ --key "${ASC_KEY_PATH}" \
+ --key-id "${ASC_KEY_ID}" \
+ --issuer "${ASC_ISSUER_ID}" \
--wait --timeout 30m
xcrun stapler staple build/export/PureMac.app
# Final shippable zip with stapled ticket
@@ -306,6 +318,8 @@ jobs:
git push origin HEAD
fi
- - name: Cleanup keychain
+ - name: Cleanup keychain + ASC key
if: always()
- run: security delete-keychain "${RUNNER_TEMP}/app-signing.keychain-db" || true
+ run: |
+ security delete-keychain "${RUNNER_TEMP}/app-signing.keychain-db" || true
+ rm -f "${RUNNER_TEMP}/asc_api_key.p8" || true
diff --git a/scripts/SECRETS.md b/scripts/SECRETS.md
index 38e8915..726fcbe 100644
--- a/scripts/SECRETS.md
+++ b/scripts/SECRETS.md
@@ -1,89 +1,133 @@
# Release pipeline secrets
`.github/workflows/release.yml` requires the following GitHub Actions secrets
-on `momenbasel/PureMac`. All seven must be set before the next tag push or the
+on `momenbasel/PureMac`. All must be set before the next tag push or the
notarize/staple steps will fail and ship a broken signature (the cause of #86).
-## Required secrets
+The pipeline uses an **App Store Connect API key** for notarization (modern,
+no rotation, scoped to one team) instead of the legacy
+`APPLE_ID + app-specific-password` flow.
+
+## Required secrets (6)
| Secret | Source | Notes |
|--------|--------|-------|
-| `BUILD_CERTIFICATE_BASE64` | Developer ID Application `.p12` exported from Keychain Access, `base64 -i cert.p12 \| pbcopy` | Includes both cert and private key |
-| `P12_PASSWORD` | Password set when exporting the `.p12` | Choose a strong random one |
+| `BUILD_CERTIFICATE_BASE64` | Filtered Developer ID Application `.p12` (cert + matching private key only), base64 | `base64 -i cert.p12 \| pbcopy` |
+| `P12_PASSWORD` | Password set when exporting the `.p12` | Random — only you and CI need it |
| `KEYCHAIN_PASSWORD` | Random string | Only used to lock the runner's temp keychain — never leaves CI |
-| `APPLE_ID` | The Apple ID email used for App Store Connect | e.g. `[email protected]` |
-| `APPLE_APP_PASSWORD` | App-specific password from <https://appleid.apple.com/account/manage> → Sign-In and Security → App-Specific Passwords | NOT your AppleID password |
-| `APPLE_TEAM_ID` | `H3WXHVTP97` (already set in workflow as env, no secret needed unless you want to override) | — |
-| `HOMEBREW_TAP_TOKEN` | Fine-grained PAT with `Contents: read+write` on `momenbasel/homebrew-tap` | Needed for the cross-repo formula bump step |
-
-## Extracting your Developer ID cert as `.p12`
+| `APP_STORE_CONNECT_KEY_ID` | The 10-char ID from the `.p8` filename (`AuthKey_XXXXXXXXXX.p8`) | e.g. `5G7R52L8RK` |
+| `APP_STORE_CONNECT_ISSUER_ID` | UUID from <https://appstoreconnect.apple.com/access/integrations/api> | e.g. `5de3898a-cd31-4061-850f-ae17b389e46a` |
+| `APP_STORE_CONNECT_PRIVATE_KEY` | Full contents of the `.p8` file (`-----BEGIN PRIVATE KEY-----` ... `-----END PRIVATE KEY-----`) | Paste raw, including the BEGIN/END lines |
-```bash
-# 1. Open Keychain Access → login keychain → "My Certificates"
-# 2. Right-click "Developer ID Application: Moamen Basel (H3WXHVTP97)" → Export
-# 3. Save as PureMac-DeveloperID.p12, set P12_PASSWORD when prompted
+## Optional secret (1)
-# 4. Convert to base64 for the GH secret:
-base64 -i ~/Downloads/PureMac-DeveloperID.p12 | pbcopy
-# now paste into BUILD_CERTIFICATE_BASE64
-```
+| Secret | Source | Notes |
+|--------|--------|-------|
+| `HOMEBREW_TAP_TOKEN` | Fine-grained PAT with `Contents: read+write` on `momenbasel/homebrew-tap` | Without this the tap formula bump step is skipped (in-repo `homebrew/puremac.rb` still bumps via the default `GITHUB_TOKEN`) |
-CLI alternative (no GUI):
+## Extracting your Developer ID cert as a filtered `.p12`
```bash
-security find-certificate -c "Developer ID Application: Moamen Basel" -p login.keychain
-# To export the matching private key as p12 you still need the GUI - macOS
-# does not let `security export` dump private keys non-interactively.
+mkdir -p ~/Desktop/PureMac-secrets && cd ~/Desktop/PureMac-secrets
+
+# 1. Export everything from login keychain
+P12_PWD=$(openssl rand -base64 24)
+echo "$P12_PWD" > P12_PASSWORD.txt
+security export -k login.keychain-db -t identities -f pkcs12 -P "$P12_PWD" -o all.p12
+
+# 2. Dump to PEM, isolate the Developer ID cert + matching private key
+openssl pkcs12 -in all.p12 -passin "pass:$P12_PWD" -nodes -out all.pem
+security find-certificate -c "Developer ID Application: Moamen Basel" -p login.keychain-db > devid.crt
+
+# 3. Use python to split private keys, then match by modulus
+python3 - <<'PY'
+import re
+content = open("all.pem").read()
+for i, k in enumerate(re.findall(r"-----BEGIN PRIVATE KEY-----.*?-----END PRIVATE KEY-----", content, re.DOTALL), 1):
+ open(f"key_{i}.pem", "w").write(k + "\n")
+PY
+
+CERT_MOD=$(openssl x509 -in devid.crt -modulus -noout | shasum -a 256 | awk '{print $1}')
+for k in key_*.pem; do
+ if [[ "$(openssl rsa -in "$k" -modulus -noout 2>/dev/null | shasum -a 256 | awk '{print $1}')" == "$CERT_MOD" ]]; then
+ cp "$k" devid.key && break
+ fi
+done
+
+# 4. Re-pack as a clean p12 with ONLY Developer ID + key
+openssl pkcs12 -export \
+ -in devid.crt -inkey devid.key \
+ -name "Developer ID Application: Moamen Basel (H3WXHVTP97)" \
+ -out PureMac-DeveloperID.p12 \
+ -passout "pass:$P12_PWD" \
+ -macalg sha256 -keypbe AES-256-CBC -certpbe AES-256-CBC
+
+# 5. Base64 for the GH secret + scrub intermediates
+base64 -i PureMac-DeveloperID.p12 -o PureMac-DeveloperID.p12.b64
+rm -P all.p12 all.pem devid.key key_*.pem
```
-## Generating the app-specific password
-
-1. Sign in at <https://appleid.apple.com>
-2. Sign-In and Security → App-Specific Passwords → +
-3. Label it `PureMac CI Notarytool`
-4. Copy the `xxxx-xxxx-xxxx-xxxx` string — set as `APPLE_APP_PASSWORD`
+## Storing the ASC API key locally for `notarytool`
-Verify locally first to avoid burning a CI minute on auth failure:
+Already set up — confirmed via `xcrun notarytool history --keychain-profile AC_NOTARY`.
+For reference:
```bash
-xcrun notarytool store-credentials puremac-ci \
- --apple-id "$APPLE_ID" \
- --team-id "H3WXHVTP97" \
- --password "$APPLE_APP_PASSWORD"
+xcrun notarytool store-credentials AC_NOTARY \
+ --key ~/.appstoreconnect/private_keys/AuthKey_5G7R52L8RK.p8 \
+ --key-id 5G7R52L8RK \
+ --issuer 5de3898a-cd31-4061-850f-ae17b389e46a
```
+That keychain profile is consumed by `scripts/release-local.sh` for emergency
+hotfixes. The CI workflow uses raw secrets instead (no keychain dependency on
+the runner).
+
## Setting them all via gh CLI
```bash
-gh secret set BUILD_CERTIFICATE_BASE64 --repo momenbasel/PureMac < /tmp/cert.b64
-gh secret set P12_PASSWORD --repo momenbasel/PureMac --body "$P12_PASSWORD"
-gh secret set KEYCHAIN_PASSWORD --repo momenbasel/PureMac --body "$(openssl rand -base64 32)"
-gh secret set APPLE_ID --repo momenbasel/PureMac --body "$APPLE_ID"
-gh secret set APPLE_APP_PASSWORD --repo momenbasel/PureMac --body "$APPLE_APP_PASSWORD"
-gh secret set HOMEBREW_TAP_TOKEN --repo momenbasel/PureMac --body "$HOMEBREW_TAP_TOKEN"
+# Fill in the 4 you control:
+P12_PWD=$(cat ~/Desktop/PureMac-secrets/P12_PASSWORD.txt)
+KC_PWD=$(cat ~/Desktop/PureMac-secrets/KEYCHAIN_PASSWORD.txt)
+
+gh secret set BUILD_CERTIFICATE_BASE64 --repo momenbasel/PureMac < ~/Desktop/PureMac-secrets/PureMac-DeveloperID.p12.b64
+gh secret set P12_PASSWORD --repo momenbasel/PureMac --body "$P12_PWD"
+gh secret set KEYCHAIN_PASSWORD --repo momenbasel/PureMac --body "$KC_PWD"
+gh secret set APP_STORE_CONNECT_KEY_ID --repo momenbasel/PureMac --body "5G7R52L8RK"
+gh secret set APP_STORE_CONNECT_ISSUER_ID --repo momenbasel/PureMac --body "5de3898a-cd31-4061-850f-ae17b389e46a"
+gh secret set APP_STORE_CONNECT_PRIVATE_KEY --repo momenbasel/PureMac < ~/.appstoreconnect/private_keys/AuthKey_5G7R52L8RK.p8
+
+# Optional:
+gh secret set HOMEBREW_TAP_TOKEN --repo momenbasel/PureMac --body "<your fine-grained PAT>"
# Verify:
gh secret list --repo momenbasel/PureMac
```
+After upload:
+
+```bash
+rm -P ~/Desktop/PureMac-secrets/PureMac-DeveloperID.p12* \
+ ~/Desktop/PureMac-secrets/P12_PASSWORD.txt \
+ ~/Desktop/PureMac-secrets/KEYCHAIN_PASSWORD.txt
+```
+
## Triggering a release
-After tag bump:
+Dry run first (build + sign + notarize, no upload, no homebrew bump):
```bash
-git tag v2.2.0
-git push origin v2.2.0
+gh workflow run release.yml --repo momenbasel/PureMac -f version=2.2.0 -f dry_run=true
+gh run watch --repo momenbasel/PureMac
```
-Or via dispatch (no tag):
+Real release (after dry run is green):
```bash
-gh workflow run release.yml --repo momenbasel/PureMac -f version=2.2.0 -f dry_run=false
+git tag v2.2.0
+git push origin v2.2.0
```
-Use `dry_run=true` first to validate signing+notarize without uploading the
-release or bumping homebrew.
-
## What ships
| Artifact | Purpose |
diff --git a/scripts/release-local.sh b/scripts/release-local.sh
index be38db5..8be8eb4 100755
--- a/scripts/release-local.sh
+++ b/scripts/release-local.sh
@@ -3,15 +3,20 @@
# Local mirror of .github/workflows/release.yml. Use for emergency hotfixes
# when CI is unavailable. Requires:
# - Developer ID Application identity in your login keychain
-# - APPLE_ID, APPLE_APP_PASSWORD env vars (or notarytool keychain profile)
+# - notarytool keychain profile already stored, e.g.:
+# xcrun notarytool store-credentials AC_NOTARY \
+# --key ~/.appstoreconnect/private_keys/AuthKey_5G7R52L8RK.p8 \
+# --key-id 5G7R52L8RK --issuer 5de3898a-cd31-4061-850f-ae17b389e46a
# - xcodegen + create-dmg installed (brew install xcodegen create-dmg)
#
-# Usage: scripts/release-local.sh <version>
+# Usage: scripts/release-local.sh <version> [notary_profile]
# scripts/release-local.sh 2.2.0
+# scripts/release-local.sh 2.2.0 AC_NOTARY
#
set -euo pipefail
-VERSION="${1:?Usage: $0 <version>}"
+VERSION="${1:?Usage: $0 <version> [notary_profile]}"
+NOTARY_PROFILE="${2:-AC_NOTARY}"
TEAM_ID="H3WXHVTP97"
SIGN_ID="Developer ID Application: Moamen Basel (${TEAM_ID})"
SCHEME="PureMac"
@@ -87,20 +92,16 @@ create-dmg \
build/export/PureMac.app
codesign --sign "${SIGN_ID}" --timestamp "${DMG}"
-echo "==> notarize app zip"
+echo "==> notarize app zip (profile: ${NOTARY_PROFILE})"
ditto -c -k --keepParent --sequesterRsrc "${APP}" build/PureMac-app.zip
xcrun notarytool submit build/PureMac-app.zip \
- --apple-id "${APPLE_ID:?set APPLE_ID env var}" \
- --password "${APPLE_APP_PASSWORD:?set APPLE_APP_PASSWORD env var}" \
- --team-id "${TEAM_ID}" \
+ --keychain-profile "${NOTARY_PROFILE}" \
--wait --timeout 30m
xcrun stapler staple "${APP}"
echo "==> notarize dmg"
xcrun notarytool submit "${DMG}" \
- --apple-id "${APPLE_ID}" \
- --password "${APPLE_APP_PASSWORD}" \
- --team-id "${TEAM_ID}" \
+ --keychain-profile "${NOTARY_PROFILE}" \
--wait --timeout 30m
xcrun stapler staple "${DMG}"
xcrun stapler validate "${DMG}"