From adddf9a96f61601e6510343deabe4f9b2246bd83 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sun, 29 Dec 2024 17:51:10 -0500 Subject: [PATCH 1/2] ci: actually build arm64 binaries --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++-------- package.json | 2 -- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed4c7fa..902b2b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,23 +26,48 @@ jobs: - 20 - 22 fail-fast: false - name: Testing Node ${{ matrix.node }} on ${{ matrix.os }} + name: Test Node ${{ matrix.node }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 - - uses: actions/setup-node@v4 + + - name: Setup Node + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - - run: npm install - - run: npm run build_x64 - - run: npm run build_arm64 - - run: npm test + - name: Install dependencies + run: npm ci --legacy-peer-deps + + - name: Set npm_config_target + run: echo "CONFIG_TARGET=${{ matrix.node == 22 && '22.12.0' || '20.9.0' }}" >> $GITHUB_ENV + + - name: Build x64 binary + run: npm_config_target=${{ env.CONFIG_TARGET }} npm x -- prebuildify --napi --arch x64 -t 20.9.0 + + - name: Set up cross-compilation + if: runner.os == 'Linux' + run: |- + sudo apt-get update + sudo apt-get install g++-aarch64-linux-gnu + printf '%s\n' >> "$GITHUB_ENV" \ + 'CC=aarch64-linux-gnu-gcc' 'CXX=aarch64-linux-gnu-g++' + + - name: Build arm64 binary + run: npm_config_target=${{ env.CONFIG_TARGET }} npm x -- prebuildify --napi --arch arm64 -t 20.9.0 + + - name: Run tests + run: npm test - - uses: actions/upload-artifact@v4 + - name: Upload prebuilds + uses: actions/upload-artifact@v4 if: github.ref_type == 'tag' && matrix.node == 20 with: path: prebuilds/** diff --git a/package.json b/package.json index 760d271..5699d90 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,6 @@ "docs": "typedoc --out docs/api tree-sitter.d.ts --readme README.md", "install": "node-gyp-build", "build": "prebuildify --napi --strip", - "build_x64": "prebuildify --napi --strip --arch x64 --target 20.9.0", - "build_arm64": "prebuildify --napi --strip --arch arm64 --target 20.9.0", "rebuild": "node-gyp rebuild", "test": "node -e \"require('child_process').spawnSync('node', ['--test', ...require('glob').sync('test/**/*.js')], {stdio:'inherit'})\"" }, From 6186cf83c237babf2c9732343620022ce21c16b5 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sun, 29 Dec 2024 19:20:29 -0500 Subject: [PATCH 2/2] ci(publish): create GH release --- .github/workflows/publish.yml | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4d88333..4eb2f43 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,25 +10,44 @@ jobs: uses: "./.github/workflows/ci.yml" publish: - name: Publish to npm + name: Publish runs-on: ubuntu-latest needs: build steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 - - uses: actions/setup-node@v4 + + - name: Setup Node + uses: actions/setup-node@v4 with: node-version: 20 registry-url: https://registry.npmjs.org - - uses: actions/download-artifact@v4 + + - name: Download prebuilds + uses: actions/download-artifact@v4 with: path: prebuilds pattern: prebuilds-* merge-multiple: true - - run: tree prebuilds - - run: npm install - - run: npm publish + + - name: List prebuilds + run: tree prebuilds + + - name: Install dependencies + run: npm install + + - name: Publish to NPM + run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Create release + run: |- + gh release create --generate-notes \ + ${{ github.ref_name }} \ + prebuilds/**/*.node + env: + GH_TOKEN: ${{ github.token }}