publish-napi #153
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
| # Copyright 2019-2022 Tauri Programme within The Commons Conservancy | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # SPDX-License-Identifier: MIT | |
| name: publish napi modules | |
| permissions: | |
| # required for OIDC token | |
| id-token: write | |
| env: | |
| DEBUG: napi:* | |
| APP_NAME: create-tauri-app | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| releaseId: | |
| description: 'Release Id' | |
| required: true | |
| type: string | |
| repository_dispatch: | |
| types: [publish-napi] | |
| jobs: | |
| build: | |
| defaults: | |
| run: | |
| working-directory: node | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| build: pnpm build --target x86_64-apple-darwin | |
| - host: windows-latest | |
| build: pnpm build --target x86_64-pc-windows-msvc | |
| target: x86_64-pc-windows-msvc | |
| - host: windows-latest | |
| build: pnpm build --target i686-pc-windows-msvc | |
| target: i686-pc-windows-msvc | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| build: pnpm build --target x86_64-unknown-linux-musl -x | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| build: pnpm build --target aarch64-apple-darwin | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| build: pnpm build --target aarch64-unknown-linux-gnu --use-napi-cross | |
| - host: ubuntu-latest | |
| target: armv7-unknown-linux-gnueabihf | |
| build: pnpm build --target armv7-unknown-linux-gnueabihf --use-napi-cross | |
| - host: ubuntu-latest | |
| target: aarch64-linux-android | |
| build: pnpm build --target aarch64-linux-android | |
| - host: ubuntu-latest | |
| target: armv7-linux-androideabi | |
| build: pnpm build --target armv7-linux-androideabi | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-musl | |
| build: pnpm build --target aarch64-unknown-linux-musl -x | |
| - host: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| build: pnpm build --target aarch64-pc-windows-msvc | |
| name: stable - ${{ matrix.settings.target }} - node@22 | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: | | |
| npm i -g --force corepack | |
| corepack enable | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| if: ${{ !matrix.settings.docker }} | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install | |
| uses: dtolnay/rust-toolchain@stable | |
| if: ${{ !matrix.settings.docker }} | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.settings.target }} | |
| - name: Cache cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| ~/.napi-rs | |
| .cargo-cache | |
| target/ | |
| key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} | |
| - uses: mlugg/setup-zig@v2 | |
| if: ${{ contains(matrix.settings.target, 'musl') }} | |
| with: | |
| version: 0.14.1 | |
| - name: Install cargo-zigbuild | |
| uses: taiki-e/install-action@v2 | |
| if: ${{ contains(matrix.settings.target, 'musl') }} | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tool: cargo-zigbuild | |
| - name: Setup toolchain | |
| run: ${{ matrix.settings.setup }} | |
| if: ${{ matrix.settings.setup }} | |
| shell: bash | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build | |
| run: ${{ matrix.settings.build }} | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: napi-${{ matrix.settings.target }} | |
| path: node/${{ env.APP_NAME }}.*.node | |
| if-no-files-found: error | |
| build-universal-macOS: | |
| name: Build universal macOS binary | |
| needs: | |
| - build | |
| runs-on: macos-latest | |
| defaults: | |
| run: | |
| working-directory: node | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: | | |
| npm i -g --force corepack | |
| corepack enable | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download macOS x64 artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: napi-x86_64-apple-darwin | |
| path: node/artifacts | |
| - name: Download macOS arm64 artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: napi-aarch64-apple-darwin | |
| path: node/artifacts | |
| - name: Combine binaries | |
| run: pnpm universal | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: napi-universal-apple-darwin | |
| path: node/${{ env.APP_NAME }}.darwin-universal.node | |
| if-no-files-found: error | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-universal-macOS | |
| defaults: | |
| run: | |
| working-directory: node | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: | | |
| npm i -g --force corepack | |
| corepack enable | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: node/artifacts | |
| - name: List artifacts | |
| run: ls artifacts | |
| shell: bash | |
| - name: Move artifacts | |
| run: pnpm artifacts | |
| - name: List packages | |
| run: ls -R ./npm | |
| shell: bash | |
| # We publish as `create-tauri-app` first and then rewrite the package.json to publish as `create-tauri` as well. | |
| - name: Publish | |
| run: | | |
| npm publish | |
| jq '.name = "create-tauri" | .bin = { "create-tauri": .bin["create-tauri-app"] } | del(.scripts.prepublishOnly)' package.json > package.tmp | |
| mv -f package.tmp package.json | |
| npm publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_ID: ${{ github.event.client_payload.releaseId || inputs.releaseId }} |