Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: actually build arm64 binaries, & publish releases to gh #236

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
33 changes: 26 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'})\""
},
Expand Down
Loading