|
| 1 | +name: Electron Passkeys Native Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths: |
| 7 | + - 'packages/electron-passkeys/**' |
| 8 | + - '.github/workflows/electron-passkeys.yml' |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build ${{ matrix.settings.target }} |
| 17 | + runs-on: ${{ matrix.settings.host }} |
| 18 | + timeout-minutes: 30 |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + settings: |
| 23 | + - host: macos-14 |
| 24 | + target: aarch64-apple-darwin |
| 25 | + - host: macos-14 |
| 26 | + target: x86_64-apple-darwin |
| 27 | + - host: windows-latest |
| 28 | + target: x86_64-pc-windows-msvc |
| 29 | + - host: windows-latest |
| 30 | + target: aarch64-pc-windows-msvc |
| 31 | + defaults: |
| 32 | + run: |
| 33 | + working-directory: packages/electron-passkeys |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: 24 |
| 40 | + |
| 41 | + - uses: pnpm/action-setup@v4 |
| 42 | + |
| 43 | + - uses: dtolnay/rust-toolchain@stable |
| 44 | + with: |
| 45 | + targets: ${{ matrix.settings.target }} |
| 46 | + |
| 47 | + - uses: Swatinem/rust-cache@v2 |
| 48 | + with: |
| 49 | + workspaces: packages/electron-passkeys |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: pnpm install --filter @clerk/electron-passkeys... --frozen-lockfile --ignore-scripts |
| 53 | + working-directory: . |
| 54 | + |
| 55 | + - name: Build native module |
| 56 | + run: pnpm build --target ${{ matrix.settings.target }} |
| 57 | + |
| 58 | + - name: Smoke test (host-native targets only) |
| 59 | + if: matrix.settings.target == 'aarch64-apple-darwin' || matrix.settings.target == 'x86_64-pc-windows-msvc' |
| 60 | + run: node -e "const m = require('./index.js'); console.log('isAvailable:', m.isAvailable(), 'capabilities:', JSON.stringify(m.capabilities())); if (!m.isAvailable()) throw new Error('the loader did not find the freshly built native binary');" |
| 61 | + |
| 62 | + - uses: actions/upload-artifact@v4 |
| 63 | + with: |
| 64 | + name: bindings-${{ matrix.settings.target }} |
| 65 | + path: packages/electron-passkeys/electron-passkeys.*.node |
| 66 | + if-no-files-found: error |
| 67 | + |
| 68 | + package: |
| 69 | + name: Assemble platform packages |
| 70 | + needs: build |
| 71 | + runs-on: ubuntu-latest |
| 72 | + timeout-minutes: 10 |
| 73 | + defaults: |
| 74 | + run: |
| 75 | + working-directory: packages/electron-passkeys |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - uses: actions/setup-node@v4 |
| 80 | + with: |
| 81 | + node-version: 24 |
| 82 | + |
| 83 | + - uses: pnpm/action-setup@v4 |
| 84 | + |
| 85 | + - name: Install dependencies |
| 86 | + run: pnpm install --filter @clerk/electron-passkeys... --frozen-lockfile --ignore-scripts |
| 87 | + working-directory: . |
| 88 | + |
| 89 | + - uses: actions/download-artifact@v4 |
| 90 | + with: |
| 91 | + path: packages/electron-passkeys/artifacts |
| 92 | + |
| 93 | + - name: Move binaries into per-platform npm packages |
| 94 | + run: pnpm artifacts |
| 95 | + |
| 96 | + - name: Verify every platform package contains its binary |
| 97 | + run: | |
| 98 | + for dir in npm/*/; do |
| 99 | + count=$(find "$dir" -name '*.node' | wc -l) |
| 100 | + if [ "$count" -ne 1 ]; then |
| 101 | + echo "::error::$dir is missing its .node binary — publishing it would ship an empty package" |
| 102 | + exit 1 |
| 103 | + fi |
| 104 | + (cd "$dir" && npm pack --dry-run) |
| 105 | + done |
0 commit comments