|
| 1 | +# Build, sign, and notarize the macOS app. Run manually or on tag. |
| 2 | +# Required secrets: APPLE_CERTIFICATE, APPLE_CERTIFICATE_PASSWORD, APPLE_ID, |
| 3 | +# APPLE_APP_SPECIFIC_PASSWORD, KEYCHAIN_PASSWORD |
| 4 | +# Optional: APPLE_TEAM_ID (defaults to DP9DFGMC65 in notarize script) |
| 5 | + |
| 6 | +name: Release macOS |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + push: |
| 11 | + tags: |
| 12 | + - '*' |
| 13 | + |
| 14 | +jobs: |
| 15 | + release-macos: |
| 16 | + runs-on: macos-latest |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set version from tag |
| 22 | + id: version |
| 23 | + run: | |
| 24 | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 25 | + echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT |
| 26 | + else |
| 27 | + echo "version=0.0.0" >> $GITHUB_OUTPUT |
| 28 | + fi |
| 29 | +
|
| 30 | + - name: Write version file and update app config |
| 31 | + run: | |
| 32 | + VERSION="${{ steps.version.outputs.version }}" |
| 33 | + echo "$VERSION" > app/version.txt |
| 34 | + sed -i.bak "s/\"version\": \"[^\"]*\"/\"version\": \"$VERSION\"/" app/package.json && rm -f app/package.json.bak |
| 35 | + sed -i.bak "s/\"version\":\"[^\"]*\"/\"version\":\"$VERSION\"/" app/src-tauri/tauri.conf.json && rm -f app/src-tauri/tauri.conf.json.bak |
| 36 | + sed -i.bak "s/^version = \"[^\"]*\"/version = \"$VERSION\"/" app/src-tauri/Cargo.toml && rm -f app/src-tauri/Cargo.toml.bak |
| 37 | +
|
| 38 | + - name: Setup Node.js |
| 39 | + uses: actions/setup-node@v4 |
| 40 | + with: |
| 41 | + node-version: 20 |
| 42 | + cache: 'npm' |
| 43 | + cache-dependency-path: app/package-lock.json |
| 44 | + |
| 45 | + - name: Install Rust |
| 46 | + uses: dtolnay/rust-toolchain@stable |
| 47 | + |
| 48 | + - name: Import Apple Developer certificate |
| 49 | + env: |
| 50 | + APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} |
| 51 | + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} |
| 52 | + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} |
| 53 | + run: | |
| 54 | + echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12 |
| 55 | + security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain |
| 56 | + security default-keychain -s build.keychain |
| 57 | + security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain |
| 58 | + security set-keychain-settings -t 3600 -u build.keychain |
| 59 | + security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign |
| 60 | + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain |
| 61 | + rm certificate.p12 |
| 62 | +
|
| 63 | + - name: Get signing identity |
| 64 | + id: identity |
| 65 | + run: | |
| 66 | + SIGNING_IDENTITY=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application" | head -1 | sed -n 's/.*"\(.*\)".*/\1/p') |
| 67 | + if [ -z "$SIGNING_IDENTITY" ]; then |
| 68 | + echo "No Developer ID Application identity found in keychain" |
| 69 | + security find-identity -v -p codesigning build.keychain |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | + echo "identity=$SIGNING_IDENTITY" >> $GITHUB_OUTPUT |
| 73 | + echo "SIGNING_IDENTITY=$SIGNING_IDENTITY" >> $GITHUB_ENV |
| 74 | +
|
| 75 | + - name: Install dependencies |
| 76 | + working-directory: app |
| 77 | + run: npm ci |
| 78 | + |
| 79 | + - name: Build and sign (Tauri + re-sign with timestamp + hardened runtime) |
| 80 | + working-directory: app |
| 81 | + env: |
| 82 | + SIGNING_IDENTITY: ${{ steps.identity.outputs.identity }} |
| 83 | + run: npm run tauri:build:release |
| 84 | + |
| 85 | + - name: Notarize |
| 86 | + working-directory: app |
| 87 | + env: |
| 88 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 89 | + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} |
| 90 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 91 | + run: npm run notarize |
| 92 | + |
| 93 | + - name: Upload notarized app |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: macos-notarized-app-${{ steps.version.outputs.version }} |
| 97 | + path: | |
| 98 | + app/src-tauri/target/release/bundle/macos/neopixel-blocks.app |
| 99 | + app/version.txt |
0 commit comments