|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Release macOS version" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + runs-on: macos-latest |
| 18 | + environment: release |
| 19 | + env: |
| 20 | + CODESIGN_IDENTITY: ${{ vars.CODESIGN_IDENTITY }} |
| 21 | + NOTARY_PROFILE_NAME: ${{ vars.NOTARY_PROFILE_NAME }} |
| 22 | + APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }} |
| 23 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Setup Node |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: 20 |
| 34 | + cache: npm |
| 35 | + |
| 36 | + - name: Setup Rust |
| 37 | + uses: dtolnay/rust-toolchain@stable |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: npm ci |
| 41 | + |
| 42 | + - name: Import signing certificate |
| 43 | + env: |
| 44 | + APPLE_CERTIFICATE_P12: ${{ secrets.APPLE_CERTIFICATE_P12 }} |
| 45 | + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} |
| 46 | + run: | |
| 47 | + set -euo pipefail |
| 48 | + KEYCHAIN=build.keychain |
| 49 | + CERT_PATH=cert.p12 |
| 50 | +
|
| 51 | + echo "$APPLE_CERTIFICATE_P12" | base64 --decode > "$CERT_PATH" 2>/dev/null || \ |
| 52 | + echo "$APPLE_CERTIFICATE_P12" | base64 -D > "$CERT_PATH" |
| 53 | +
|
| 54 | + security create-keychain -p "" "$KEYCHAIN" |
| 55 | + security set-keychain-settings -lut 21600 "$KEYCHAIN" |
| 56 | + security unlock-keychain -p "" "$KEYCHAIN" |
| 57 | + security import "$CERT_PATH" -k "$KEYCHAIN" -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign |
| 58 | + security list-keychains -d user -s "$KEYCHAIN" |
| 59 | + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "" "$KEYCHAIN" |
| 60 | +
|
| 61 | + - name: Configure notarytool credentials |
| 62 | + env: |
| 63 | + APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} |
| 64 | + APPLE_API_ISSUER_ID: ${{ secrets.APPLE_API_ISSUER_ID }} |
| 65 | + APPLE_API_PRIVATE_KEY_B64: ${{ secrets.APPLE_API_PRIVATE_KEY_B64 }} |
| 66 | + run: | |
| 67 | + set -euo pipefail |
| 68 | + mkdir -p private_keys |
| 69 | + echo "$APPLE_API_PRIVATE_KEY_B64" | base64 --decode > private_keys/AuthKey.p8 |
| 70 | + xcrun notarytool store-credentials "$NOTARY_PROFILE_NAME" \ |
| 71 | + --key-id "$APPLE_API_KEY_ID" \ |
| 72 | + --issuer "$APPLE_API_ISSUER_ID" \ |
| 73 | + --key "private_keys/AuthKey.p8" |
| 74 | +
|
| 75 | + - name: Write Tauri signing key |
| 76 | + env: |
| 77 | + TAURI_SIGNING_PRIVATE_KEY_B64: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_B64 }} |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + mkdir -p "$HOME/.tauri" |
| 81 | + echo "$TAURI_SIGNING_PRIVATE_KEY_B64" | base64 --decode > "$HOME/.tauri/codexmonitor.key" |
| 82 | +
|
| 83 | + - name: Build app bundle |
| 84 | + env: |
| 85 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} |
| 86 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} |
| 87 | + run: | |
| 88 | + set -euo pipefail |
| 89 | + npm run tauri -- build --bundles app |
| 90 | +
|
| 91 | + - name: Bundle OpenSSL and re-sign |
| 92 | + run: | |
| 93 | + set -euo pipefail |
| 94 | + CODESIGN_IDENTITY="$CODESIGN_IDENTITY" \ |
| 95 | + scripts/macos-fix-openssl.sh |
| 96 | +
|
| 97 | + - name: Notarize and staple |
| 98 | + run: | |
| 99 | + set -euo pipefail |
| 100 | + ditto -c -k --keepParent \ |
| 101 | + src-tauri/target/release/bundle/macos/CodexMonitor.app \ |
| 102 | + CodexMonitor.zip |
| 103 | +
|
| 104 | + xcrun notarytool submit CodexMonitor.zip \ |
| 105 | + --keychain-profile "$NOTARY_PROFILE_NAME" \ |
| 106 | + --wait |
| 107 | +
|
| 108 | + xcrun stapler staple \ |
| 109 | + src-tauri/target/release/bundle/macos/CodexMonitor.app |
| 110 | +
|
| 111 | + - name: Package artifacts |
| 112 | + run: | |
| 113 | + set -euo pipefail |
| 114 | + VERSION="${{ inputs.version }}" |
| 115 | +
|
| 116 | + mkdir -p release-artifacts release-artifacts/dmg-root |
| 117 | + rm -rf release-artifacts/dmg-root/CodexMonitor.app |
| 118 | + ditto src-tauri/target/release/bundle/macos/CodexMonitor.app \ |
| 119 | + release-artifacts/dmg-root/CodexMonitor.app |
| 120 | +
|
| 121 | + ditto -c -k --keepParent \ |
| 122 | + src-tauri/target/release/bundle/macos/CodexMonitor.app \ |
| 123 | + release-artifacts/CodexMonitor.zip |
| 124 | +
|
| 125 | + hdiutil create -volname "CodexMonitor" \ |
| 126 | + -srcfolder release-artifacts/dmg-root \ |
| 127 | + -ov -format UDZO \ |
| 128 | + release-artifacts/CodexMonitor_${VERSION}_aarch64.dmg |
| 129 | +
|
| 130 | + COPYFILE_DISABLE=1 tar -czf \ |
| 131 | + src-tauri/target/release/bundle/macos/CodexMonitor.app.tar.gz \ |
| 132 | + -C src-tauri/target/release/bundle/macos CodexMonitor.app |
| 133 | +
|
| 134 | + npm run tauri signer sign -- \ |
| 135 | + -f "$HOME/.tauri/codexmonitor.key" \ |
| 136 | + -p "$TAURI_SIGNING_PRIVATE_KEY_PASSWORD" \ |
| 137 | + src-tauri/target/release/bundle/macos/CodexMonitor.app.tar.gz |
| 138 | +
|
| 139 | + - name: Build latest.json |
| 140 | + run: | |
| 141 | + set -euo pipefail |
| 142 | + VERSION="${{ inputs.version }}" |
| 143 | + SIGNATURE=$(cat src-tauri/target/release/bundle/macos/CodexMonitor.app.tar.gz.sig) |
| 144 | + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || true) |
| 145 | + if [ -n "$LAST_TAG" ]; then |
| 146 | + git log "${LAST_TAG}..HEAD" --pretty=format:"- %s" > release-artifacts/release-notes.md |
| 147 | + else |
| 148 | + git log --pretty=format:"- %s" > release-artifacts/release-notes.md |
| 149 | + fi |
| 150 | +
|
| 151 | + python3 - <<PY |
| 152 | + import json |
| 153 | + from datetime import datetime, timezone |
| 154 | + from pathlib import Path |
| 155 | +
|
| 156 | + notes = Path("release-artifacts/release-notes.md").read_text().strip() |
| 157 | +
|
| 158 | + payload = { |
| 159 | + "version": "${VERSION}", |
| 160 | + "notes": notes, |
| 161 | + "pub_date": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), |
| 162 | + "platforms": { |
| 163 | + "darwin-aarch64": { |
| 164 | + "url": "https://github.com/Dimillian/CodexMonitor/releases/download/v${VERSION}/CodexMonitor.app.tar.gz", |
| 165 | + "signature": "${SIGNATURE}", |
| 166 | + } |
| 167 | + }, |
| 168 | + } |
| 169 | +
|
| 170 | + Path("release-artifacts/latest.json").write_text(json.dumps(payload, indent=2) + "\\n") |
| 171 | + PY |
| 172 | +
|
| 173 | + - name: Create GitHub release |
| 174 | + env: |
| 175 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 176 | + run: | |
| 177 | + set -euo pipefail |
| 178 | + VERSION="${{ inputs.version }}" |
| 179 | +
|
| 180 | + gh release create "v${VERSION}" \ |
| 181 | + --title "v${VERSION}" \ |
| 182 | + --notes-file release-artifacts/release-notes.md \ |
| 183 | + --target "$GITHUB_SHA" \ |
| 184 | + release-artifacts/CodexMonitor.zip \ |
| 185 | + release-artifacts/CodexMonitor_${VERSION}_aarch64.dmg \ |
| 186 | + src-tauri/target/release/bundle/macos/CodexMonitor.app.tar.gz \ |
| 187 | + src-tauri/target/release/bundle/macos/CodexMonitor.app.tar.gz.sig \ |
| 188 | + release-artifacts/latest.json |
| 189 | +
|
| 190 | + - name: Bump version and open PR |
| 191 | + env: |
| 192 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 193 | + run: | |
| 194 | + set -euo pipefail |
| 195 | + VERSION="${{ inputs.version }}" |
| 196 | +
|
| 197 | + NEXT_VERSION=$(python3 - <<'PY' "$VERSION" |
| 198 | + import sys |
| 199 | +
|
| 200 | + version = sys.argv[1] |
| 201 | + parts = version.split(".") |
| 202 | + if len(parts) != 3: |
| 203 | + raise SystemExit("Expected version like 0.X.Y") |
| 204 | +
|
| 205 | + major, minor, patch = (int(p) for p in parts) |
| 206 | + print(f"{major}.{minor}.{patch + 1}") |
| 207 | + PY |
| 208 | + ) |
| 209 | +
|
| 210 | + git config user.name "github-actions[bot]" |
| 211 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 212 | +
|
| 213 | + npm version "$NEXT_VERSION" --no-git-tag-version |
| 214 | +
|
| 215 | + python3 - <<PY |
| 216 | + import json |
| 217 | + from pathlib import Path |
| 218 | +
|
| 219 | + path = Path("src-tauri/tauri.conf.json") |
| 220 | + data = json.loads(path.read_text()) |
| 221 | + data["version"] = "$NEXT_VERSION" |
| 222 | + path.write_text(json.dumps(data, indent=2) + "\\n") |
| 223 | + PY |
| 224 | +
|
| 225 | + git checkout -b "chore/bump-version-${NEXT_VERSION}" |
| 226 | + git add package.json package-lock.json src-tauri/tauri.conf.json |
| 227 | + git commit -m "chore: bump version to ${NEXT_VERSION}" |
| 228 | + git push origin "chore/bump-version-${NEXT_VERSION}" |
| 229 | +
|
| 230 | + gh pr create \ |
| 231 | + --title "chore: bump version to ${NEXT_VERSION}" \ |
| 232 | + --body "Post-release version bump to ${NEXT_VERSION}." \ |
| 233 | + --base main \ |
| 234 | + --head "chore/bump-version-${NEXT_VERSION}" |
0 commit comments