From 6dd019b3bb4f2891acb6fa5677911fd782952326 Mon Sep 17 00:00:00 2001 From: robonen Date: Sun, 2 Aug 2026 18:28:15 +0700 Subject: [PATCH] feat: enhance version validation in CI workflow to ensure tag consistency with Cargo.toml --- .gitea/workflows/ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0737b8f..818f3b7 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -61,10 +61,24 @@ jobs: id: meta run: | set -eu + manifest=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2) + version="$manifest" + + # A tag that disagrees with Cargo.toml must never ship. The installer + # is named after the tag, but the binary reports env!("CARGO_PKG_VERSION") + # — so a mismatch leaves every installed copy seeing the release as + # newer than itself forever, reinstalling every few hours. case "$GITHUB_REF" in - refs/tags/v*) version="${GITHUB_REF#refs/tags/v}" ;; - *) version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2) ;; + refs/tags/v*) + version="${GITHUB_REF#refs/tags/v}" + if [ "$version" != "$manifest" ]; then + echo "tag v$version does not match Cargo.toml version $manifest" >&2 + echo "bump the version in Cargo.toml and retag" >&2 + exit 1 + fi + ;; esac + echo "version=$version" >> "$GITHUB_OUTPUT" echo "version: $version"