-
Notifications
You must be signed in to change notification settings - Fork 26
232 lines (210 loc) · 7.36 KB
/
release.yml
File metadata and controls
232 lines (210 loc) · 7.36 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 0.2.0-rc.1)"
required: true
type: string
npm-tag:
description: "npm dist-tag"
required: true
type: choice
options:
- latest
- rc
concurrency:
group: release
cancel-in-progress: false
jobs:
# Build V8 sidecar binaries for all platforms
build-v8:
name: "Build V8 (${{ matrix.npm-dir }})"
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
npm-dir: linux-x64-gnu
binary: secure-exec-v8
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
npm-dir: linux-arm64-gnu
binary: secure-exec-v8
cross: true
- target: x86_64-apple-darwin
os: macos-latest
npm-dir: darwin-x64
binary: secure-exec-v8
- target: aarch64-apple-darwin
os: macos-latest
npm-dir: darwin-arm64
binary: secure-exec-v8
runs-on: ${{ matrix.os }}
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: v${{ inputs.version }}
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.85.0"
targets: ${{ matrix.target }}
- name: Cache Rust build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
native/v8-runtime/target
key: rust-release-${{ matrix.target }}-${{ hashFiles('native/v8-runtime/Cargo.lock') }}
restore-keys: |
rust-release-${{ matrix.target }}-
- name: Install cross-compilation tools
if: matrix.cross
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Configure cross-compilation linker
if: matrix.cross
working-directory: native/v8-runtime
run: |
mkdir -p .cargo
cat > .cargo/config.toml <<'EOF'
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
- name: Build
working-directory: native/v8-runtime
run: cargo build --release --target ${{ matrix.target }}
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: v8-${{ matrix.npm-dir }}
path: native/v8-runtime/target/${{ matrix.target }}/release/${{ matrix.binary }}
# Publish all packages to npm after V8 binaries are built
publish:
name: "Publish"
needs: [build-v8]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: v${{ inputs.version }}
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.6
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Build
run: pnpm turbo build
- name: Type check
run: pnpm turbo check-types
# Download all V8 platform binaries into their npm package dirs
- name: Download V8 binaries
uses: actions/download-artifact@v4
with:
pattern: v8-*
path: native/v8-runtime/npm
- name: Place V8 binaries
run: |
# Move downloaded artifacts into their platform package dirs
for dir in native/v8-runtime/npm/v8-*/; do
PLATFORM_DIR=$(basename "$dir" | sed 's/^v8-//')
TARGET_DIR="native/v8-runtime/npm/${PLATFORM_DIR}"
if [ -d "$TARGET_DIR" ]; then
cp "$dir"/* "$TARGET_DIR/"
find "$TARGET_DIR" -name "secure-exec-v8" -exec chmod +x {} \;
echo "✓ Placed binary in ${TARGET_DIR}"
fi
done
# Verify each built artifact was placed
echo "--- Binary verification ---"
for dir in native/v8-runtime/npm/v8-*/; do
PLATFORM_DIR=$(basename "$dir" | sed 's/^v8-//')
TARGET_DIR="native/v8-runtime/npm/${PLATFORM_DIR}"
if ls "$TARGET_DIR"/secure-exec-v8* 1>/dev/null 2>&1; then
echo "✓ ${PLATFORM_DIR}: $(ls "$TARGET_DIR"/secure-exec-v8*)"
else
echo "✗ ${PLATFORM_DIR}: MISSING BINARY"
exit 1
fi
done
- name: Publish to npm
run: |
FAILURES=""
# Publish workspace packages
for dir in $(pnpm -r ls --json --depth -1 | jq -r '.[] | select(.private != true) | .path'); do
# Skip the root package
if [ "$dir" = "$(pwd)" ]; then
continue
fi
NAME=$(jq -r .name "$dir/package.json")
VERSION="${{ inputs.version }}"
if npm view "${NAME}@${VERSION}" version >/dev/null 2>&1; then
echo "⏭ ${NAME}@${VERSION} already published, skipping."
continue
fi
echo "Publishing ${NAME}@${VERSION}..."
if ! (cd "$dir" && pnpm publish --access public --tag ${{ inputs.npm-tag }} --no-git-checks); then
FAILURES="${FAILURES} ${NAME}"
fi
done
# Publish v8 platform packages that have binaries (built by matrix)
for dir in native/v8-runtime/npm/*/; do
if [ ! -f "$dir/package.json" ]; then
continue
fi
PLATFORM=$(basename "$dir")
# Skip artifact staging dirs and platforms without binaries
if [[ "$PLATFORM" == v8-* ]]; then continue; fi
if ! ls "$dir"secure-exec-v8* 1>/dev/null 2>&1; then
echo "⏭ ${PLATFORM}: no binary, skipping publish."
continue
fi
NAME=$(jq -r .name "$dir/package.json")
VERSION="${{ inputs.version }}"
if npm view "${NAME}@${VERSION}" version >/dev/null 2>&1; then
echo "⏭ ${NAME}@${VERSION} already published, skipping."
continue
fi
echo "Publishing ${NAME}@${VERSION}..."
if ! (cd "$dir" && npm publish --access public --tag ${{ inputs.npm-tag }}); then
FAILURES="${FAILURES} ${NAME}"
fi
done
if [ -n "$FAILURES" ]; then
echo "::error::Failed to publish:${FAILURES}"
exit 1
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub release
run: |
if gh release view "v${{ inputs.version }}" >/dev/null 2>&1; then
echo "GitHub release v${{ inputs.version }} already exists, skipping."
else
PRERELEASE=""
if [ "${{ inputs.npm-tag }}" = "rc" ]; then
PRERELEASE="--prerelease"
fi
gh release create "v${{ inputs.version }}" \
--title "v${{ inputs.version }}" \
--generate-notes \
$PRERELEASE
fi
env:
GH_TOKEN: ${{ github.token }}