-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (141 loc) · 4.91 KB
/
release-cli-napi.yml
File metadata and controls
163 lines (141 loc) · 4.91 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Release CLI Napi Packages
concurrency:
group: ${{ github.workflow }}-${{ inputs.version || github.run_id }}
cancel-in-progress: false
on:
workflow_call:
inputs:
version:
required: true
type: string
workflow_dispatch:
inputs:
version:
description: 'Version to release (without v prefix, e.g. 2026.10222.0)'
required: true
type: string
permissions:
contents: read
jobs:
build-napi:
strategy:
fail-fast: false
matrix:
target:
- os: ubuntu-24.04
rust: x86_64-unknown-linux-gnu
suffix: linux-x64-gnu
- os: ubuntu-24.04
rust: aarch64-unknown-linux-gnu
suffix: linux-arm64-gnu
cross: true
- os: macos-14
rust: aarch64-apple-darwin
suffix: darwin-arm64
- os: macos-14
rust: x86_64-apple-darwin
suffix: darwin-x64
- os: windows-latest
rust: x86_64-pc-windows-msvc
suffix: win32-x64-msvc
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 25
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target.rust }}
- name: Install cross-compilation tools (aarch64-linux)
if: matrix.target.cross
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Cache cargo registry & target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target.rust }}-cargo-napi-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target.rust }}-cargo-napi-
- name: Build all napi libraries
shell: bash
run: |
for lib in logger md-compiler config init-bundle; do
echo "Building napi for $lib..."
(cd "libraries/$lib" && pnpm exec napi build --platform --release --target ${{ matrix.target.rust }} --output-dir dist -- --features napi)
done
- name: Collect .node files into CLI platform package
shell: bash
run: |
target_dir="cli/npm/${{ matrix.target.suffix }}"
for lib in logger md-compiler config init-bundle; do
cp libraries/$lib/dist/*.node "$target_dir/"
done
echo "Contents of $target_dir:"
ls -la "$target_dir/"
- name: Upload CLI platform package
uses: actions/upload-artifact@v4
with:
name: cli-napi-${{ matrix.target.suffix }}
path: cli/npm/${{ matrix.target.suffix }}/
if-no-files-found: error
publish-cli-napi:
needs: build-napi
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 25
registry-url: https://registry.npmjs.org/
- name: Download all platform artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: cli-napi-*
- name: Distribute artifacts to cli/npm/ directories
shell: bash
run: |
for artifact_dir in artifacts/cli-napi-*/; do
suffix=$(basename "$artifact_dir" | sed 's/cli-napi-//')
target_dir="cli/npm/${suffix}"
echo "Copying from ${artifact_dir} to ${target_dir}"
cp "${artifact_dir}"*.node "$target_dir/" || { echo "ERROR: no .node files found in ${artifact_dir}"; exit 1; }
done
- name: Publish CLI platform sub-packages
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for dir in cli/npm/*/; do
if [ -f "${dir}package.json" ]; then
echo "Publishing ${dir}..."
(cd "$dir" && pnpm publish --access public --no-git-checks) || echo "⚠️ Failed to publish ${dir}, may already exist"
fi
done