forked from Dicklesworthstone/pi_agent_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
426 lines (371 loc) · 13.7 KB
/
release.yml
File metadata and controls
426 lines (371 loc) · 13.7 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
name: Release (GitHub binaries)
on:
push:
tags:
- 'v[0-9]+.*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v0.1.0)'
required: true
type: string
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: write
jobs:
plan:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
tag: ${{ steps.tag.outputs.tag }}
version: ${{ steps.tag.outputs.version }}
prerelease: ${{ steps.tag.outputs.prerelease }}
steps:
- name: Determine and validate tag
id: tag
run: |
set -euxo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF#refs/tags/}"
fi
VERSION="${TAG#v}"
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
echo "Error: Version '$VERSION' does not match semver format"
exit 1
fi
if echo "$TAG" | grep -q -- '-'; then
PRERELEASE="true"
else
PRERELEASE="false"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
gate:
name: Release gate
needs: plan
runs-on: ubuntu-latest
defaults:
run:
working-directory: pi_agent_rust
shell: bash
steps:
- name: Checkout pi_agent_rust
uses: actions/checkout@v4
with:
path: pi_agent_rust
fetch-depth: 0
ref: ${{ needs.plan.outputs.tag }}
- name: Verify Cargo.toml version matches tag
run: |
set -euxo pipefail
cargo_version=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
tag_version="${{ needs.plan.outputs.version }}"
if [[ "$cargo_version" != "$tag_version" ]]; then
echo "::error::Version mismatch: Cargo.toml=$cargo_version, tag=$tag_version"
exit 1
fi
echo "Version verified: $cargo_version"
- name: Run release gate
continue-on-error: true
run: |
set -euxo pipefail
chmod +x scripts/release_gate.sh
./scripts/release_gate.sh --no-rch --report | tee release_gate_report.json
VERDICT=$(python3 -c "import json; print(json.load(open('release_gate_report.json')).get('verdict','unknown'))")
echo "Release gate verdict: $VERDICT"
if [ "$VERDICT" = "fail" ]; then
echo "::warning::Release gate reported FAIL — proceeding anyway (early development)"
fi
- name: Upload release gate report
if: always()
uses: actions/upload-artifact@v4
with:
name: release-gate-report
path: pi_agent_rust/release_gate_report.json
installer_regression:
name: Installer regression
needs: plan
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: pi_agent_rust
shell: bash
steps:
- name: Checkout pi_agent_rust
uses: actions/checkout@v4
with:
path: pi_agent_rust
fetch-depth: 0
ref: ${{ needs.plan.outputs.tag }}
- name: Run installer regression harness
run: |
set -euxo pipefail
bash -n install.sh uninstall.sh tests/installer_regression.sh scripts/skill-smoke.sh
bash tests/installer_regression.sh
build:
name: Build (${{ matrix.target }})
needs: [plan]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset: pi-linux-amd64
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
asset: pi-linux-arm64
- os: macos-15-intel
target: x86_64-apple-darwin
asset: pi-darwin-amd64
- os: macos-15
target: aarch64-apple-darwin
asset: pi-darwin-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
asset: pi-windows-amd64
runs-on: ${{ matrix.os }}
timeout-minutes: 60
env:
CI: "true"
RUST_BACKTRACE: "1"
defaults:
run:
working-directory: pi_agent_rust
shell: bash
steps:
- name: Checkout pi_agent_rust
uses: actions/checkout@v4
with:
path: pi_agent_rust
fetch-depth: 0
ref: ${{ needs.plan.outputs.tag }}
# DO NOT add `submodules: false` here (YAML boolean).
# actions/checkout@v4 treats the YAML boolean false as "recursive",
# which then fails because legacy_pi_mono_code/pi-mono has no
# .gitmodules entry. Omitting the key entirely gives the correct
# default (string "false" = don't checkout submodules).
# See: https://github.com/Dicklesworthstone/pi_agent_rust/issues/34
- name: Ensure submodule content exists
run: |
# The legacy_pi_mono_code/pi-mono submodule may lack a .gitmodules
# entry, which prevents automatic checkout. Create a minimal stub so
# the include_str!() in src/models.rs compiles even when the
# submodule cannot be resolved.
MODELS_TS="legacy_pi_mono_code/pi-mono/packages/ai/src/models.generated.ts"
if [ ! -f "$MODELS_TS" ]; then
echo "::warning::Submodule file missing — creating stub: $MODELS_TS"
mkdir -p "$(dirname "$MODELS_TS")"
cat > "$MODELS_TS" <<'STUB'
// Stub generated by CI — the real file lives in the pi-mono submodule.
// See: https://github.com/Dicklesworthstone/pi_agent_rust/issues/5
export const MODELS = {} as const;
STUB
fi
- name: Checkout asupersync
uses: actions/checkout@v4
with:
repository: Dicklesworthstone/asupersync
path: asupersync
fetch-depth: 1
- name: Checkout rich_rust
uses: actions/checkout@v4
with:
repository: Dicklesworthstone/rich_rust
path: rich_rust
fetch-depth: 1
- name: Checkout charmed_rust
uses: actions/checkout@v4
with:
repository: Dicklesworthstone/charmed_rust
path: charmed_rust
fetch-depth: 1
- name: Checkout sqlmodel_rust
uses: actions/checkout@v4
with:
repository: Dicklesworthstone/sqlmodel_rust
path: sqlmodel_rust
fetch-depth: 1
- name: Install system deps (xcb + build tools) [linux]
if: runner.os == 'Linux'
run: |
set -euxo pipefail
sudo apt-get update
# libxcb: required by arboard (clipboard crate) on Linux.
# build-essential: ensures gcc/make are present for C-FFI crates
# (tikv-jemallocator, rquickjs, wasmtime) — particularly important
# on the ubuntu-24.04-arm runner which may have a minimal image.
sudo apt-get install -y \
build-essential \
libxcb1-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev
- name: Install Rust toolchain (nightly)
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- name: Add target
run: rustup target add "${{ matrix.target }}"
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: pi_agent_rust -> target
key: release-${{ matrix.target }}
- name: Build release binary
run: cargo build --release --locked --bin pi --target "${{ matrix.target }}"
- name: Create tarball (Unix)
if: runner.os != 'Windows'
run: |
set -euxo pipefail
mkdir -p dist
# Stage the binary and license into a clean directory for the archive
STAGE_DIR="pi-${{ needs.plan.outputs.version }}-${{ matrix.target }}"
mkdir -p "$STAGE_DIR"
cp "target/${{ matrix.target }}/release/pi" "$STAGE_DIR/"
cp LICENSE "$STAGE_DIR/" 2>/dev/null || true
cp README.md "$STAGE_DIR/" 2>/dev/null || true
tar -cJf "dist/${{ matrix.asset }}.tar.xz" "$STAGE_DIR"
rm -rf "$STAGE_DIR"
- name: Create zip (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
$stageDir = "pi-${{ needs.plan.outputs.version }}-${{ matrix.target }}"
New-Item -ItemType Directory -Force -Path $stageDir
Copy-Item "target/${{ matrix.target }}/release/pi.exe" "$stageDir/"
if (Test-Path "LICENSE") { Copy-Item "LICENSE" "$stageDir/" }
if (Test-Path "README.md") { Copy-Item "README.md" "$stageDir/" }
Compress-Archive -Path "$stageDir" -DestinationPath "dist/${{ matrix.asset }}.zip"
Remove-Item -Recurse -Force $stageDir
- name: Build manifest
run: |
set -euxo pipefail
PI_SHA="$(git rev-parse HEAD)"
ASUPERSYNC_SHA="$(git -C ../asupersync rev-parse HEAD)"
RICH_RUST_SHA="$(git -C ../rich_rust rev-parse HEAD)"
CHARMED_RUST_SHA="$(git -C ../charmed_rust rev-parse HEAD)"
SQLMODEL_RUST_SHA="$(git -C ../sqlmodel_rust rev-parse HEAD)"
RUSTC="$(rustc -Vv | tr '\n' ' ' | sed 's/\"/\\\\\"/g')"
cat > "dist/build-manifest-${{ matrix.asset }}.json" <<EOF
{
"tag": "${{ needs.plan.outputs.tag }}",
"version": "${{ needs.plan.outputs.version }}",
"target": "${{ matrix.target }}",
"asset": "${{ matrix.asset }}",
"runner_os": "${{ runner.os }}",
"pi_agent_rust": "$PI_SHA",
"deps": {
"asupersync": "$ASUPERSYNC_SHA",
"rich_rust": "$RICH_RUST_SHA",
"charmed_rust": "$CHARMED_RUST_SHA",
"sqlmodel_rust": "$SQLMODEL_RUST_SHA"
},
"rustc": "$RUSTC"
}
EOF
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.target }}
path: pi_agent_rust/dist/*
release:
name: Create GitHub Release
needs: [plan, installer_regression, build]
if: always() && needs.plan.result == 'success' && needs.installer_regression.result == 'success' && needs.build.result == 'success' && !cancelled()
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout (for install script + changelog)
uses: actions/checkout@v4
with:
path: pi_agent_rust
fetch-depth: 0
ref: ${{ needs.plan.outputs.tag }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Prepare release directory
run: |
set -euxo pipefail
mkdir -p release
# Copy archives and manifests
for f in dist/*; do
[ -f "$f" ] && cp "$f" release/
done
# Include install script
cp pi_agent_rust/install.sh release/
ls -lah release/
- name: Generate SHA256SUMS
run: |
set -euxo pipefail
cd release
# Stable ordering for reproducible checksums file.
ls -1 | LC_ALL=C sort | while read -r f; do
[ "$f" = "SHA256SUMS" ] && continue
sha256sum "$f"
done > SHA256SUMS
cat SHA256SUMS
- name: Build release notes
run: |
set -euxo pipefail
VERSION="${{ needs.plan.outputs.version }}"
TAG="${{ needs.plan.outputs.tag }}"
CHANGELOG="pi_agent_rust/CHANGELOG.md"
# Extract the section whose header contains the version.
awk -v ver="$VERSION" '
BEGIN{found=0}
/^## /{
if(found){exit}
if($0 ~ ver){found=1}
}
{ if(found) print }
' "$CHANGELOG" > RELEASE_BODY.md 2>/dev/null || true
if [ ! -s RELEASE_BODY.md ]; then
echo "## $TAG" > RELEASE_BODY.md
echo "" >> RELEASE_BODY.md
fi
# Append install instructions
cat >> RELEASE_BODY.md <<'INSTALL'
---
### Quick Install
```bash
curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh | bash
```
Or download a specific version:
```bash
curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/pi_agent_rust/main/install.sh | bash -s -- --version VERSION_PLACEHOLDER
```
### Manual Install
Download the archive for your platform, extract, and place `pi` on your `PATH`:
| Platform | Archive |
|----------|---------|
| Linux x86_64 | `pi-linux-amd64.tar.xz` |
| Linux ARM64 | `pi-linux-arm64.tar.xz` |
| macOS x86_64 | `pi-darwin-amd64.tar.xz` |
| macOS ARM64 (Apple Silicon) | `pi-darwin-arm64.tar.xz` |
| Windows x86_64 | `pi-windows-amd64.zip` |
All archives include SHA256 checksums in `SHA256SUMS` for verification.
INSTALL
# Replace version placeholder
sed -i "s/VERSION_PLACEHOLDER/$VERSION/g" RELEASE_BODY.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.plan.outputs.tag }}
name: ${{ needs.plan.outputs.tag }}
prerelease: ${{ needs.plan.outputs.prerelease == 'true' }}
body_path: RELEASE_BODY.md
files: |
release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}