|
| 1 | +name: release / desktop publish |
| 2 | + |
| 3 | +# Triggered when a desktop release-prepare PR is merged. The merge commit's |
| 4 | +# message begins with "release(desktop): vX.Y.Z" — that's how we filter. |
| 5 | +# |
| 6 | +# Order: assert secrets → import signing identity → install JS deps + Pods → |
| 7 | +# stamp CFBundleVersion → xcodebuild archive + export → notarize + staple → |
| 8 | +# create-dmg → move tag onto merge commit → create GitHub Release with .dmg. |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + publish: |
| 20 | + if: "${{ startsWith(github.event.head_commit.message, 'release(desktop): v') }}" |
| 21 | + runs-on: macos-14 |
| 22 | + timeout-minutes: 60 |
| 23 | + |
| 24 | + env: |
| 25 | + APP_NAME: entangle |
| 26 | + SCHEME: entangle-macOS |
| 27 | + WORKSPACE: apps/desktop/macos/entangle.xcworkspace |
| 28 | + ARCHIVE_PATH: build/entangle.xcarchive |
| 29 | + EXPORT_PATH: build/export |
| 30 | + EXPORT_OPTIONS: apps/desktop/macos/ExportOptions.plist |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Parse version from commit message |
| 38 | + id: parse |
| 39 | + run: | |
| 40 | + MSG=$(printf '%s' "${{ github.event.head_commit.message }}" | head -n1) |
| 41 | + VERSION=$(printf '%s' "$MSG" | sed -nE 's/^release\(desktop\): v([0-9]+\.[0-9]+\.[0-9]+).*/\1/p') |
| 42 | + if [ -z "$VERSION" ]; then |
| 43 | + echo "Could not parse version from: $MSG" >&2 |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 47 | +
|
| 48 | + - name: Assert required secrets |
| 49 | + env: |
| 50 | + MACOS_CERT_P12_BASE64: ${{ secrets.MACOS_CERT_P12_BASE64 }} |
| 51 | + MACOS_CERT_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }} |
| 52 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 53 | + APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }} |
| 54 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 55 | + run: | |
| 56 | + missing=() |
| 57 | + for s in MACOS_CERT_P12_BASE64 MACOS_CERT_PASSWORD APPLE_ID APPLE_APP_PASSWORD APPLE_TEAM_ID; do |
| 58 | + if [ -z "${!s}" ]; then missing+=("$s"); fi |
| 59 | + done |
| 60 | + if [ ${#missing[@]} -gt 0 ]; then |
| 61 | + echo "Missing required repo secrets: ${missing[*]}" >&2 |
| 62 | + echo "See RELEASING.md for how to set them up." >&2 |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Stamp CFBundleVersion |
| 67 | + env: |
| 68 | + BUILD_NUMBER: ${{ github.run_number }} |
| 69 | + run: | |
| 70 | + /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" \ |
| 71 | + apps/desktop/macos/entangle-macOS/Info.plist |
| 72 | +
|
| 73 | + - name: Setup Node + pnpm |
| 74 | + uses: actions/setup-node@v4 |
| 75 | + with: |
| 76 | + node-version: '20' |
| 77 | + - run: corepack enable && corepack prepare pnpm@10.33.0 --activate |
| 78 | + |
| 79 | + - name: Install JS deps |
| 80 | + working-directory: apps/desktop |
| 81 | + run: pnpm install --ignore-workspace --frozen-lockfile |
| 82 | + |
| 83 | + - name: Setup Ruby + Bundler |
| 84 | + uses: ruby/setup-ruby@v1 |
| 85 | + with: |
| 86 | + ruby-version: '3.2' |
| 87 | + bundler-cache: true |
| 88 | + working-directory: apps/desktop |
| 89 | + |
| 90 | + - name: Install Pods |
| 91 | + working-directory: apps/desktop/macos |
| 92 | + run: bundle exec pod install |
| 93 | + |
| 94 | + - name: Import signing certificate |
| 95 | + env: |
| 96 | + MACOS_CERT_P12_BASE64: ${{ secrets.MACOS_CERT_P12_BASE64 }} |
| 97 | + MACOS_CERT_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }} |
| 98 | + run: | |
| 99 | + KEYCHAIN=build.keychain |
| 100 | + KEYCHAIN_PWD=$(uuidgen) |
| 101 | +
|
| 102 | + echo "$MACOS_CERT_P12_BASE64" | base64 --decode > /tmp/cert.p12 |
| 103 | + security create-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN" |
| 104 | + security set-keychain-settings -lut 21600 "$KEYCHAIN" |
| 105 | + security unlock-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN" |
| 106 | + security import /tmp/cert.p12 -k "$KEYCHAIN" -P "$MACOS_CERT_PASSWORD" \ |
| 107 | + -T /usr/bin/codesign -T /usr/bin/productbuild -T /usr/bin/security |
| 108 | + security set-key-partition-list -S apple-tool:,apple:,codesign: \ |
| 109 | + -s -k "$KEYCHAIN_PWD" "$KEYCHAIN" >/dev/null |
| 110 | + security list-keychains -d user -s "$KEYCHAIN" $(security list-keychains -d user | tr -d '"') |
| 111 | + rm /tmp/cert.p12 |
| 112 | +
|
| 113 | + - name: xcodebuild archive |
| 114 | + run: | |
| 115 | + xcodebuild \ |
| 116 | + -workspace "$WORKSPACE" \ |
| 117 | + -scheme "$SCHEME" \ |
| 118 | + -configuration Release \ |
| 119 | + -archivePath "$ARCHIVE_PATH" \ |
| 120 | + -destination 'generic/platform=macOS' \ |
| 121 | + CODE_SIGN_STYLE=Manual \ |
| 122 | + DEVELOPMENT_TEAM="${{ secrets.APPLE_TEAM_ID }}" \ |
| 123 | + archive | xcpretty && exit ${PIPESTATUS[0]} |
| 124 | +
|
| 125 | + - name: xcodebuild exportArchive |
| 126 | + run: | |
| 127 | + xcodebuild \ |
| 128 | + -exportArchive \ |
| 129 | + -archivePath "$ARCHIVE_PATH" \ |
| 130 | + -exportPath "$EXPORT_PATH" \ |
| 131 | + -exportOptionsPlist "$EXPORT_OPTIONS" | xcpretty && exit ${PIPESTATUS[0]} |
| 132 | +
|
| 133 | + - name: Notarize |
| 134 | + env: |
| 135 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 136 | + APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }} |
| 137 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 138 | + run: | |
| 139 | + APP_PATH="$EXPORT_PATH/$APP_NAME.app" |
| 140 | + ZIP_PATH="$EXPORT_PATH/$APP_NAME.zip" |
| 141 | + ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH" |
| 142 | + xcrun notarytool submit "$ZIP_PATH" \ |
| 143 | + --apple-id "$APPLE_ID" \ |
| 144 | + --password "$APPLE_APP_PASSWORD" \ |
| 145 | + --team-id "$APPLE_TEAM_ID" \ |
| 146 | + --wait |
| 147 | + xcrun stapler staple "$APP_PATH" |
| 148 | +
|
| 149 | + - name: Build DMG |
| 150 | + env: |
| 151 | + VERSION: ${{ steps.parse.outputs.version }} |
| 152 | + run: | |
| 153 | + brew install create-dmg |
| 154 | + DMG_PATH="$EXPORT_PATH/${APP_NAME}-${VERSION}.dmg" |
| 155 | + create-dmg \ |
| 156 | + --volname "${APP_NAME} ${VERSION}" \ |
| 157 | + --window-size 600 400 \ |
| 158 | + --icon-size 100 \ |
| 159 | + --app-drop-link 450 200 \ |
| 160 | + "$DMG_PATH" \ |
| 161 | + "$EXPORT_PATH/${APP_NAME}.app" |
| 162 | + # Re-staple the DMG itself for offline Gatekeeper checks. |
| 163 | + xcrun stapler staple "$DMG_PATH" || true |
| 164 | + echo "DMG=$DMG_PATH" >> "$GITHUB_ENV" |
| 165 | +
|
| 166 | + - name: Move tag onto merge commit |
| 167 | + env: |
| 168 | + VERSION: ${{ steps.parse.outputs.version }} |
| 169 | + # The original tag pointed at the developer's pre-bump commit; we move |
| 170 | + # it so the GitHub Release reflects the actually-released tree. |
| 171 | + run: | |
| 172 | + git config user.name "entangle-release-bot" |
| 173 | + git config user.email "release-bot@users.noreply.github.com" |
| 174 | + git tag -f "v${VERSION}-desktop" |
| 175 | + git push -f origin "v${VERSION}-desktop" |
| 176 | +
|
| 177 | + - name: Create GitHub Release |
| 178 | + env: |
| 179 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 180 | + VERSION: ${{ steps.parse.outputs.version }} |
| 181 | + run: | |
| 182 | + gh release create "v${VERSION}-desktop" "$DMG" \ |
| 183 | + --title "Desktop v${VERSION}" \ |
| 184 | + --generate-notes \ |
| 185 | + --verify-tag |
0 commit comments