name: CI on: pull_request: push: branches: - master - main tags: - "v*" workflow_dispatch: permissions: contents: read id-token: write jobs: build: name: build-${{ matrix.target }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu needs_cross_gcc: false - target: aarch64-unknown-linux-gnu needs_cross_gcc: true steps: - uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm - name: Enable corepack run: corepack enable - name: Setup Rust toolchain uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Install aarch64 cross compiler if: matrix.needs_cross_gcc run: | sudo apt-get update sudo apt-get install -y gcc-aarch64-linux-gnu - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build native addon run: | if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ pnpm exec napi build --platform --release --target ${{ matrix.target }} else pnpm exec napi build --platform --release --target ${{ matrix.target }} fi - name: Upload artifact uses: actions/upload-artifact@v4 with: name: bindings-${{ matrix.target }} path: cocalc_openat2.*.node if-no-files-found: error test: name: test-linux-x64 runs-on: ubuntu-latest needs: build steps: - uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm - name: Enable corepack run: corepack enable - name: Install dependencies run: pnpm install --frozen-lockfile - name: Download x64 artifact uses: actions/download-artifact@v4 with: name: bindings-x86_64-unknown-linux-gnu path: . - name: Run tests run: pnpm test publish: name: publish if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest needs: - build - test steps: - uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm - name: Enable corepack run: corepack enable - name: Install dependencies run: pnpm install --frozen-lockfile - name: Download build artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: Move artifacts into npm package dirs run: pnpm run artifacts - name: Show package dirs run: ls -R npm - name: Publish root package (prepublish publishes per-platform packages first) env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc npm config set provenance true npm publish --access public