Files
alkane-toolkit/.gitea/workflows/release.yml
T
noahandClaude Opus 4.8 749cdc4eed item 12: CI verify/release split, dependency audit, README + badges
CI is now two workflows: verify.yml (pull requests + non-main pushes) runs the
clippy gate, build, unit tests, microbenchmarks, the headless self-test, and a
best-effort dependency audit; release.yml (main) repeats the clippy gate + audit
before its existing build/test/selftest/package/release, then refreshes the
committed README badges and pushes any change back (best-effort, and a badges-
only push does not bump the version, so it does not loop).

Security: cargo audit found a build-time-only advisory (h2 0.3 in the wx-rs
build script's reqwest 0.11 subtree, never linked into the runtime binary and
never executed on Linux). The vendored/offline tree can't upgrade it without
re-vendoring, so it is documented and accepted in .cargo/audit.toml (mirrored in
deny.toml with the project's permissive-license policy).

Badges: ci/gen-badges.py emits self-contained shields-style SVGs into badges/
(tests, coverage 36%, bench, LOC 12.5k, clippy clean, dependencies, license) --
committed and referenced by relative path so a self-hosted Gitea renders them
with no external service. README rewritten around what the toolkit actually does
today (discover / monitor / operate / install), with build, CLI, dev, and
architecture sections and the dual-license note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
2026-09-22 18:17:31 -06:00

170 lines
6.9 KiB
YAML

name: build-test-release
# Runs on every merge/push to main: build the GUI, run tests + a microbenchmark,
# and (when the change warrants it) cut an X.Y.Z release with the binary attached.
on:
push:
branches: [main]
jobs:
release:
runs-on: alkane-ci
env:
WX_PREFIX: /root/.cache/wx-3.3.3-linux
steps:
- name: Checkout (full history for tags)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute version
id: ver
run: bash ci/compute-version.sh | tee -a "$GITHUB_OUTPUT"
- name: Test version logic
if: steps.ver.outputs.release == 'true'
run: bash ci/test-compute-version.sh
- name: Install build dependencies
if: steps.ver.outputs.release == 'true'
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends \
libssl-dev pkg-config ca-certificates >/dev/null
echo "libssl-dev + pkg-config installed (openssl-sys needs them)"
- name: Cache vendored wxWidgets build
if: steps.ver.outputs.release == 'true'
uses: actions/cache@v4
with:
path: /root/.cache/wx-3.3.3-linux
key: wx-3.3.3-${{ runner.os }}-${{ hashFiles('thirdparty/wx-rs/VERSION') }}
- name: Build wxWidgets (once, then cached)
if: steps.ver.outputs.release == 'true'
run: |
if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then
bash scripts/build-wx-linux.sh
else
echo "wx prefix restored from cache"
fi
- name: Clippy (our crate, warnings are errors)
if: steps.ver.outputs.release == 'true'
run: |
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
- name: Set crate version to ${{ steps.ver.outputs.version }}
if: steps.ver.outputs.release == 'true'
run: |
sed -i "0,/^version = \".*\"/s//version = \"${{ steps.ver.outputs.version }}\"/" Cargo.toml
grep -m1 '^version' Cargo.toml
- name: Build release
if: steps.ver.outputs.release == 'true'
run: |
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
cargo build --release -p alkane-gui --offline
- name: Unit tests
if: steps.ver.outputs.release == 'true'
run: |
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
cargo test -p alkane-gui --offline
- name: Microbenchmarks
if: steps.ver.outputs.release == 'true'
run: |
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
cargo test -p alkane-gui --release --offline -- --ignored --nocapture bench_
- name: Headless UI self-test
if: steps.ver.outputs.release == 'true'
run: |
apt-get update -qq && apt-get install -y -qq --no-install-recommends \
xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null
BIN=target/release/alkane-toolkit
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
- name: Dependency audit (best-effort)
if: steps.ver.outputs.release == 'true'
continue-on-error: true
run: |
if command -v cargo-audit >/dev/null 2>&1; then
cargo audit || echo "cargo audit reported findings (accepted ones in .cargo/audit.toml)"
else
echo "cargo-audit not installed on this runner; skipping"
fi
# Refresh the committed README badges from live metrics and push any change
# back to main. Best-effort: a locked-down runner that can't push must not
# fail the release. A badges-only push does not bump the version (see
# compute-version.sh), so it does not loop back into another release.
- name: Refresh badges
if: steps.ver.outputs.release == 'true'
continue-on-error: true
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
| grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
python3 ci/gen-badges.py --tests "${PASS:-0}" --bench "row-render + scan-parse"
if [ -n "$(git status --porcelain badges)" ]; then
git config user.name "alkane-ci"
git config user.email "ci@bluefla.re"
git add badges
git commit -m "ci: refresh README badges [skip release]"
API="${GITHUB_API_URL:-https://gitea.bluefla.re/api/v1}"
HOST="${API%/api/v1}"
git push "${HOST}/${GITHUB_REPOSITORY}.git" "HEAD:main" \
-c http.extraheader="Authorization: token ${TOKEN}" || echo "badge push skipped"
else
echo "badges unchanged"
fi
- name: Package artifact
if: steps.ver.outputs.release == 'true'
id: pkg
run: |
V="${{ steps.ver.outputs.version }}"
NAME="alkane-toolkit-v${V}-linux-x86_64"
mkdir -p "dist/$NAME"
cp target/release/alkane-toolkit "dist/$NAME/"
cat > "dist/$NAME/README.txt" <<EOF
alkane-toolkit v${V} (linux x86_64)
Bump type: ${{ steps.ver.outputs.bump }}
Commit: ${GITHUB_SHA}
Run: ./alkane-toolkit
Requires GTK 3 at runtime: sudo apt install libgtk-3-0
Offline demo: ALKANE_FAKE_SCAN=1 ./alkane-toolkit
EOF
tar -C dist -czf "dist/${NAME}.tar.gz" "$NAME"
echo "asset=dist/${NAME}.tar.gz" >> "$GITHUB_OUTPUT"
echo "assetname=${NAME}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Create Gitea release + upload artifact
if: steps.ver.outputs.release == 'true'
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ steps.ver.outputs.tag }}"
API="${GITHUB_API_URL:-https://gitea.bluefla.re/api/v1}"
REPO="${GITHUB_REPOSITORY}"
body="Automated ${{ steps.ver.outputs.bump }} release from ${GITHUB_SHA}."
rel=$(curl -sS -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" \
"${API}/repos/${REPO}/releases" \
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\",\"name\":\"${TAG}\",\"body\":\"${body}\"}")
id=$(echo "$rel" | grep -oE '"id":[0-9]+' | head -1 | cut -d: -f2)
if [ -z "$id" ]; then echo "release create failed: $rel"; exit 1; fi
curl -sS -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/gzip" \
"${API}/repos/${REPO}/releases/${id}/assets?name=${{ steps.pkg.outputs.assetname }}" \
--data-binary @"${{ steps.pkg.outputs.asset }}" | grep -oE '"browser_download_url":"[^"]+"' || true
echo "Released ${TAG}"
- name: No release needed
if: steps.ver.outputs.release != 'true'
run: echo "No backend/UI change since ${{ steps.ver.outputs.last_tag }} - skipping release."