-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (81 loc) · 2.94 KB
/
javascript.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: javascript
on:
push:
branches:
- ci
- stable
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- runner: ubuntu-latest
target: linux-x64-gnu
- runner: windows-latest
target: win32-x64
#- runner: macos-14
# target: darwin-arm64
#- runner: macos-12
# target: darwin-64
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install
working-directory: dist/js/publish
- run: npx napi build --cargo-cwd=../../.. --platform --release --features=js --strip
working-directory: dist/js/publish
- uses: actions/upload-artifact@v4
with:
name: codemp-js-${{ matrix.platform.target }}
path: dist/js/publish/codemp.*.node
publish:
runs-on: ubuntu-latest
needs: [build]
steps:
# TODO we need index.d.ts and index.js but those get auto generated with napi build
# we could upload them from one of the previous runs but its messy, so we'll waste
# some github resources and build another time here, discarding the binary
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- run: npm install
working-directory: dist/js/publish
- run: npx napi build --cargo-cwd=../../.. --platform --features=js
working-directory: dist/js/publish
- run: rm *.node
working-directory: dist/js/publish
- run: npx napi create-npm-dir -t .
working-directory: dist/js/publish
- uses: actions/download-artifact@v4
with:
path: dist/js/publish/artifacts
pattern: codemp-js-*
- run: npx napi artifacts
working-directory: dist/js/publish
- run: npx napi prepublish -t . --skip-gh-release
working-directory: dist/js/publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: rm -rf *.node artifacts node_modules
working-directory: dist/js/publish
# TODO this is a bit awful, but napi just appends the platform triplet to the resulting package name
# however we want '@codemp/native-...' and 'codemp' (because otherwise it gets flagged as spam)
# so we just sed out before releasing. this is really ugly but if it works right now i'll just
# take it and think again about it later
- run: sed -i 's/"@codemp\/native"/"codemp"/' package.json
- run: npm publish
working-directory: dist/js/publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}