Skip to content

Commit c579d46

Browse files
authored
chore: fix release previous tag auto-selection (#607)
GitHub's (un-documented) algorithm for automatically selecting the previous release tag when generating release notes appears to be hindered by the presence of our nested go module tags. So we explicitly select the previous non-pre, non-draft release as the previous tag.
1 parent 8c18508 commit c579d46

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,25 @@ jobs:
6363
# If the release does not yet exist, create a draft release targeting this commit.
6464
- name: Create draft release
6565
if: github.event_name == 'push' && steps.version.outputs.exists == 'false'
66+
# We explicitly set the notes start tag because GitHub otherwise does not make the right
67+
# decision (it is very sensitive to non-version tags being present in the repository, and
68+
# the Go nexted modules tags hinder it). We pick the latest non-prerelease tag as the start
69+
# tag, always.
6670
run: |-
67-
gh release create '${{ steps.version.outputs.tag }}' --draft --generate-notes --target='${{ github.sha }}' --title='${{ steps.version.outputs.tag }}' ${{ contains(steps.version.outputs.tag, '-') && '--prerelease' || '' }}
71+
lastTag=$(gh release list \
72+
--exclude-drafts \
73+
--exclude-pre-releases \
74+
--limit=1 \
75+
--json=tagName \
76+
--template="{{ (index . 0).tagName }}" \
77+
)
78+
gh release create '${{ steps.version.outputs.tag }}' \
79+
--draft \
80+
--generate-notes \
81+
--target='${{ github.sha }}' \
82+
--title='${{ steps.version.outputs.tag }}' \
83+
--notes-start-tag="${lastTag}" \
84+
${{ contains(steps.version.outputs.tag, '-') && '--prerelease' || '' }}
6885
env:
6986
GH_TOKEN: ${{ github.token }}
7087

0 commit comments

Comments
 (0)