Skip to content

Commit

Permalink
build: switch to prebuildify
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Mar 10, 2024
1 parent 245510c commit 414d4d8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 63 deletions.
62 changes: 24 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@ 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 }}

jobs:

test:
strategy:
matrix:
os:
- windows-2019
- windows-2022
- macos-14
- ubuntu-20.04
- ubuntu-22.04
node:
- 18
- 20
Expand All @@ -37,15 +32,24 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- run: npm install
- if: runner.os != 'macOS'
run: npm run build -- --arch x64
- if: runner.os == 'macOS'
run: npm run build -- --arch x64+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:
Expand All @@ -55,31 +59,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
15 changes: 3 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
let binding;
try {
binding = require('./build/Release/tree_sitter_runtime_binding');
} catch (e) {
try {
binding = require('./build/Debug/tree_sitter_runtime_binding');
} catch (_) {
throw e;
}
}

const util = require('util')
const binding = require('node-gyp-build')(__dirname);
const {Query, Parser, NodeMethods, Tree, TreeCursor, LookaheadIterator} = binding;

const util = require('util');

/*
* Tree
*/
Expand Down
39 changes: 26 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
{
"name": "tree-sitter",
"version": "0.20.6",
"version": "0.21.0",
"description": "Incremental parsers for node",
"author": "Max Brunsfeld",
"contributors": [
"Segev Finer",
"Boris Verkhovskiy",
"Amaan Qureshi"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/tree-sitter/node-tree-sitter.git"
},
"keywords": [
"parser",
"lexer"
"incremental",
"parsing",
"tree-sitter"
],
"main": "index.js",
"types": "tree-sitter.d.ts",
"files": [
"binding.gyp",
"tree-sitter.d.ts",
"prebuilds/*",
"src/*",
"vendor/tree-sitter/lib/include/*",
"vendor/tree-sitter/lib/src/*"
],
"dependencies": {
"node-addon-api": "^7.1.0",
"prebuild-install": "^7.1.1"
"node-gyp-build": "^4.8.0"
},
"devDependencies": {
"@types/node": "^20.11.16",
"chai": "^4.3.10",
"mocha": "^8.4.0",
"node-gyp": "^10.0.1",
"prebuild": "^13.0.0",
"prebuildify": "^6.0.0",
"tmp": "^0.2.1",
"tree-sitter-c": "github:amaanq/tree-sitter-c#napi",
"tree-sitter-embedded-template": "github:tree-sitter/tree-sitter-embedded-template#napi",
Expand All @@ -32,17 +46,16 @@
"tree-sitter-javascript": "github:amaanq/tree-sitter-javascript#napi",
"tree-sitter-json": "github:tree-sitter/tree-sitter-json#napi",
"tree-sitter-python": "github:amaanq/tree-sitter-python#napi",
"tree-sitter-rust": "github:amaanq/tree-sitter-rust#napi",
"tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#napi"
"tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#napi",
"tree-sitter-rust": "github:amaanq/tree-sitter-rust#napi"
},
"scripts": {
"install": "prebuild-install -r napi || node-gyp rebuild",
"build": "node-gyp build",
"install": "node-gyp-build",
"build": "prebuildify --napi --strip",
"rebuild": "node-gyp rebuild",
"test": "mocha"
},
"binary": {
"napi_versions": [
8
]
"publishConfig": {
"access": "public"
}
}

0 comments on commit 414d4d8

Please sign in to comment.