Fix macOS bundled runtime signing #11
Workflow file for this run
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
| name: Release Desktop | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag, for example v0.1.0" | |
| required: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| name: Build ${{ matrix.name }} | |
| runs-on: ${{ matrix.platform }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Windows | |
| platform: windows-latest | |
| args: "" | |
| rustTargets: "" | |
| - name: macOS Apple Silicon | |
| platform: macos-latest | |
| args: "--target aarch64-apple-darwin" | |
| rustTargets: "aarch64-apple-darwin" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.rustTargets }} | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: apps/desktop/src-tauri -> target | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Prepare bundled sidecar runtime | |
| shell: bash | |
| run: | | |
| rm -rf apps/desktop/src-tauri/resources | |
| mkdir -p apps/desktop/src-tauri/resources/node | |
| cp -RL apps/desktop/sidecar apps/desktop/src-tauri/resources/sidecar | |
| NODE_BIN="$(command -v node)" | |
| if [[ "$RUNNER_OS" == "Windows" ]]; then | |
| cp "$NODE_BIN" apps/desktop/src-tauri/resources/node/node.exe | |
| else | |
| cp "$NODE_BIN" apps/desktop/src-tauri/resources/node/node | |
| chmod +x apps/desktop/src-tauri/resources/node/node | |
| fi | |
| - name: Verify bundled sidecar runtime | |
| shell: bash | |
| run: | | |
| test -f apps/desktop/src-tauri/resources/sidecar/bin/pi-prompt.mjs | |
| if [[ "$RUNNER_OS" == "Windows" ]]; then | |
| test -f apps/desktop/src-tauri/resources/node/node.exe | |
| else | |
| test -f apps/desktop/src-tauri/resources/node/node | |
| fi | |
| - name: Test desktop backend | |
| working-directory: apps/desktop/src-tauri | |
| run: cargo test | |
| - name: Import Apple Developer ID certificate | |
| if: runner.os == 'macOS' | |
| env: | |
| APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} | |
| APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | |
| KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
| run: | | |
| CERTIFICATE_PATH="$RUNNER_TEMP/developer-id-application.p12" | |
| KEYCHAIN_PATH="$RUNNER_TEMP/app-signing.keychain-db" | |
| echo "$APPLE_CERTIFICATE" | base64 --decode > "$CERTIFICATE_PATH" | |
| security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" | |
| security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH" | |
| security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" | |
| security import "$CERTIFICATE_PATH" \ | |
| -P "$APPLE_CERTIFICATE_PASSWORD" \ | |
| -A \ | |
| -t cert \ | |
| -f pkcs12 \ | |
| -k "$KEYCHAIN_PATH" | |
| security list-keychains -d user -s "$KEYCHAIN_PATH" "$HOME/Library/Keychains/login.keychain-db" | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" | |
| security find-identity -v -p codesigning "$KEYCHAIN_PATH" | |
| - name: Sign bundled Node runtime | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| KEYCHAIN_PATH="$RUNNER_TEMP/app-signing.keychain-db" | |
| NODE_RUNTIME="apps/desktop/src-tauri/resources/node/node" | |
| codesign --force \ | |
| --options runtime \ | |
| --timestamp \ | |
| --keychain "$KEYCHAIN_PATH" \ | |
| --sign "Developer ID Application: Beiming Liu (MJFP85U8HQ)" \ | |
| "$NODE_RUNTIME" | |
| codesign --verify --strict --verbose=4 "$NODE_RUNTIME" | |
| - name: Build and publish Tauri app | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| with: | |
| projectPath: apps/desktop | |
| tagName: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} | |
| releaseName: Irori ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} | |
| releaseBody: See the assets below to download and install this version. | |
| releaseDraft: true | |
| prerelease: false | |
| args: ${{ matrix.args }} | |
| - name: Verify packaged macOS signature | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| APP_BUNDLE="apps/desktop/src-tauri/target/aarch64-apple-darwin/release/bundle/macos/Irori.app" | |
| codesign --verify --deep --strict --verbose=4 "$APP_BUNDLE" | |
| spctl --assess --type execute --verbose=4 "$APP_BUNDLE" |