ci: automated release workflow

Single workflow_dispatch (version, dry_run) that bumps versions, regenerates
CHANGELOG via git-cliff, rebuilds site CSS, builds all targets, creates the
GitHub release, updates the Homebrew tap and publishes Chocolatey.

- dist/release/bump_version.sh: version replacer across all tracked locations (+tests)
- .github/workflows/release.yml: prepare -> build matrix -> homebrew/release -> choco
- retire build-artifacts.yml (merged into release.yml)
- Linux builds via cargo-zigbuild (old glibc) for broad compatibility
This commit is contained in:
Christian Visintin
2026-06-07 16:46:50 +02:00
parent 0ad18ea5e7
commit c652ca18b8
4 changed files with 491 additions and 172 deletions

38
dist/release/bump_version.sh vendored Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Bump termscp version across all tracked locations.
# Usage: bump_version.sh <version> [date] [root]
set -euo pipefail
VERSION="${1:?usage: bump_version.sh <version> [date] [root]}"
DATE="${2:-$(date +%F)}"
ROOT="${3:-$(git rev-parse --show-toplevel)}"
# in-place sed that works on both GNU and BSD/macOS
sedi() { perl -0777 -pi -e "$1" "$2"; }
# Cargo.toml — only the top-level package version (line-anchored), not deps
sedi "s/^version = \"[0-9][0-9A-Za-z.\\-]*\"/version = \"$VERSION\"/m" "$ROOT/Cargo.toml"
# install.sh — the literal default assignment only
sedi "s/^TERMSCP_VERSION=\"[0-9][0-9A-Za-z.\\-]*\"/TERMSCP_VERSION=\"$VERSION\"/m" "$ROOT/install.sh"
# README.md — version + release date
sedi "s/Current version: [0-9][0-9A-Za-z.\\-]* [0-9]{4}-[0-9]{2}-[0-9]{2}/Current version: $VERSION $DATE/" "$ROOT/README.md"
# site: home.html + every lang json — "termscp X is NOW out"
sedi "s/termscp [0-9][0-9A-Za-z.\\-]* is NOW out/termscp $VERSION is NOW out/g" "$ROOT/site/html/home.html"
for f in "$ROOT"/site/lang/*.json; do
sedi "s/termscp [0-9][0-9A-Za-z.\\-]* is NOW out/termscp $VERSION is NOW out/g" "$f"
done
# site/get-started.html — nupkg + deb download URLs
sedi "s/termscp\\.[0-9][0-9A-Za-z.\\-]*\\.nupkg/termscp.$VERSION.nupkg/g" "$ROOT/site/html/get-started.html"
sedi "s/termscp_[0-9][0-9A-Za-z.\\-]*_amd64\\.deb/termscp_${VERSION}_amd64.deb/g" "$ROOT/site/html/get-started.html"
# chocolatey nuspec
sedi "s#<version>[0-9][0-9A-Za-z.\\-]*</version>#<version>$VERSION</version>#" "$ROOT/dist/chocolatey/termscp.nuspec"
# chocolatey install script — release tag + asset name in the URLs (checksums set later by CI)
sedi "s#releases/download/v[0-9][0-9A-Za-z.\\-]*/termscp-v[0-9][0-9A-Za-z.\\-]*-#releases/download/v$VERSION/termscp-v$VERSION-#g" "$ROOT/dist/chocolatey/tools/chocolateyinstall.ps1"
echo "Bumped to $VERSION ($DATE)"

85
dist/release/test_bump_version.sh vendored Executable file
View File

@@ -0,0 +1,85 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUMP="$SCRIPT_DIR/bump_version.sh"
ROOT="$(mktemp -d)"
trap 'rm -rf "$ROOT"' EXIT
# --- build a fixture tree mirroring the real layout, all at 1.0.0 ---
mkdir -p "$ROOT/site/html" "$ROOT/site/lang" "$ROOT/dist/chocolatey/tools"
cat > "$ROOT/Cargo.toml" <<'EOF'
[package]
name = "termscp"
version = "1.0.0"
[dependencies]
foo = { version = "1.0.0" }
EOF
cat > "$ROOT/install.sh" <<'EOF'
TERMSCP_VERSION="1.0.0"
set_termscp_version() {
TERMSCP_VERSION="$1"
}
EOF
cat > "$ROOT/README.md" <<'EOF'
<p align="center">Current version: 1.0.0 2026-04-18</p>
EOF
cat > "$ROOT/site/html/home.html" <<'EOF'
<span>termscp 1.0.0 is NOW out! Download it from</span>
EOF
cat > "$ROOT/site/html/get-started.html" <<'EOF'
<a href="https://github.com/veeso/termscp/releases/latest/download/termscp.1.0.0.nupkg">Github</a>
<pre>wget -O termscp.deb https://github.com/veeso/termscp/releases/latest/download/termscp_1.0.0_amd64.deb</pre>
EOF
for lang in en it fr es zh-CN; do
cat > "$ROOT/site/lang/$lang.json" <<'EOF'
{ "versionAlert": "termscp 1.0.0 is NOW out! Download it from" }
EOF
done
cat > "$ROOT/dist/chocolatey/termscp.nuspec" <<'EOF'
<version>1.0.0</version>
EOF
cat > "$ROOT/dist/chocolatey/tools/chocolateyinstall.ps1" <<'EOF'
$url = 'https://github.com/veeso/termscp/releases/download/v1.0.0/termscp-v1.0.0-aarch64-pc-windows-msvc.zip'
$url = 'https://github.com/veeso/termscp/releases/download/v1.0.0/termscp-v1.0.0-x86_64-pc-windows-msvc.zip'
EOF
# --- run the bump ---
"$BUMP" 1.1.0 2026-06-07 "$ROOT"
fail() { echo "FAIL: $1"; exit 1; }
have() { grep -q -- "$2" "$ROOT/$1" || fail "$1 missing: $2"; }
missing() { ! grep -q -- "$2" "$ROOT/$1" || fail "$1 still has: $2"; }
# package version bumped, dependency version NOT touched
have "Cargo.toml" 'version = "1.1.0"'
have "Cargo.toml" 'foo = { version = "1.0.0" }'
have "install.sh" 'TERMSCP_VERSION="1.1.0"'
have "README.md" 'Current version: 1.1.0 2026-06-07'
missing "README.md" '2026-04-18'
have "site/html/home.html" 'termscp 1.1.0 is NOW out'
have "site/lang/en.json" 'termscp 1.1.0 is NOW out'
have "site/lang/zh-CN.json" 'termscp 1.1.0 is NOW out'
have "site/html/get-started.html" 'termscp.1.1.0.nupkg'
have "site/html/get-started.html" 'termscp_1.1.0_amd64.deb'
have "dist/chocolatey/termscp.nuspec" '<version>1.1.0</version>'
have "dist/chocolatey/tools/chocolateyinstall.ps1" 'releases/download/v1.1.0/termscp-v1.1.0-'
missing "dist/chocolatey/tools/chocolateyinstall.ps1" 'v1.0.0'
# --- idempotency: running again at same version is a no-op (no error) ---
"$BUMP" 1.1.0 2026-06-07 "$ROOT"
have "Cargo.toml" 'version = "1.1.0"'
echo "PASS"