Files
lucisv/.gitea/workflows/release.yml
T

128 lines
5.6 KiB
YAML

# Author: Guoliang Chen, a Senior Digital Design Engineer
# Release: pushing a tag `vX.Y.Z` builds every distribution artifact and
# publishes a Gitea release with the CHANGELOG section for that version as
# its notes. What the release page carries is the seven .vsix packages —
# the universal one, the five (darwin-arm64/darwin-x64/linux-x64/
# linux-arm64/win32-x64) with the lucisv + lucisv-server + lucisv-mcp binaries embedded,
# and the all-platforms one carrying every platform's three binaries at once — plus SHA256SUMS.
# Every package is a must: a missing one fails the release, by name
# (tools/prune_release_assets.sh). The loose binaries are still built for
# every target
# (the packages are made from them) and still audited, but they are not
# attached: anyone who wants a standalone binary builds it with
# `cargo build --release` (docs/features/editor-platform-vsix).
#
# The release fails, deliberately, when the tag does not match the
# workspace version or CHANGELOG.md has no section for it: every release
# ships with real, written notes (see tools/RELEASING.md).
#
# It is gated in three stages:
# 1. `preflight` checks in seconds that the tag matches Cargo.toml, the VS Code
# extension version files, and a non-empty CHANGELOG.md section before any
# heavy build runs.
# 2. `linux` runs clippy and guarded workspace tests on `linux-x64` so Linux
# portability is verified before building or publishing a release.
# 3. `build-and-publish` runs `tools/gates.sh` (stamp, fmt, clippy, every
# crate's suites, doc-tests, corpus gate, node tests, cross check), builds
# and audits all targets, prunes assets to the seven .vsix files + SHA256SUMS,
# and publishes the Gitea release.
name: release
on:
push:
tags:
- 'v*'
jobs:
preflight:
runs-on: macos-arm64
steps:
- uses: actions/checkout@v4
- name: Check tag, versions, and CHANGELOG notes
run: |
tag_ver=${GITHUB_REF_NAME#v}
[ "v$tag_ver" = "$GITHUB_REF_NAME" ] && [ -n "$tag_ver" ] || {
echo "tag $GITHUB_REF_NAME must look like vX.Y.Z" >&2
exit 1
}
crate_ver=$(awk '
/^\[workspace\.package\]/ { in_wp = 1; next }
/^\[/ { in_wp = 0 }
in_wp && /^version[[:space:]]*=/ {
sub(/^[^"]*"/, ""); sub(/".*/, ""); print; exit
}
' Cargo.toml)
[ "$crate_ver" = "$tag_ver" ] || {
echo "tag $GITHUB_REF_NAME does not match Cargo.toml version '$crate_ver'" >&2
exit 1
}
for pinned in \
"$(node -p "require('./editors/vscode/package.json').version")" \
"$(node -p "require('./editors/vscode/package-lock.json').version")" \
"$(node -p "require('./editors/vscode/package-lock.json').packages[''].version")"; do
[ "$pinned" = "$tag_ver" ] || {
echo "editors/vscode version '$pinned' does not match tag $GITHUB_REF_NAME" >&2
exit 1
}
done
tools/release_notes.sh "$tag_ver" >/dev/null
linux:
needs: preflight
runs-on: linux-x64
steps:
- uses: actions/checkout@v4
- name: Install the Rust toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --profile minimal -c clippy,rustfmt
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: cargo clippy
run: cargo clippy --all-targets -- -D warnings
- name: cargo test
run: tools/guard.sh -m 6 -t 1800 -- cargo test --workspace
build-and-publish:
needs: [preflight, linux]
runs-on: macos-arm64
steps:
- uses: actions/checkout@v4
# The corpus is pinned-rev clones cached on the runner host, as in
# ci.yml; gates.sh skips its corpus step when the cache is absent, so
# fetch it here rather than release without that gate.
- name: Ensure the cached corpus
run: |
corpus="$HOME/.cache/lucisv-corpus"
[ -d "$corpus" ] || tools/corpus_fetch.sh "$corpus"
- name: Gate the release
run: tools/gates.sh
- name: Build release artifacts for every target
run: tools/release.sh --cross
- name: Audit the cross-built artifacts
run: tools/audit_artifacts.sh dist
- name: Check the tag against the crate version
run: |
v=$(target/release/lucisv --version | awk '{print $2}')
[ "v$v" = "$GITHUB_REF_NAME" ] || {
echo "tag $GITHUB_REF_NAME does not match crate version $v" >&2
exit 1
}
# The release page ships extension packages only: all seven checked by
# name, SHA256SUMS filtered down to them and re-verified, the loose
# binaries (needed to build and audit the packages) dropped.
- name: Keep only the extension packages
run: tools/prune_release_assets.sh dist "${GITHUB_REF_NAME#v}"
- name: Extract the release notes from CHANGELOG.md
run: tools/release_notes.sh "${GITHUB_REF_NAME#v}" > dist/RELEASE_NOTES.md
# LUCISV_API_URL is an optional repository Actions variable naming a
# direct http://host:port for the Gitea API, so the uploads do not go
# through Cloudflare's 100-second origin timeout (0.29.0 and 0.30.0
# both died there with a 524). Unset, the public URL is used.
- name: Create the release and attach the artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LUCISV_API_URL: ${{ vars.LUCISV_API_URL }}
run: tools/publish_release.sh "$GITHUB_REF_NAME" dist
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com