diff --git a/.github/workflows/build.yml b/.github/workflows/ci.yml similarity index 50% rename from .github/workflows/build.yml rename to .github/workflows/ci.yml index 5ed615f..ab8dc13 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/ci.yml @@ -1,31 +1,30 @@ -name: build +name: Build on: push: branches: - master - tags: - - v* pull_request: branches: - master + workflow_call: concurrency: group: ${{github.workflow}}-${{github.ref}} cancel-in-progress: true - jobs: test: strategy: matrix: os: - - windows-2022 - - macos-14 - - ubuntu-20.04 + - windows-latest + - macos-latest + - ubuntu-latest node: - 18 - 20 + - 22 fail-fast: false name: Testing Node ${{ matrix.node }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -37,38 +36,15 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + - run: npm install - - run: npm run build -- --arch x64 - - run: npm run build -- --arch arm64 + - run: npm run build_x64 + - run: npm run build_arm64 - run: npm test + - uses: actions/upload-artifact@v4 if: github.ref_type == 'tag' && matrix.node == 20 with: path: prebuilds/** name: prebuilds-${{matrix.os}} retention-days: 2 - - publish: - if: github.ref_type == 'tag' - name: Publish to npm - runs-on: ubuntu-20.04 - needs: [test] - steps: - - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: https://registry.npmjs.org - - uses: actions/download-artifact@v4 - with: - path: prebuilds - pattern: prebuilds-* - merge-multiple: true - - run: tree prebuilds - - run: npm install - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4d88333 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish + +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ + +jobs: + build: + uses: "./.github/workflows/ci.yml" + + publish: + name: Publish to npm + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org + - uses: actions/download-artifact@v4 + with: + path: prebuilds + pattern: prebuilds-* + merge-multiple: true + - run: tree prebuilds + - run: npm install + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index ae8d6ee..3233c8c 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,8 @@ "scripts": { "install": "node-gyp-build", "build": "prebuildify --napi --strip", + "build_x64": "prebuildify --napi --strip --arch x64", + "build_arm64": "prebuildify --napi --strip --arch arm64", "rebuild": "node-gyp rebuild", "test": "node -e \"require('child_process').spawnSync('node', ['--test', ...require('glob').sync('test/**/*.js')], {stdio:'inherit'})\"" },