Skip to content

Commit

Permalink
Validate version against Cargo.toml
Browse files Browse the repository at this point in the history
This is strongly inspired by an analogous check in the ripgrep
workflow, but done differently (from how that currently does it) by
parsing `Cargo.toml` using `yq`.

The `yq` command supports reading TOML (just not writing it). This
command is present on the `ubuntu-latest` runner.

This also moves the "Show the version" step into the new step, and
has that step also show the version extracted from `Cargo.toml`, so
as to make errors easier to understand and also to help verify that
this logic is really working.
  • Loading branch information
EliahKagan committed Jul 31, 2024
1 parent 5de322f commit 2390a47
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,31 @@ jobs:
# VERSION: TEST-0.0.0

steps:
- name: Create artifacts directory
run: mkdir artifacts
- name: Checkout repository
uses: actions/checkout@v4

- name: Get the release version from the tag
if: env.VERSION == ''
run: echo 'VERSION=${{ github.ref_name }}' >> "$GITHUB_ENV"

- name: Show the version
- name: Validate version against Cargo.toml
run: |
echo "version is: $VERSION"
manifest_version="$(yq -r .package.version Cargo.toml)"
echo "version to give the release: $VERSION"
echo "version Cargo.toml declares: $manifest_version"
case "$VERSION" in
"$manifest_version")
echo "OK: Version to give the relase agrees with top-level Cargo.toml."
;;
*)
echo "STOPPING: Version to give the release seems mistaken."
exit 1
;;
esac
- name: Create artifacts directory
run: mkdir artifacts

- name: Create GitHub release
id: release
Expand Down

0 comments on commit 2390a47

Please sign in to comment.