feat: impl float-pigment-css-napi #8
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: NAPI | |
| on: | |
| push: | |
| branches: ['master'] | |
| tags: ['napi-v*'] | |
| paths: | |
| - 'float-pigment-css-napi/**' | |
| - 'float-pigment-css/**' | |
| - '.github/workflows/napi.yml' | |
| pull_request: | |
| branches: ['master'] | |
| paths: | |
| - 'float-pigment-css-napi/**' | |
| - 'float-pigment-css/**' | |
| - '.github/workflows/napi.yml' | |
| defaults: | |
| run: | |
| working-directory: float-pigment-css-napi | |
| env: | |
| DEBUG: napi:* | |
| APP_NAME: float-pigment-css-napi | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| build: pnpm run build --target aarch64-apple-darwin | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| build: pnpm run build --target x86_64-apple-darwin | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| build: pnpm run build --target x86_64-pc-windows-msvc | |
| - host: windows-latest | |
| target: i686-pc-windows-msvc | |
| build: pnpm run build --target i686-pc-windows-msvc | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: pnpm run build --target x86_64-unknown-linux-gnu --use-napi-cross | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| build: pnpm run build --target x86_64-unknown-linux-musl -x | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| build: pnpm run build --target aarch64-unknown-linux-gnu --use-napi-cross | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-musl | |
| build: pnpm run build --target aarch64-unknown-linux-musl -x | |
| name: build - ${{ matrix.settings.target }} | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Rust | |
| # Pin to the toolchain in the repo-root rust-toolchain.toml so the | |
| # cross-compile targets get added to the toolchain that actually builds. | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: '1.92.0' | |
| targets: ${{ matrix.settings.target }} | |
| - name: Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: 'float-pigment-css-napi -> ../target' | |
| # musl targets cross-compile via cargo-zigbuild (napi build -x) | |
| - name: Setup zig | |
| if: ${{ contains(matrix.settings.target, 'musl') }} | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.14.1 | |
| - name: Install cargo-zigbuild | |
| if: ${{ contains(matrix.settings.target, 'musl') }} | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-zigbuild | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 8 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| run: ${{ matrix.settings.build }} | |
| shell: bash | |
| - name: Test | |
| # Only run tests where the built artifact's arch matches the runner's: | |
| # macos-latest=arm64, ubuntu-latest=x64, windows-latest=x64. | |
| # The other targets are cross-compiled and can't be loaded here. | |
| if: ${{ matrix.settings.target == 'aarch64-apple-darwin' || matrix.settings.target == 'x86_64-unknown-linux-gnu' || matrix.settings.target == 'x86_64-pc-windows-msvc' }} | |
| run: pnpm test | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: float-pigment-css-napi/${{ env.APP_NAME }}.*.node | |
| if-no-files-found: error | |
| publish: | |
| name: publish | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/napi-v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 8 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Create npm dirs | |
| run: pnpm exec napi create-npm-dirs | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: float-pigment-css-napi/artifacts | |
| - name: Move artifacts into per-platform npm dirs | |
| run: pnpm run artifacts | |
| - name: List npm dirs | |
| run: ls -R ./npm | |
| - name: Publish | |
| run: | | |
| npm config set provenance true | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |