Skip to content

Commit 0da6fca

Browse files
committed
Add package workflow to inspect before publish
1 parent 98ddfe7 commit 0da6fca

File tree

3 files changed

+217
-2
lines changed

3 files changed

+217
-2
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
strategy:
6363
matrix:
6464
node-version: [18, 20, 22]
65-
os: [ubuntu-20.04, macos-13, macos-14, windows-2019]
65+
os: [ubuntu-22.04, macos-13, macos-14, windows-2019]
6666

6767
name: Test for node-${{ matrix.node-version }} on ${{ matrix.os }}
6868
runs-on: ${{ matrix.os }}

.github/workflows/package.yml

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
name: Publish package
2+
3+
on:
4+
push:
5+
6+
workflow_dispatch:
7+
inputs:
8+
new-version:
9+
description: New version to be published, overrides tag
10+
required: true
11+
type: string
12+
13+
npm-tag:
14+
description: NPM tag
15+
required: true
16+
default: latest
17+
type: choice
18+
options:
19+
- latest
20+
- next
21+
22+
jobs:
23+
build:
24+
strategy:
25+
matrix:
26+
include:
27+
- os: ubuntu-22.04
28+
arch: linux-x64-glibc
29+
- os: macos-13
30+
arch: darwin-x64
31+
- os: macos-14
32+
arch: darwin-arm64
33+
- os: windows-2019
34+
arch: win32-x64
35+
36+
name: Build for ${{ matrix.arch }}
37+
runs-on: ${{ matrix.os }}
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
submodules: true
44+
45+
- name: Use Node.js 20
46+
uses: actions/setup-node@v4
47+
with:
48+
cache: npm
49+
node-version: 20
50+
51+
- name: Install dependencies
52+
run: npm ci
53+
54+
- name: Prebuild
55+
run: npm run build
56+
57+
- name: Upload artifacts
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: prebuild-${{ matrix.arch }}
61+
path: prebuilds/**/*.node
62+
63+
build-linux-arm64-glibc:
64+
name: Build for linux-arm64-glibc
65+
runs-on: buildjet-2vcpu-ubuntu-2204-arm
66+
67+
container:
68+
image: node:20-bullseye
69+
70+
steps:
71+
- name: Install build deps
72+
run: apt update -yq && apt install -yq g++ git make python3
73+
74+
- name: Checkout
75+
uses: actions/checkout@v4
76+
with:
77+
submodules: true
78+
79+
- name: Install dependencies
80+
run: npm ci
81+
82+
- name: Prebuild
83+
run: npm run build
84+
85+
- name: Upload artifacts
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: prebuild-linux-arm64-glibc
89+
path: prebuilds/**/*.node
90+
91+
build-linux-x64-musl:
92+
name: Build for linux-x64-musl
93+
runs-on: ubuntu-latest
94+
95+
container:
96+
image: node:20-alpine
97+
98+
steps:
99+
- name: Install build deps
100+
run: apk add --no-cache g++ git make python3
101+
102+
- name: Checkout
103+
uses: actions/checkout@v4
104+
with:
105+
submodules: true
106+
107+
- name: Install dependencies
108+
run: npm ci
109+
110+
- name: Prebuild
111+
run: npm run build
112+
113+
- name: Upload artifacts
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: prebuild-linux-x64-musl
117+
path: prebuilds/**/*.node
118+
119+
build-linux-arm64-musl:
120+
name: Build for linux-arm64-musl
121+
runs-on: ubuntu-latest
122+
123+
steps:
124+
- name: Checkout
125+
uses: actions/checkout@v4
126+
with:
127+
submodules: true
128+
129+
- name: Prebuild
130+
uses: uraimo/run-on-arch-action@v2
131+
with:
132+
arch: aarch64
133+
distro: alpine_latest
134+
dockerRunArgs: --volume "${PWD}:/repo" --workdir /repo
135+
install: |
136+
apk add --update make g++ python3
137+
apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/v3.19/main/ nodejs~=20 npm
138+
run: |
139+
npm ci
140+
npm run build
141+
142+
- name: Upload artifacts
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: prebuild-linux-arm64-musl
146+
path: prebuilds/**/*.node
147+
148+
build-freebsd-x64:
149+
name: Build for freebsd-x64
150+
runs-on: ubuntu-latest
151+
152+
steps:
153+
- name: Checkout
154+
uses: actions/checkout@v4
155+
with:
156+
submodules: true
157+
158+
- name: Prebuild
159+
uses: vmactions/freebsd-vm@v1
160+
with:
161+
prepare: |
162+
pkg install -y gmake python3 npm-node20
163+
run: |
164+
npm ci
165+
npm run build
166+
sync: sshfs
167+
168+
- name: Upload artifacts
169+
uses: actions/upload-artifact@v4
170+
with:
171+
name: prebuild-freebsd-x64
172+
path: prebuilds/**/*.node
173+
174+
publish:
175+
name: Upload package artifact
176+
runs-on: ubuntu-latest
177+
178+
needs:
179+
- build
180+
- build-freebsd-x64
181+
- build-linux-arm64-glibc
182+
- build-linux-arm64-musl
183+
- build-linux-x64-musl
184+
185+
steps:
186+
- name: Checkout
187+
uses: actions/checkout@v4
188+
with:
189+
submodules: true
190+
191+
- name: Setup npm with Node.js 20
192+
uses: actions/setup-node@v4
193+
with:
194+
cache: npm
195+
node-version: 20
196+
token: ${{ secrets.NPM_TOKEN }}
197+
registry-url: 'https://registry.npmjs.org'
198+
199+
- name: Install dependencies
200+
run: npm ci --ignore-scripts
201+
202+
- name: Download artifacts
203+
id: download-artifact
204+
uses: actions/download-artifact@v4
205+
206+
- name: Move prebuild artifacts
207+
run: mkdir prebuilds && cp --recursive prebuild-*/* prebuilds/
208+
209+
- name: Pack package
210+
run: npm pack
211+
212+
- name: Upload package artifact
213+
uses: actions/upload-artifact@v4
214+
with:
215+
path: '*.tgz'

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
matrix:
2727
include:
28-
- os: ubuntu-20.04
28+
- os: ubuntu-22.04
2929
arch: linux-x64-glibc
3030
- os: macos-13
3131
arch: darwin-x64

0 commit comments

Comments
 (0)