Skip to content

Commit ae6d5f1

Browse files
[fix] update napi
1 parent 6a4f947 commit ae6d5f1

File tree

10 files changed

+365
-34
lines changed

10 files changed

+365
-34
lines changed

.github/workflows/napi.yml

+8-34
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@ env:
33
DEBUG: napi:*
44
APP_NAME: ast-grep-napi
55
MACOSX_DEPLOYMENT_TARGET: '10.13'
6-
'on':
6+
on:
77
push:
8-
branches:
9-
- main
10-
tags-ignore:
11-
- '**'
12-
paths-ignore:
13-
- '**/*.md'
14-
- LICENSE
15-
- '**/*.gitignore'
16-
- .editorconfig
17-
- docs/**
18-
pull_request: null
8+
tags:
9+
- "[0-9]+.*"
10+
workflow_dispatch: null
11+
schedule:
12+
# run napi every day 9 am
13+
- cron: '0 9 * * *'
14+
1915
defaults:
2016
run:
2117
working-directory: ./crates/napi
@@ -37,11 +33,6 @@ jobs:
3733
yarn build
3834
yarn test
3935
target: x86_64-pc-windows-msvc
40-
- host: windows-latest
41-
build: |
42-
yarn build --target i686-pc-windows-msvc
43-
yarn test
44-
target: i686-pc-windows-msvc
4536
- host: ubuntu-latest
4637
target: x86_64-unknown-linux-gnu
4738
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
@@ -57,10 +48,6 @@ jobs:
5748
build: |
5849
yarn build --target aarch64-apple-darwin
5950
strip -x *.node
60-
- host: windows-latest
61-
target: aarch64-pc-windows-msvc
62-
build: |
63-
yarn build --target aarch64-pc-windows-msvc
6451
name: stable - ${{ matrix.settings.target }} - node@16
6552
runs-on: ${{ matrix.settings.host }}
6653
steps:
@@ -100,21 +87,8 @@ jobs:
10087
run: ${{ matrix.settings.setup }}
10188
if: ${{ matrix.settings.setup }}
10289
shell: bash
103-
- name: Setup node x86
104-
if: matrix.settings.target == 'i686-pc-windows-msvc'
105-
run: yarn config set supportedArchitectures.cpu "ia32"
106-
shell: bash
10790
- name: Install dependencies
10891
run: yarn install
109-
- name: Setup node x86
110-
uses: actions/setup-node@v3
111-
if: matrix.settings.target == 'i686-pc-windows-msvc'
112-
with:
113-
node-version: 16
114-
check-latest: true
115-
cache: yarn
116-
cache-dependency-path: ./crates/napi/yarn.lock
117-
architecture: x86
11892
- name: Build in docker
11993
uses: addnab/docker-run-action@v3
12094
if: ${{ matrix.settings.docker }}

.github/workflows/npm.yml

+242
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
name: Release npm cli
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
build:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
# Windows
12+
- os: windows-latest
13+
target: x86_64-pc-windows-msvc
14+
binary: parcel_css.exe
15+
# Mac OS
16+
- os: macos-latest
17+
target: x86_64-apple-darwin
18+
strip: strip -x # Must use -x on macOS. This produces larger results on linux.
19+
binary: parcel_css
20+
21+
name: build-${{ matrix.target }}
22+
runs-on: ${{ matrix.os }}
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Install Node.JS
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: 14
29+
- name: Install Rust
30+
uses: actions-rs/toolchain@v1
31+
with:
32+
toolchain: stable
33+
profile: minimal
34+
override: true
35+
36+
- name: Setup rust target
37+
run: rustup target add ${{ matrix.target }}
38+
39+
- uses: bahmutov/[email protected]
40+
- name: Build release
41+
run: yarn build-release
42+
env:
43+
RUST_TARGET: ${{ matrix.target }}
44+
- name: Build CLI
45+
run: |
46+
cargo build --release --features cli --target ${{ matrix.target }}
47+
node -e "require('fs').renameSync('target/${{ matrix.target }}/release/${{ matrix.binary }}', '${{ matrix.binary }}')"
48+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
49+
if: ${{ matrix.strip }}
50+
run: ${{ matrix.strip }} *.node ${{ matrix.binary }}
51+
- name: Upload artifacts
52+
uses: actions/upload-artifact@v2
53+
with:
54+
name: bindings-${{ matrix.target }}
55+
path: |
56+
*.node
57+
${{ matrix.binary }}
58+
build-apple-silicon:
59+
name: build-apple-silicon
60+
runs-on: macos-latest
61+
steps:
62+
- uses: actions/checkout@v2
63+
- name: Install Node.JS
64+
uses: actions/setup-node@v2
65+
with:
66+
node-version: 14
67+
- name: Install Rust
68+
uses: actions-rs/toolchain@v1
69+
with:
70+
toolchain: stable
71+
profile: minimal
72+
override: true
73+
74+
- name: Setup rust target
75+
run: rustup target add aarch64-apple-darwin
76+
77+
- uses: bahmutov/[email protected]
78+
- name: Build release
79+
run: yarn build-release
80+
env:
81+
RUST_TARGET: aarch64-apple-darwin
82+
JEMALLOC_SYS_WITH_LG_PAGE: 14
83+
- name: Build CLI
84+
run: |
85+
export CC=$(xcrun -f clang);
86+
export CXX=$(xcrun -f clang++);
87+
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
88+
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
89+
export MACOSX_DEPLOYMENT_TARGET="10.9";
90+
cargo build --release --features cli --target aarch64-apple-darwin
91+
mv target/aarch64-apple-darwin/release/parcel_css parcel_css
92+
env:
93+
JEMALLOC_SYS_WITH_LG_PAGE: 14
94+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
95+
run: strip -x *.node parcel_css
96+
- name: Upload artifacts
97+
uses: actions/upload-artifact@v2
98+
with:
99+
name: bindings-aarch64-apple-darwin
100+
path: |
101+
*.node
102+
parcel_css
103+
build-linux:
104+
strategy:
105+
fail-fast: false
106+
matrix:
107+
include:
108+
- target: x86_64-unknown-linux-gnu
109+
strip: strip
110+
image: docker.io/centos/nodejs-12-centos7
111+
setup: npm install --global yarn@1
112+
- target: aarch64-unknown-linux-gnu
113+
strip: aarch64-linux-gnu-strip
114+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
115+
setup: apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
116+
- target: armv7-unknown-linux-gnueabihf
117+
strip: arm-linux-gnueabihf-strip
118+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
119+
setup: apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
120+
- target: aarch64-unknown-linux-musl
121+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
122+
strip: aarch64-linux-musl-strip
123+
- target: x86_64-unknown-linux-musl
124+
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
125+
strip: strip
126+
127+
name: build-${{ matrix.target }}
128+
runs-on: ubuntu-latest
129+
container:
130+
image: ${{ matrix.image }}
131+
132+
steps:
133+
- uses: actions/checkout@v2
134+
- name: Install Node.JS
135+
uses: actions/setup-node@v2
136+
with:
137+
node-version: 14
138+
- name: Install Rust
139+
uses: actions-rs/toolchain@v1
140+
with:
141+
toolchain: stable
142+
profile: minimal
143+
override: true
144+
145+
- name: Setup cross compile toolchain
146+
if: ${{ matrix.setup }}
147+
run: ${{ matrix.setup }}
148+
149+
- name: Setup rust target
150+
run: rustup target add ${{ matrix.target }}
151+
152+
- uses: bahmutov/[email protected]
153+
- name: Build release
154+
run: yarn build-release
155+
env:
156+
RUST_TARGET: ${{ matrix.target }}
157+
- name: Build CLI
158+
run: |
159+
cargo build --release --features cli --target ${{ matrix.target }}
160+
mv target/${{ matrix.target }}/release/parcel_css parcel_css
161+
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
162+
if: ${{ matrix.strip }}
163+
run: ${{ matrix.strip }} *.node parcel_css
164+
- name: Upload artifacts
165+
uses: actions/upload-artifact@v2
166+
with:
167+
name: bindings-${{ matrix.target }}
168+
path: |
169+
*.node
170+
parcel_css
171+
build-wasm:
172+
runs-on: ubuntu-latest
173+
steps:
174+
- uses: actions/checkout@v2
175+
- name: Install Node.JS
176+
uses: actions/setup-node@v2
177+
with:
178+
node-version: 14
179+
- name: Install wasm-pack
180+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
181+
- name: Build wasm
182+
run: yarn wasm-browser:build-release
183+
- name: Upload artifacts
184+
uses: actions/upload-artifact@v2
185+
with:
186+
name: wasm
187+
path: node/pkg
188+
189+
release:
190+
runs-on: ubuntu-latest
191+
name: Build and release
192+
needs:
193+
- build
194+
- build-linux
195+
- build-apple-silicon
196+
- build-wasm
197+
steps:
198+
- uses: actions/checkout@v1
199+
- uses: bahmutov/[email protected]
200+
- name: Download artifacts
201+
uses: actions/download-artifact@v2
202+
with:
203+
path: artifacts
204+
- name: Build npm packages
205+
run: |
206+
node scripts/build-npm.js
207+
node scripts/build-wasm.js
208+
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > ~/.npmrc
209+
env:
210+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
211+
- name: Publish to npm
212+
run: |
213+
for pkg in npm/*; do
214+
echo "Publishing $pkg..."
215+
cd $pkg;
216+
npm publish;
217+
cd ../..;
218+
done
219+
cd cli
220+
echo "Publishing @parcel/css-cli...";
221+
npm publish
222+
cd ..
223+
echo "Publishing @parcel/css...";
224+
npm publish
225+
release-crates:
226+
runs-on: ubuntu-latest
227+
name: Release Rust crate
228+
steps:
229+
- uses: actions/checkout@v1
230+
- uses: bahmutov/[email protected]
231+
- name: Install Rust
232+
uses: actions-rs/toolchain@v1
233+
with:
234+
toolchain: stable
235+
profile: minimal
236+
override: true
237+
- run: cargo login ${CRATES_IO_TOKEN}
238+
env:
239+
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
240+
- run: |
241+
cargo install cargo-workspaces
242+
cargo workspaces publish --from-git -y

npm/darwin-arm64/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@ast-grep/cli-darwin-arm64`
2+
3+
This is the **aarch64-apple-darwin** binary for `@ast-grep/cli`

npm/darwin-arm64/package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@ast-grep/cli-darwin-arm64",
3+
"version": "0.1.0",
4+
"os": [
5+
"darwin"
6+
],
7+
"cpu": [
8+
"arm64"
9+
],
10+
"main": "ast-grep-cli.darwin-arm64.node",
11+
"files": [
12+
"ast-grep-cli.darwin-arm64.node"
13+
],
14+
"description": "Search and Rewrite code at large scale using precise AST pattern",
15+
"keywords": ["ast", "pattern", "codemod", "search", "rewrite"],
16+
"license": "MIT",
17+
"engines": {
18+
"node": ">= 10"
19+
},
20+
"publishConfig": {
21+
"registry": "https://registry.npmjs.org/",
22+
"access": "public"
23+
},
24+
"repository": "https://github.com/HerringtonDarkholme/ast-grep"
25+
}

npm/darwin-x64/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@ast-grep/cli-darwin-x64`
2+
3+
This is the **x86_64-apple-darwin** binary for `@ast-grep/cli`

npm/darwin-x64/package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@ast-grep/cli-darwin-x64",
3+
"version": "0.1.0",
4+
"os": [
5+
"darwin"
6+
],
7+
"cpu": [
8+
"x64"
9+
],
10+
"main": "ast-grep-cli.darwin-x64.node",
11+
"files": [
12+
"ast-grep-cli.darwin-x64.node"
13+
],
14+
"description": "Search and Rewrite code at large scale using precise AST pattern",
15+
"keywords": ["ast", "pattern", "codemod", "search", "rewrite"],
16+
"license": "MIT",
17+
"engines": {
18+
"node": ">= 10"
19+
},
20+
"publishConfig": {
21+
"registry": "https://registry.npmjs.org/",
22+
"access": "public"
23+
},
24+
"repository": "https://github.com/HerringtonDarkholme/ast-grep"
25+
}

npm/linux-x64-gnu/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@ast-grep/cli-linux-x64-gnu`
2+
3+
This is the **x86_64-unknown-linux-gnu** binary for `@ast-grep/cli`

0 commit comments

Comments
 (0)