Skip to content

Commit dd1b0f4

Browse files
authored
fix: handle pre-existing draft release in host job (#116)
The plan job calls `dist host --steps=create` which pre-creates the GitHub release as a draft. When the host job later runs `gh release create`, it fails with "a release with the same tag name already exists", which blocks the custom-publish-homebrew job from running. Fix by checking if the release already exists and using `gh release edit` + `gh release upload --clobber` instead of `gh release create` in that case. Co-authored-by: Eddie A Tejeda <669988+eddietejeda@users.noreply.github.com>
1 parent f6c2782 commit dd1b0f4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,14 @@ jobs:
276276
# Write and read notes from a file to avoid quoting breaking things
277277
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
278278
279-
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
279+
# The plan job runs `dist host --steps=create` which pre-creates the draft release.
280+
# If the release already exists, edit it in place; otherwise create it fresh.
281+
if gh release view "${{ needs.plan.outputs.tag }}" > /dev/null 2>&1; then
282+
gh release edit "${{ needs.plan.outputs.tag }}" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt"
283+
gh release upload "${{ needs.plan.outputs.tag }}" artifacts/* --clobber
284+
else
285+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
286+
fi
280287
281288
custom-publish-homebrew:
282289
needs:

0 commit comments

Comments
 (0)