From 55d987219ffa0f85a7b18d4510e21845e8388935 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 25 Oct 2024 23:58:27 -0400 Subject: [PATCH] ci: rework release workflow --- .github/workflows/{build.yml => ci.yml} | 45 ++++++------------------- .github/workflows/publish.yml | 35 +++++++++++++++++++ package.json | 2 ++ 3 files changed, 48 insertions(+), 34 deletions(-) rename .github/workflows/{build.yml => ci.yml} (50%) create mode 100644 .github/workflows/publish.yml 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..551a750 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,16 @@ 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 + shell: bash + - 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..54006e9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish + +on: + push: + tags: + - v[0-9]+.[0-9]+.[0-9]+ + +jobs: + build: + uses: "./.github/workflows/ci.yml" + + 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/package.json b/package.json index 798dd5c..c53b519 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,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 --test $(find test -name '*.js')" },