File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,19 +92,28 @@ jobs:
9292 - name : Install cargo-release
9393 run : cargo install cargo-release
9494
95- - name : Create a new tag based on Cargo.toml version
95+ - name : Check if tag exists
96+ id : check_tag
9697 run : |
9798 VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r .packages[0].version)
98-
99- # Check if the tag already exists remotely
10099 if git ls-remote --tags origin | grep -q "refs/tags/v$VERSION"; then
101- echo "Tag v$VERSION already exists, skipping tag creation."
100+ echo "tag_exists=true" >> $GITHUB_OUTPUT
102101 else
103- git tag "v$VERSION"
104- git push origin " v$VERSION"
102+ echo "tag_exists=false" >> $GITHUB_OUTPUT
103+ echo "TAG_NAME= v$VERSION" >> $GITHUB_ENV
105104 fi
106-
107- echo "TAG_NAME=v$VERSION" >> $GITHUB_ENV
105+
106+ - name : Fail if tag exists
107+ if : steps.check_tag.outputs.tag_exists == 'true'
108+ run : |
109+ echo "Release tag already exists, aborting workflow to prevent overwriting."
110+ exit 1
111+
112+ - name : Create and push tag
113+ if : steps.check_tag.outputs.tag_exists == 'false'
114+ run : |
115+ git tag "${{ env.TAG_NAME }}"
116+ git push origin "${{ env.TAG_NAME }}"
108117
109118
110119 - name : Download Linux Artifact
You can’t perform that action at this time.
0 commit comments