Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 141550e

Browse files
authored
ci: fix npm napi release (#257)
1 parent 2262c33 commit 141550e

File tree

39 files changed

+419
-3045
lines changed

39 files changed

+419
-3045
lines changed

.github/workflows/napi-release.yaml

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: release conductor 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+
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: ubuntu-latest
34+
target: x86_64-unknown-linux-gnu
35+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
36+
build: |-
37+
set -e &&
38+
yarn build --target x86_64-unknown-linux-gnu &&
39+
strip *.node
40+
name: stable - ${{ matrix.settings.target }} - node@18
41+
runs-on: ${{ matrix.settings.host }}
42+
defaults:
43+
run:
44+
working-directory: libs/napi
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Setup node
48+
uses: actions/setup-node@v4
49+
if: ${{ !matrix.settings.docker }}
50+
with:
51+
node-version: 18
52+
- name: Install
53+
uses: dtolnay/rust-toolchain@stable
54+
if: ${{ !matrix.settings.docker }}
55+
with:
56+
toolchain: stable
57+
targets: ${{ matrix.settings.target }}
58+
- name: Cache cargo
59+
uses: actions/cache@v3
60+
with:
61+
path: |
62+
~/.cargo/registry/index/
63+
~/.cargo/registry/cache/
64+
~/.cargo/git/db/
65+
.cargo-cache
66+
target/
67+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
68+
- uses: goto-bus-stop/setup-zig@v2
69+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
70+
with:
71+
version: 0.11.0
72+
- name: Setup toolchain
73+
run: ${{ matrix.settings.setup }}
74+
if: ${{ matrix.settings.setup }}
75+
shell: bash
76+
- name: Install dependencies
77+
run: yarn install
78+
- name: Build in docker
79+
uses: addnab/docker-run-action@v3
80+
if: ${{ matrix.settings.docker }}
81+
with:
82+
image: ${{ matrix.settings.docker }}
83+
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'
84+
run: ${{ matrix.settings.build }}
85+
- name: Build
86+
run: ${{ matrix.settings.build }}
87+
if: ${{ !matrix.settings.docker }}
88+
shell: bash
89+
- name: Upload artifact
90+
uses: actions/upload-artifact@v3
91+
with:
92+
name: bindings-${{ matrix.settings.target }}
93+
path: libs/napi/${{ env.APP_NAME }}.*.node
94+
if-no-files-found: error
95+
96+
publish:
97+
name: Publish
98+
runs-on: ubuntu-latest
99+
defaults:
100+
run:
101+
working-directory: libs/napi
102+
steps:
103+
- uses: actions/checkout@v4
104+
- name: Setup node
105+
uses: actions/setup-node@v4
106+
with:
107+
node-version: 18
108+
109+
- name: Install dependencies
110+
run: yarn install
111+
- name: Download all artifacts
112+
uses: actions/download-artifact@v3
113+
with:
114+
path: artifacts
115+
- name: Move artifacts
116+
run: yarn artifacts
117+
- name: List packages
118+
run: ls -R ./npm
119+
shell: bash
120+
- name: Publish
121+
run: |
122+
npm config set provenance true
123+
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
124+
then
125+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
126+
npm publish --access public
127+
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
128+
then
129+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
130+
npm publish --tag next --access public
131+
else
132+
echo "Not a release, skipping publish"
133+
fi
134+
env:
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yaml

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
name: release
2-
1+
name: release conductor
2+
3+
# on:
4+
# push:
5+
# branches:
6+
# - master
7+
# - main
8+
# pull_request:
9+
# release:
10+
# types: [created]
311
on:
412
push:
513
branches:
614
- master
7-
- main
815
pull_request:
916
release:
1017
types: [created]

Cargo.lock

+38-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/napi/.cargo/config.toml

-3
This file was deleted.

0 commit comments

Comments
 (0)