ci: Fix builds #44
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: CI | |
| env: | |
| DEBUG: napi:* | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| RUST_BACKTRACE: 1 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*.*.*' | |
| pull_request: | |
| jobs: | |
| # Builds native Node.js bindings for each target platform using napi-rs. | |
| # The build artifacts are uploaded and used by the test job. | |
| build: | |
| name: Build - ${{ matrix.target }} | |
| if: "!contains(github.event.head_commit.message, 'skip ci')" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [aarch64-apple-darwin, x86_64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc] | |
| include: | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| cache: npm | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| - name: Cache NPM dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: node_modules | |
| key: npm-cache-${{ matrix.target }}-node@18-${{ hashFiles('package-lock.json') }} | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: rust-cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install dependencies | |
| run: npm install | |
| shell: bash | |
| - name: Build | |
| run: npx nx build:native -- --platform ${{ matrix.target }} | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.target }} | |
| path: | | |
| **/*.node | |
| !node_modules/**/*.node | |
| !target/**/*.node | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # Downloads the built native modules and runs the test suite on each platform | |
| # to ensure the bindings work correctly across different architectures. | |
| test: | |
| name: Test - ${{ matrix.target }} | |
| needs: | |
| - build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [aarch64-apple-darwin, x86_64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc] | |
| include: | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| cache: npm | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.target }} | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Test | |
| run: npm test | |
| # Publishes the package to npm when a tag is pushed, or performs a dry-run during PRs. | |
| publish: | |
| name: ${{ github.event_name == 'pull_request' && '🔍 Publish (Dry Run)' || '📦 Publish' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'pull_request' | |
| needs: | |
| - build | |
| - test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| cache: npm | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: bindings-* | |
| merge-multiple: true | |
| - name: Build TypeScript | |
| run: npm run build:ts | |
| - name: Verify package contents | |
| run: | | |
| echo "Package contents:" | |
| npm pack --dry-run | |
| - name: Publish | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish (Dry Run) | |
| if: github.event_name == 'pull_request' | |
| run: npm publish --dry-run |