forked from NVIDIA/OpenShell
-
Notifications
You must be signed in to change notification settings - Fork 0
302 lines (270 loc) · 11.9 KB
/
Copy pathopenlock-release.yml
File metadata and controls
302 lines (270 loc) · 11.9 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: openlock release
# Fork-specific release workflow. Builds the openshell binaries that
# openlock needs (openshell-gateway, openshell-sandbox, openshell CLI)
# on public GitHub-hosted runners, attaches them to a GitHub Release.
#
# Distinct from upstream's release-tag.yml which targets NVIDIA's
# self-hosted infrastructure (custom runners, NVIDIA GHCR, debian
# packaging, fern docs, GitLab triggers).
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Git tag to release (e.g. v0.1.0)"
required: true
type: string
permissions:
contents: write
env:
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
defaults:
run:
shell: bash
jobs:
build-linux:
name: Build Linux ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
- arch: arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
runs-on: ${{ matrix.runner }}
# The gateway now links z3 (upstream prover dep), so each job compiles z3
# twice (gateway + CLI). On the slower amd64 runner that exceeds 60 min;
# raised to 120. Follow-up: build server+cli in one cargo invocation to
# share z3-sys, or add sccache, to cut release wall-clock.
timeout-minutes: 120
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
- name: Install system deps
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq pkg-config libssl-dev clang protobuf-compiler
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
# The CLI statically links z3 via --features bundled-z3 (no runtime
# libz3.so.4). The vendored z3 source hits overload-resolution errors
# under modern system clang, so — mirroring upstream release-dev.yml —
# zig provides the C/C++ toolchain and linker for the z3 build. Only the
# CLI build step opts into this (via that step's env:); the gateway and
# sandbox supervisor don't link z3 and keep the default toolchain.
- name: Set up zig
uses: mlugg/setup-zig@v2
with:
version: 0.14.1
- name: Configure zig C/C++ wrappers for z3
run: |
set -euo pipefail
ZIG="$(command -v zig)"
mkdir -p /tmp/zig-cc
# cc-rs injects --target=<rust-triple> (for example
# x86_64-unknown-linux-gnu), which zig does not parse. Strip any
# caller-provided --target. WITHOUT -target, zig cc defaults to the
# *runner's native* CPU, baking AVX2/BMI2/FMA into the bundled z3 —
# which SIGILLs on older CPUs (e.g. pre-Haswell Ivy Bridge). Pin a
# portable ISA baseline per arch so the released binaries run anywhere.
case "${{ matrix.target }}" in
x86_64-*) MCPU="x86_64_v2" ;; # SSE4.2/POPCNT, ~2008+; ample for z3
aarch64-*) MCPU="baseline" ;; # armv8-a, universal aarch64
*) MCPU="baseline" ;;
esac
for tool in cc c++; do
printf '#!/bin/bash\nargs=()\nfor arg in "$@"; do\n case "$arg" in\n --target=*) ;;\n *) args+=("$arg") ;;\n esac\ndone\nexec "%s" %s -mcpu=%s "${args[@]}"\n' \
"$ZIG" "$tool" "$MCPU" > "/tmp/zig-cc/${tool}"
chmod +x "/tmp/zig-cc/${tool}"
done
- name: Cache cargo target
uses: Swatinem/rust-cache@v2
with:
shared-key: openlock-release-${{ matrix.target }}
# The gateway (openshell-server) gained an upstream prover dependency that
# pulls z3-sys; build it with bundled-z3 via the zig toolchain (same as the
# CLI) so the released gateway has no runtime libz3.so.4 dependency.
- name: Build openshell-gateway
env:
CC: /tmp/zig-cc/cc
CXX: /tmp/zig-cc/c++
CXXSTDLIB: c++
READ_ONLY_GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
TARGET_ENV=$(echo "${{ matrix.target }}" | tr '-' '_')
TARGET_ENV_UPPER=${TARGET_ENV^^}
export "CC_${TARGET_ENV}=/tmp/zig-cc/cc"
export "CXX_${TARGET_ENV}=/tmp/zig-cc/c++"
export "CARGO_TARGET_${TARGET_ENV_UPPER}_LINKER=/tmp/zig-cc/cc"
cargo build --release --target ${{ matrix.target }} -p openshell-server --features bundled-z3
- name: Build openshell-sandbox (supervisor)
run: cargo build --release --target ${{ matrix.target }} -p openshell-sandbox --bin openshell-sandbox
# CLI links z3; --features bundled-z3 vendors and statically links it
# via the zig toolchain configured above, so the released binary has no
# runtime libz3.so.4 dependency. The CC/CXX/LINKER and CXXSTDLIB=c++
# overrides are scoped to this step (z3 built with zig c++ uses libc++
# symbols, so z3-sys's default stdc++ must be overridden to match).
- name: Build openshell CLI
env:
CC: /tmp/zig-cc/cc
CXX: /tmp/zig-cc/c++
CXXSTDLIB: c++
# z3-sys --features bundled fetches the z3 source via the GitHub API;
# authenticate so GitHub-hosted runners don't hit the unauthenticated
# 60-req/hr rate limit (HTTP 403). z3-sys reads READ_ONLY_GITHUB_TOKEN.
READ_ONLY_GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
TARGET_ENV=$(echo "${{ matrix.target }}" | tr '-' '_')
TARGET_ENV_UPPER=${TARGET_ENV^^}
export "CC_${TARGET_ENV}=/tmp/zig-cc/cc"
export "CXX_${TARGET_ENV}=/tmp/zig-cc/c++"
export "CARGO_TARGET_${TARGET_ENV_UPPER}_LINKER=/tmp/zig-cc/cc"
cargo build --release --target ${{ matrix.target }} -p openshell-cli --features bundled-z3
- name: Package binaries
run: |
set -euo pipefail
mkdir -p artifacts
cd target/${{ matrix.target }}/release
tar -czf "${GITHUB_WORKSPACE}/artifacts/openshell-gateway-${{ matrix.target }}.tar.gz" openshell-gateway
tar -czf "${GITHUB_WORKSPACE}/artifacts/openshell-sandbox-${{ matrix.target }}.tar.gz" openshell-sandbox
tar -czf "${GITHUB_WORKSPACE}/artifacts/openshell-${{ matrix.target }}.tar.gz" openshell
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.arch }}
path: artifacts/*.tar.gz
retention-days: 5
build-macos:
name: Build macOS aarch64
runs-on: macos-14
timeout-minutes: 60
env:
TARGET: aarch64-apple-darwin
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
- name: Install build deps
run: brew install protobuf
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
# The CLI statically links z3 via --features bundled-z3 (no runtime libz3
# dylib). The vendored z3 source hits overload-resolution errors under the
# runner's older Apple clang, so — mirroring the Linux job and upstream
# release-dev.yml — zig provides the C/C++ compiler for the z3 build. zig
# only COMPILES z3 (built static); the final binary is linked by the
# default system linker (ld64), because zig cannot link a macOS
# executable. Only the CLI build step opts in (via its env:); the gateway
# doesn't link z3 and keeps the default toolchain.
- name: Set up zig
uses: mlugg/setup-zig@v2
with:
version: 0.14.1
- name: Configure zig C/C++ wrappers for z3
run: |
set -euo pipefail
ZIG="$(command -v zig)"
mkdir -p /tmp/zig-cc
# cc-rs injects --target=<rust-triple>, which zig does not parse;
# strip it and let zig use its native default. -fno-sanitize=all
# disables zig cc's default UBSan instrumentation, whose
# __ubsan_handle_* symbols are otherwise unresolved when the system
# linker links the final Rust binary.
for tool in cc c++; do
printf '#!/bin/bash\nargs=()\nfor arg in "$@"; do\n case "$arg" in\n --target=*) ;;\n *) args+=("$arg") ;;\n esac\ndone\nexec "%s" %s -fno-sanitize=all "${args[@]}"\n' \
"$ZIG" "$tool" > "/tmp/zig-cc/${tool}"
chmod +x "/tmp/zig-cc/${tool}"
done
- name: Cache cargo target
uses: Swatinem/rust-cache@v2
with:
shared-key: openlock-release-aarch64-apple-darwin
# The gateway (openshell-server) gained an upstream prover dependency that
# pulls z3-sys; build it with bundled-z3 via the zig toolchain (same as the
# CLI) so the released gateway works on a clean Mac with no Homebrew z3.
- name: Build openshell-gateway
env:
CC: /tmp/zig-cc/cc
CXX: /tmp/zig-cc/c++
CC_aarch64_apple_darwin: /tmp/zig-cc/cc
CXX_aarch64_apple_darwin: /tmp/zig-cc/c++
CXXSTDLIB: c++
MACOSX_DEPLOYMENT_TARGET: "11.0"
READ_ONLY_GITHUB_TOKEN: ${{ github.token }}
run: cargo build --release --target "$TARGET" -p openshell-server --features bundled-z3
# --features bundled-z3 vendors and statically links z3 via the zig
# toolchain configured above, so the released binary has no runtime libz3
# dylib and works on a clean Mac with no Homebrew z3. CC/CXX and the
# target-scoped CC_<triple>/CXX_<triple> point cc-rs (z3-sys's builder) at
# the zig wrappers; CXXSTDLIB=c++ matches macOS's libc++. The linker is
# deliberately NOT overridden — zig cannot link a macOS executable, so
# ld64 links the final binary against the zig-compiled static z3.
- name: Build openshell CLI
env:
CC: /tmp/zig-cc/cc
CXX: /tmp/zig-cc/c++
CC_aarch64_apple_darwin: /tmp/zig-cc/cc
CXX_aarch64_apple_darwin: /tmp/zig-cc/c++
CXXSTDLIB: c++
MACOSX_DEPLOYMENT_TARGET: "11.0"
# z3-sys --features bundled fetches the z3 source via the GitHub API;
# authenticate so the runner doesn't hit the unauthenticated
# 60-req/hr rate limit (HTTP 403). z3-sys reads READ_ONLY_GITHUB_TOKEN.
READ_ONLY_GITHUB_TOKEN: ${{ github.token }}
run: cargo build --release --target "$TARGET" -p openshell-cli --features bundled-z3
- name: Package binaries
run: |
set -euo pipefail
mkdir -p artifacts
cd target/"$TARGET"/release
tar -czf "${GITHUB_WORKSPACE}/artifacts/openshell-gateway-${TARGET}.tar.gz" openshell-gateway
tar -czf "${GITHUB_WORKSPACE}/artifacts/openshell-${TARGET}.tar.gz" openshell
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-aarch64
path: artifacts/*.tar.gz
retention-days: 5
release:
name: Release
needs: [build-linux, build-macos]
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag || github.ref }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release/
merge-multiple: true
- name: Compute checksums
working-directory: release
run: |
set -euo pipefail
ls -lh
sha256sum *.tar.gz > checksums-sha256.txt
cat checksums-sha256.txt
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
name: ${{ env.RELEASE_TAG }}
generate_release_notes: true
prerelease: ${{ contains(env.RELEASE_TAG, '-rc') || contains(env.RELEASE_TAG, '-beta') || contains(env.RELEASE_TAG, '-alpha') }}
files: |
release/*.tar.gz
release/checksums-sha256.txt