Skip to content

Commit 0bb029a

Browse files
authored
disable release overwrite (dmnd-pool#75)
1 parent 29dca23 commit 0bb029a

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)