Skip to content

Commit f01d240

Browse files
🐛 Enhance release workflow to support manual dispatch and prevent duplicate tags (#185)
Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent 67ef619 commit f01d240

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

.github/workflows/auto-create-release.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ on:
66
push:
77
branches:
88
- release/**
9+
workflow_dispatch:
910

1011
permissions:
1112
contents: write
1213
packages: write
1314

1415
jobs:
1516
release:
16-
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
17+
if: >-
18+
github.event_name == 'workflow_dispatch' ||
19+
(github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/'))
1720
name: Create Release
1821
runs-on: ubuntu-24.04-arm
1922
steps:
@@ -35,8 +38,20 @@ jobs:
3538
run: |
3639
task lint
3740
task git:set-config
38-
task version:tag-release
39-
echo "REL_VERSION=$(task version:get)" >> "$GITHUB_OUTPUT"
41+
REL_VERSION="$(task version:get)"
42+
echo "REL_VERSION=${REL_VERSION}" >> "$GITHUB_OUTPUT"
43+
44+
full_remote_sha="$(git ls-remote --tags origin "refs/tags/${REL_VERSION}" 2>/dev/null | awk '{print $1}' || true)"
45+
if [ -n "${full_remote_sha}" ]; then
46+
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
47+
echo "ℹ️ INFO: Full tag '${REL_VERSION}' already exists; skipping tag creation."
48+
else
49+
echo "❌ ERROR: Full tag '${REL_VERSION}' already exists; aborting" >&2
50+
exit 1
51+
fi
52+
else
53+
task version:tag-release
54+
fi
4055
4156
- name: Install Docker Buildx
4257
uses: docker/setup-buildx-action@v3

0 commit comments

Comments
 (0)