Skip to content

Commit 6257e92

Browse files
committed
0.0.1 Stable relase
0 parents  commit 6257e92

33 files changed

+6387
-0
lines changed

.github/workflows/CI.yml

+258
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
name: CI
2+
env:
3+
DEBUG: napi:*
4+
APP_NAME: tokenizers
5+
MACOSX_DEPLOYMENT_TARGET: '10.13'
6+
permissions:
7+
contents: write
8+
id-token: write
9+
'on':
10+
push:
11+
branches:
12+
- main
13+
tags-ignore:
14+
- '**'
15+
paths-ignore:
16+
- '**/*.md'
17+
- LICENSE
18+
- '**/*.gitignore'
19+
- .editorconfig
20+
- docs/**
21+
pull_request: null
22+
jobs:
23+
build:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
settings:
28+
- host: macos-latest
29+
target: x86_64-apple-darwin
30+
build: |
31+
yarn build
32+
strip -x *.node
33+
- host: windows-latest
34+
build: yarn build
35+
target: x86_64-pc-windows-msvc
36+
- host: ubuntu-latest
37+
target: x86_64-unknown-linux-gnu
38+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
39+
build: |-
40+
set -e &&
41+
yarn build --target x86_64-unknown-linux-gnu &&
42+
strip *.node
43+
- host: macos-latest
44+
target: aarch64-apple-darwin
45+
build: |
46+
yarn build --target aarch64-apple-darwin
47+
strip -x *.node
48+
name: stable - ${{ matrix.settings.target }} - node@18
49+
runs-on: ${{ matrix.settings.host }}
50+
steps:
51+
- uses: actions/checkout@v3
52+
- name: Setup node
53+
uses: actions/setup-node@v3
54+
if: ${{ !matrix.settings.docker }}
55+
with:
56+
node-version: 18
57+
check-latest: true
58+
cache: yarn
59+
- name: Install
60+
uses: dtolnay/rust-toolchain@stable
61+
if: ${{ !matrix.settings.docker }}
62+
with:
63+
toolchain: stable
64+
targets: ${{ matrix.settings.target }}
65+
- name: Cache cargo
66+
uses: actions/cache@v3
67+
with:
68+
path: |
69+
~/.cargo/registry/index/
70+
~/.cargo/registry/cache/
71+
~/.cargo/git/db/
72+
.cargo-cache
73+
target/
74+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
75+
- uses: goto-bus-stop/setup-zig@v2
76+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
77+
with:
78+
version: 0.10.1
79+
- name: Setup toolchain
80+
run: ${{ matrix.settings.setup }}
81+
if: ${{ matrix.settings.setup }}
82+
shell: bash
83+
- name: Setup node x86
84+
if: matrix.settings.target == 'i686-pc-windows-msvc'
85+
run: yarn config set supportedArchitectures.cpu "ia32"
86+
shell: bash
87+
- name: Install dependencies
88+
run: yarn install
89+
- name: Setup node x86
90+
uses: actions/setup-node@v3
91+
if: matrix.settings.target == 'i686-pc-windows-msvc'
92+
with:
93+
node-version: 18
94+
check-latest: true
95+
cache: yarn
96+
architecture: x86
97+
- name: Build in docker
98+
uses: addnab/docker-run-action@v3
99+
if: ${{ matrix.settings.docker }}
100+
with:
101+
image: ${{ matrix.settings.docker }}
102+
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
103+
run: ${{ matrix.settings.build }}
104+
- name: Build
105+
run: ${{ matrix.settings.build }}
106+
if: ${{ !matrix.settings.docker }}
107+
shell: bash
108+
- name: Upload artifact
109+
uses: actions/upload-artifact@v3
110+
with:
111+
name: bindings-${{ matrix.settings.target }}
112+
path: ${{ env.APP_NAME }}.*.node
113+
if-no-files-found: error
114+
test-macOS-windows-binding:
115+
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
116+
needs:
117+
- build
118+
strategy:
119+
fail-fast: false
120+
matrix:
121+
settings:
122+
- host: macos-latest
123+
target: x86_64-apple-darwin
124+
- host: windows-latest
125+
target: x86_64-pc-windows-msvc
126+
node:
127+
- '14'
128+
- '16'
129+
- '18'
130+
runs-on: ${{ matrix.settings.host }}
131+
steps:
132+
- uses: actions/checkout@v3
133+
- name: Setup node
134+
uses: actions/setup-node@v3
135+
with:
136+
node-version: ${{ matrix.node }}
137+
check-latest: true
138+
cache: yarn
139+
- name: Install dependencies
140+
run: yarn install
141+
- name: Download artifacts
142+
uses: actions/download-artifact@v3
143+
with:
144+
name: bindings-${{ matrix.settings.target }}
145+
path: .
146+
- name: List packages
147+
run: ls -R .
148+
shell: bash
149+
- name: Test bindings
150+
run: yarn test
151+
test-linux-x64-gnu-binding:
152+
name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
153+
needs:
154+
- build
155+
strategy:
156+
fail-fast: false
157+
matrix:
158+
node:
159+
- '14'
160+
- '16'
161+
- '18'
162+
runs-on: ubuntu-latest
163+
steps:
164+
- uses: actions/checkout@v3
165+
- name: Setup node
166+
uses: actions/setup-node@v3
167+
with:
168+
node-version: ${{ matrix.node }}
169+
check-latest: true
170+
cache: yarn
171+
- name: Install dependencies
172+
run: yarn install
173+
- name: Download artifacts
174+
uses: actions/download-artifact@v3
175+
with:
176+
name: bindings-x86_64-unknown-linux-gnu
177+
path: .
178+
- name: List packages
179+
run: ls -R .
180+
shell: bash
181+
- name: Test bindings
182+
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim yarn test
183+
universal-macOS:
184+
name: Build universal macOS binary
185+
needs:
186+
- build
187+
runs-on: macos-latest
188+
steps:
189+
- uses: actions/checkout@v3
190+
- name: Setup node
191+
uses: actions/setup-node@v3
192+
with:
193+
node-version: 18
194+
check-latest: true
195+
cache: yarn
196+
- name: Install dependencies
197+
run: yarn install
198+
- name: Download macOS x64 artifact
199+
uses: actions/download-artifact@v3
200+
with:
201+
name: bindings-x86_64-apple-darwin
202+
path: artifacts
203+
- name: Download macOS arm64 artifact
204+
uses: actions/download-artifact@v3
205+
with:
206+
name: bindings-aarch64-apple-darwin
207+
path: artifacts
208+
- name: Combine binaries
209+
run: yarn universal
210+
- name: Upload artifact
211+
uses: actions/upload-artifact@v3
212+
with:
213+
name: bindings-universal-apple-darwin
214+
path: ${{ env.APP_NAME }}.*.node
215+
if-no-files-found: error
216+
publish:
217+
name: Publish
218+
runs-on: ubuntu-latest
219+
needs:
220+
- test-macOS-windows-binding
221+
- test-linux-x64-gnu-binding
222+
- universal-macOS
223+
steps:
224+
- uses: actions/checkout@v3
225+
- name: Setup node
226+
uses: actions/setup-node@v3
227+
with:
228+
node-version: 18
229+
check-latest: true
230+
cache: yarn
231+
- name: Install dependencies
232+
run: yarn install
233+
- name: Download all artifacts
234+
uses: actions/download-artifact@v3
235+
with:
236+
path: artifacts
237+
- name: Move artifacts
238+
run: yarn artifacts
239+
- name: List packages
240+
run: ls -R ./npm
241+
shell: bash
242+
- name: Publish
243+
run: |
244+
npm config set provenance true
245+
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
246+
then
247+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
248+
npm publish --access public
249+
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
250+
then
251+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
252+
npm publish --tag next --access public
253+
else
254+
echo "Not a release, skipping publish"
255+
fi
256+
env:
257+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
258+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)