From 4ac4c6223dd8c74e1cb3489d68b8203cc0a8ddac Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Tue, 20 Aug 2024 11:57:40 +0200 Subject: [PATCH] Check if cargo version is updated --- .gitea/workflows/ci.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 09c0f7f..60cfbcb 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -22,4 +22,33 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-loadstar - run: cargo publish -n + check-cargo-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get current version from Cargo.toml + id: cargo-version + run: | + # Extract the version from Cargo.toml in the PR branch + CARGO_VERSION=$(grep '^version' Cargo.toml | sed -e 's/version = "//' -e 's/"//') + echo "cargo_version=$CARGO_VERSION" >> $GITHUB_ENV + + - name: Get previous version from main branch + id: main-cargo-version + run: | + # Fetch the Cargo.toml from the main branch and extract its version + git fetch origin main + MAIN_CARGO_VERSION=$(git show origin/main:Cargo.toml | grep '^version' | sed -e 's/version = "//' -e 's/"//') + echo "main_cargo_version=$MAIN_CARGO_VERSION" >> $GITHUB_ENV + + - name: Compare versions + run: | + if [ "$cargo_version" = "$main_cargo_version" ]; then + echo "Cargo version has not been updated." + exit 1 + else + echo "Cargo version has been updated." + fi