Skip to content

Commit

Permalink
Check for existing tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Jun 23, 2024
1 parent b8849fe commit ac76adf
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,28 @@ jobs:
validation:
runs-on: ubuntu-latest
outputs:
GDEXT_PUBLISHED_VERSION: ${{ steps.interpret-tag-version.outputs.GDEXT_PUBLISHED_VERSION }}
GDEXT_PUBLISHED_VERSION: ${{ steps.parse-crate-version.outputs.GDEXT_PUBLISHED_VERSION }}
steps:
- uses: actions/checkout@v4

# sed: https://unix.stackexchange.com/a/589584
- name: "Interpret tag version"
id: interpret-tag-version
- name: "Parse crate version from Cargo.toml"
id: parse-crate-version
run: |
#version=$(echo "$GITHUB_REF" | sed -n "s#refs/tags/v\(.*\)#\1#p")
version="0.1.0" # DEBUG
[ -z "$version" ] && {
printf "\n::error::Failed to parse '$GITHUB_REF'.\n"
crateVer=$(grep '^version' godot/Cargo.toml | sed -E 's/^version = "(.*)"$/\1/')
if [[ -z "$crateVer" ]]; then
echo "::error::Failed to parse crate version from Cargo.toml."
exit 1
fi
# Check if tag exists.
git fetch --tags
git tag -l | grep -q "^v$version$" && {
echo "::error::Tag 'v$version' already exists."
exit 2
}
echo "Published version: $version"
echo "GDEXT_PUBLISHED_VERSION=$version" >> $GITHUB_OUTPUT
echo "GDEXT_PUBLISHED_VERSION=$crateVer" >> $GITHUB_OUTPUT
echo "Validated version: $crateVer"
- name: "Verify that Cargo.toml versions match ${{ steps.interpret-tag-version.outputs.GDEXT_PUBLISHED_VERSION }}"
run: |
Expand Down

0 comments on commit ac76adf

Please sign in to comment.