Skip to content

Commit 753da82

Browse files
committed
fix
1 parent 8705b41 commit 753da82

File tree

9 files changed

+409
-704
lines changed

9 files changed

+409
-704
lines changed

.github/workflows/napi-release.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: release napi to npm
2+
env:
3+
DEBUG: napi:*
4+
APP_NAME: lib
5+
MACOSX_DEPLOYMENT_TARGET: "10.13"
6+
permissions:
7+
contents: write
8+
id-token: write
9+
on:
10+
release:
11+
types: [created]
12+
jobs:
13+
build:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
settings:
18+
- host: macos-latest
19+
target: x86_64-apple-darwin
20+
build: |
21+
yarn build
22+
strip -x *.node
23+
- host: ubuntu-latest
24+
target: x86_64-unknown-linux-gnu
25+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
26+
build: |-
27+
set -e &&
28+
yarn build --target x86_64-unknown-linux-gnu &&
29+
strip *.node
30+
- host: macos-latest-xlarge
31+
target: aarch64-apple-darwin
32+
build: |
33+
yarn build --target aarch64-apple-darwin
34+
strip -x *.node
35+
name: stable - ${{ matrix.settings.target }} - node@18
36+
runs-on: ${{ matrix.settings.host }}
37+
defaults:
38+
run:
39+
working-directory: libs/napi
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Setup node
46+
uses: actions/setup-node@v4
47+
if: ${{ !matrix.settings.docker }}
48+
with:
49+
node-version: 18
50+
- name: Install
51+
uses: dtolnay/rust-toolchain@stable
52+
if: ${{ !matrix.settings.docker }}
53+
with:
54+
toolchain: stable
55+
targets: ${{ matrix.settings.target }}
56+
- name: Cache cargo
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
~/.cargo/registry/index/
61+
~/.cargo/registry/cache/
62+
~/.cargo/git/db/
63+
.cargo-cache
64+
target/
65+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
66+
- uses: goto-bus-stop/setup-zig@v2
67+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
68+
with:
69+
version: 0.11.0
70+
- name: Setup toolchain
71+
run: ${{ matrix.settings.setup }}
72+
if: ${{ matrix.settings.setup }}
73+
shell: bash
74+
- name: Install dependencies
75+
run: yarn install
76+
- name: Build in docker
77+
uses: addnab/docker-run-action@v3
78+
if: ${{ matrix.settings.docker }}
79+
with:
80+
image: ${{ matrix.settings.docker }}
81+
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/libs/napi"
82+
run: ${{ matrix.settings.build }}
83+
- name: Build
84+
run: ${{ matrix.settings.build }}
85+
if: ${{ !matrix.settings.docker }}
86+
shell: bash
87+
- name: Upload artifact
88+
uses: actions/upload-artifact@v3
89+
with:
90+
name: bindings-${{ matrix.settings.target }}
91+
path: libs/napi/${{ env.APP_NAME }}.*.node
92+
if-no-files-found: error
93+
94+
publish:
95+
name: publish to npm
96+
runs-on: ubuntu-latest
97+
needs:
98+
- build
99+
steps:
100+
- uses: actions/checkout@v4
101+
- name: setup node
102+
uses: actions/setup-node@v4
103+
with:
104+
node-version: 18
105+
106+
- name: install dependencies (lib)
107+
run: yarn install
108+
working-directory: libs/napi
109+
110+
- name: Download all artifacts
111+
uses: actions/download-artifact@v3
112+
with:
113+
path: libs/napi/artifacts
114+
115+
- name: Move artifacts
116+
run: yarn artifacts
117+
working-directory: libs/napi
118+
119+
- name: List packages
120+
run: ls -R ./npm
121+
shell: bash
122+
working-directory: libs/napi
123+
124+
- name: Update version to match release tag and commit
125+
run: |
126+
TAG_NAME=${GITHUB_REF#refs/tags/}
127+
cd libs/napi
128+
npm version $TAG_NAME --no-git-tag-version
129+
cd ../../
130+
cd bin/npm
131+
npm version $TAG_NAME --no-git-tag-version
132+
git config user.name "github-actions"
133+
git config user.email "[email protected]"
134+
git add .
135+
git commit -m "ci: bump napi packages' versions to $TAG_NAME"
136+
env:
137+
GITHUB_REF: ${{ github.ref }}
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
140+
- name: publish lib
141+
working-directory: libs/napi
142+
run: |
143+
npm config set provenance true
144+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
145+
npm publish --access public
146+
env:
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
149+
150+
- name: publish bin
151+
working-directory: bin/npm
152+
run: |
153+
TAG_NAME=${GITHUB_REF#refs/tags/}
154+
npm install --save-exact @graph-tooling/lib@$TAG_NAME
155+
npm config set provenance true
156+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
157+
npm publish --access public
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)