From 2bdc76a15f462d3f394c5598c37f744d415089d4 Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Sun, 10 Mar 2024 16:03:55 +0200 Subject: [PATCH] build: switch to prebuildify --- .github/workflows/build.yml | 64 ++++++++++++++++--------------------- binding.gyp | 57 +++++++++++++++++---------------- index.js | 15 ++------- package.json | 39 ++++++++++++++-------- 4 files changed, 86 insertions(+), 89 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8779f94f..722250da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,25 +4,25 @@ on: push: branches: - master + tags: + - v* pull_request: branches: - master - release: - types: - - released -env: - PREBUILD_CMD: npx prebuild -r napi --all --strip -u ${{ secrets.GH_TOKEN }} +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true -jobs: +jobs: test: strategy: matrix: os: - - windows-2019 + - windows-2022 - macos-14 - - ubuntu-20.04 + - ubuntu-22.04 node: - 18 - 20 @@ -37,15 +37,23 @@ jobs: - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - - run: npm install + - run: npm run build -- --arch x64 + - if: runner.os == 'macOS' + run: npm run build -- --arch 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.event_name == 'release' }} + if: github.ref_type == 'tag' name: Publish to npm - runs-on: ubuntu-20.04 - needs: test + runs-on: ubuntu-22.04 + needs: [test] steps: - uses: actions/checkout@v4 with: @@ -55,31 +63,13 @@ jobs: 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 --access public + - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - prebuild: - strategy: - matrix: - os: - - windows-2019 - - macos-14 - - ubuntu-20.04 - fail-fast: false - name: Prebuild for ${{ matrix.os }} - runs-on: ${{ matrix.os }} - needs: publish - steps: - - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm install - - run: ${{ env.PREBUILD_CMD }} - - if: runner.os == 'macOS' - run: ${{ env.PREBUILD_CMD }} --arch arm64 diff --git a/binding.gyp b/binding.gyp index 4fa2270d..01eb48a5 100644 --- a/binding.gyp +++ b/binding.gyp @@ -2,7 +2,10 @@ "targets": [ { "target_name": "tree_sitter_runtime_binding", - "dependencies": ["tree_sitter", "