diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1d0c58196..2e3b39e84 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,6 +38,57 @@ jobs: - name: Check typos run: typos + # version bump + check-version: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: RDXWorks-actions/checkout@main + with: + fetch-depth: 0 # Ensure the full git history is fetched + + - name: Fetch all tags + run: git fetch --tags + + - name: Get latest tag + id: get_latest_tag + run: | + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "Latest tag is $latest_tag" + echo "latest_tag=$latest_tag" >> $GITHUB_ENV + + - name: Verify Cargo.toml version bump + run: | + # Extract the version from the latest tag + latest_tag_version=$latest_tag + + # Extract the version from Cargo.toml in the PR branch + pr_version=$(grep '^version' crates/sargon/Cargo.toml | sed 's/version = "\(.*\)"/\1/') + + echo "Latest tag version: $latest_tag_version" + echo "PR version: $pr_version" + + # Split the versions into major, minor, and patch components + IFS='.' read -r -a tag_version_parts <<< "$latest_tag_version" + IFS='.' read -r -a pr_version_parts <<< "$pr_version" + + major_diff=$((pr_version_parts[0] - tag_version_parts[0])) + minor_diff=$((pr_version_parts[1] - tag_version_parts[1])) + patch_diff=$((pr_version_parts[2] - tag_version_parts[2])) + + # Check if the PR version is a valid bump + if [ "$major_diff" -eq 1 ] && [ "${pr_version_parts[1]}" -eq 0 ] && [ "${pr_version_parts[2]}" -eq 0 ]; then + echo "Major version bump valid!" + elif [ "$major_diff" -eq 0 ] && [ "$minor_diff" -eq 1 ] && [ "${pr_version_parts[2]}" -eq 0 ]; then + echo "Minor version bump valid!" + elif [ "$major_diff" -eq 0 ] && [ "$minor_diff" -eq 0 ] && [ "$patch_diff" -eq 1 ]; then + echo "Patch version bump valid!" + else + echo "Version bump is invalid!" + exit 1 + fi + + # phylum phylum-analyze: if: ${{ github.event.pull_request }} uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/phylum-analyze.yml@main diff --git a/Cargo.lock b/Cargo.lock index e8dc1cc57..b15b5b1e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2617,7 +2617,7 @@ dependencies = [ [[package]] name = "sargon" -version = "1.1.19" +version = "1.1.23" dependencies = [ "actix-rt", "aes-gcm", diff --git a/crates/sargon/Cargo.toml b/crates/sargon/Cargo.toml index fe60d8260..d070c5cc1 100644 --- a/crates/sargon/Cargo.toml +++ b/crates/sargon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sargon" -version = "1.1.21" +version = "1.1.23" edition = "2021" build = "build.rs"