diff --git a/.github/workflows/release-version.yml b/.github/workflows/release-version.yml index f6fcdf278..73b3ca386 100644 --- a/.github/workflows/release-version.yml +++ b/.github/workflows/release-version.yml @@ -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: |