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
1218permissions :
1319 contents : read
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