Skip to content

Commit 76a03de

Browse files
Syncs fork dev with main repo
but also adds a check for drafts
1 parent 83da244 commit 76a03de

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/release-drafter.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ on:
88
- 'release_*'
99
pull_request_target:
1010
types: [opened, reopened, synchronize]
11+
workflow_dispatch:
12+
inputs:
13+
version:
14+
description: 'Version to use for the release draft (optional)'
15+
required: false
16+
type: string
1117

1218
permissions:
1319
contents: read
@@ -34,9 +40,38 @@ jobs:
3440
echo "version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
3541
echo "Galaxy release version: ${RELEASE_VERSION}"
3642
43+
- name: Check if we should update draft
44+
id: check-draft
45+
run: |
46+
VERSION="${{ inputs.version || steps.galaxy-version.outputs.version }}"
47+
48+
# Check if this version is already published
49+
PUBLISHED=$(gh release view "v${VERSION}" --json isDraft --jq '.isDraft' 2>/dev/null || echo "not_found")
50+
51+
if [ "$PUBLISHED" = "false" ]; then
52+
echo "Published release v${VERSION} already exists. Skipping."
53+
echo "skip=true" >> $GITHUB_OUTPUT
54+
exit 0
55+
fi
56+
57+
# Check if a draft exists for a DIFFERENT version (only one draft at a time)
58+
EXISTING_DRAFT=$(gh release list --limit 50 --json tagName,isDraft --jq '.[] | select(.isDraft == true) | .tagName' | head -1)
59+
60+
if [ -n "$EXISTING_DRAFT" ] && [ "$EXISTING_DRAFT" != "v${VERSION}" ]; then
61+
echo "Draft release $EXISTING_DRAFT already exists (for different version). Skipping v${VERSION}."
62+
echo "Only one draft release at a time is supported."
63+
echo "skip=true" >> $GITHUB_OUTPUT
64+
else
65+
echo "Proceeding with draft for v${VERSION}."
66+
echo "skip=false" >> $GITHUB_OUTPUT
67+
fi
68+
env:
69+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
3771
- uses: release-drafter/release-drafter@v6
72+
if: steps.check-draft.outputs.skip == 'false'
3873
with:
3974
config-name: release-drafter.yml
40-
version: ${{ steps.galaxy-version.outputs.version }}
75+
version: ${{ inputs.version || steps.galaxy-version.outputs.version }}
4176
env:
4277
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)