From 3018330e62cdc13caaaa9a0b5e162e55546704c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Cuadrado=20Juan?= Date: Fri, 21 Feb 2025 12:11:09 +0100 Subject: [PATCH] ci: Add version-check job to check Cargo.toml on release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On release (when the CI workflow is triggered by a tag), check that the Cargo.toml `version` matches the tag. This prevents releasing badly tagged or version-annotated images. This is lifted from kwctl's CI. Signed-off-by: VĂ­ctor Cuadrado Juan --- .github/workflows/ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a64680a..49d45133 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,23 @@ jobs: with: command: check + version-check: + name: Check Cargo.toml version + if: github.ref_type == 'tag' + runs-on: ubuntu-latest + steps: + - name: Download source code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Check cargo file version + run: | + CARGO_VERSION=$(sed -n 's,^version\s*= \"\(.*\)\",\1,p' Cargo.toml) + TAG_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//') + + if [ "$CARGO_VERSION" != "$TAG_VERSION" ];then + echo "::error title=Invalid Cargo.toml version::Cargo.toml version does not match the tag version" + exit 1 + fi + unit-tests: name: Unit tests runs-on: ubuntu-latest @@ -132,4 +149,3 @@ jobs: echo "Changes detected in cli-docs.md. Please run `make build-docs` and commit the changes." gh run cancel ${{ github.run_id }} fi -