Skip to content

Commit bf9d9f5

Browse files
authored
Merge pull request #3879 from jooby-project/ciautomate
ci: automate GitHub release notes generation
2 parents 076d333 + 10ef8a1 commit bf9d9f5

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

.github/workflows/maven-central.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: mvn clean install -DskipTests -q
3030
- name: Set up Maven Central
3131
uses: actions/setup-java@v4
32-
with: # running setup-java again overwrites the settings.xml
32+
with:
3333
java-version: 21
3434
distribution: 'temurin'
3535
server-id: central
@@ -44,3 +44,60 @@ jobs:
4444
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
4545
CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }}
4646
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
47+
48+
update-release-notes:
49+
name: Update GitHub Release Notes
50+
needs: release
51+
runs-on: ubuntu-latest
52+
permissions:
53+
contents: write
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
with:
58+
fetch-depth: 0
59+
60+
- name: Generate and Update Release Notes
61+
continue-on-error: true
62+
env:
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: |
65+
CURRENT_TAG=${{ github.ref_name }}
66+
VERSION_NUM=${CURRENT_TAG#v}
67+
68+
# Calculate previous tag using version sorting
69+
git fetch --tags --force
70+
PREV_TAG=$(git tag --sort=-v:refname | grep -A 1 "^${CURRENT_TAG}$" | tail -n 1)
71+
72+
# Fetch milestone ID for the link
73+
MILESTONE_ID=$(gh api repos/${{ github.repository }}/milestones -q ".[] | select(.title==\"$VERSION_NUM\") | .number")
74+
75+
# Fetch closed issues and PRs for this milestone, excluding the dependencies label
76+
gh issue list \
77+
--repo ${{ github.repository }} \
78+
--search "milestone:\"$VERSION_NUM\" is:closed -label:dependencies" \
79+
--limit 100 \
80+
--json title,url \
81+
--jq '.[] | "- [\(.title)](\(.url))"' > milestone_issues.md
82+
83+
# Assemble the final changelog.md
84+
cat << EOF > changelog.md
85+
$(cat milestone_issues.md)
86+
87+
## Changes
88+
- [$CURRENT_TAG](https://github.com/jooby-project/jooby/tree/$CURRENT_TAG)
89+
- [Issues](https://github.com/jooby-project/jooby/milestone/$MILESTONE_ID?closed=1)
90+
- [Changelog](https://github.com/jooby-project/jooby/compare/$PREV_TAG...$CURRENT_TAG)
91+
- [Dependencies](https://github.com/jooby-project/jooby/pulls?q=is%3Apr+label%3Adependencies+is%3Aclosed+milestone%3A$VERSION_NUM)
92+
93+
## Support my work
94+
- [Sponsor](https://github.com/sponsors/jknack)
95+
96+
### Sponsors
97+
- [@premium-minds](https://github.com/premium-minds)
98+
- [@agentgt](https://github.com/agentgt)
99+
- [@tipsy](https://github.com/tipsy)
100+
EOF
101+
102+
# Overwrite the existing release notes
103+
gh release edit $CURRENT_TAG --notes-file changelog.md

0 commit comments

Comments
 (0)