From 6a372e298275c7a3f08040b3f034ff09afa9b5b8 Mon Sep 17 00:00:00 2001 From: Eric Ratliff Date: Sun, 22 Feb 2026 09:57:37 -0600 Subject: [PATCH] Release build script reads from anvil version --- README.md | 15 +++++++++------ build-release.sh | 30 ++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7f1ec89..1fb8bde 100644 --- a/README.md +++ b/README.md @@ -409,19 +409,22 @@ The binary lands at `target\release\anvil.exe`. ### Release builds (Linux + Windows from one machine) The `build-release.sh` script at the repo root builds optimized, stripped -binaries for both platforms and packages them into tarballs and zips: +binaries for both platforms and packages them into tarballs and zips. It +reads the version from `Cargo.toml` (the single source of truth) and +accepts an optional suffix for pre-release builds: ```bash -./build-release.sh # uses git describe for version -./build-release.sh v1.2.0 # explicit version tag +./build-release.sh # uses version from Cargo.toml (e.g. 1.0.0) +./build-release.sh beta1 # appends suffix (e.g. 1.0.0-beta1) +./build-release.sh rc1 # appends suffix (e.g. 1.0.0-rc1) ``` This produces a `release-artifacts/` directory with: ``` -anvil-v1.2.0-linux-x86_64.tar.gz -anvil-v1.2.0-linux-x86_64.zip -anvil-v1.2.0-windows-x86_64.zip +anvil-1.0.0-linux-x86_64.tar.gz +anvil-1.0.0-linux-x86_64.zip +anvil-1.0.0-windows-x86_64.zip SHA256SUMS ``` diff --git a/build-release.sh b/build-release.sh index efc49c2..0d229ed 100644 --- a/build-release.sh +++ b/build-release.sh @@ -2,14 +2,36 @@ # Build release binaries for distribution # This script builds both Linux and Windows binaries (cross-compile) # +# Usage: +# ./build-release.sh # version from Cargo.toml (e.g. 1.0.0) +# ./build-release.sh beta1 # appends suffix (e.g. 1.0.0-beta1) +# ./build-release.sh rc1 # appends suffix (e.g. 1.0.0-rc1) +# # For Windows-only builds, use build-release.ps1 on Windows # For Linux-only builds, comment out the Windows section below set -e -VERSION=${1:-$(git describe --tags --always)} +# Read version from the single source of truth: Cargo.toml +BASE_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') +if [ -z "$BASE_VERSION" ]; then + echo "Error: Could not read version from Cargo.toml" + exit 1 +fi + +# Optional suffix (beta1, rc1, etc.) +if [ -n "$1" ]; then + VERSION="${BASE_VERSION}-${1}" +else + VERSION="$BASE_VERSION" +fi + RELEASE_DIR="release-artifacts" -echo "Building Anvil $VERSION release binaries..." +echo "Building Anvil v${VERSION} release binaries..." +echo " Version base: ${BASE_VERSION} (from Cargo.toml)" +if [ -n "$1" ]; then + echo " Suffix: ${1}" +fi echo "" # Clean previous artifacts @@ -63,7 +85,7 @@ cd .. # Display results echo "" echo "===========================================================" -echo " Release artifacts built successfully!" +echo " Anvil v${VERSION} release artifacts built successfully!" echo "===========================================================" echo "" echo "Artifacts in $RELEASE_DIR/:" @@ -73,7 +95,7 @@ echo "Checksums:" cat "$RELEASE_DIR/SHA256SUMS" echo "" echo "Upload these files to your Gitea release:" -echo " 1. Go to: Releases -> $VERSION -> Edit Release" +echo " 1. Create release: Releases -> New Release -> Tag: v${VERSION}" echo " 2. Drag and drop files from $RELEASE_DIR/" echo " 3. Save" echo "" \ No newline at end of file