From 08554ea32d520939e49eaab035ab0f678d5f181f Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Wed, 30 Jul 2025 14:46:50 +0200 Subject: [PATCH 1/4] Use generated release notes in GitHub Release template --- golang/publish/github.md.tmpl | 12 +---------- golang/publish/notes.go | 10 +++++++-- golang/publish/publish.sh | 40 +++++++++++++++++++++++------------ 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/golang/publish/github.md.tmpl b/golang/publish/github.md.tmpl index 422502e..bfe9f71 100644 --- a/golang/publish/github.md.tmpl +++ b/golang/publish/github.md.tmpl @@ -1,17 +1,7 @@ The MongoDB Go Driver Team is pleased to release version {{ .ReleaseVersion }} of the official MongoDB Go Driver. -## Release Notes - -This release {description of notable changes}. - -### {Notable Release Feature 1} - -{Description of notable release feature 1} - -*** +{{ .ChangeLog }} For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D{{ .ReleaseVersion }}). -**Full Changelog**: [v{{ .PreviousVersion }}...v{{ .ReleaseVersion }}](https://github.com/mongodb/mongo-go-driver/compare/v{{ .PreviousVersion }}...v{{ .ReleaseVersion }}) - Documentation for the Go Driver can be found on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo?tab=doc) and the [MongoDB documentation site](https://docs.mongodb.com/ecosystem/drivers/go/). BSON library documentation is also available on [pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson?tab=doc). Questions and inquiries can be asked on the [MongoDB Developer Community](https://www.mongodb.com/community/forums/tag/golang). Bugs can be reported in the [Go Driver project in the MongoDB JIRA](https://jira.mongodb.org/secure/CreateIssue!default.jspa?pid=14289) where a list of [current issues](https://jira.mongodb.org/browse/GODRIVER) can be found. Your feedback on the Go Driver is greatly appreciated! diff --git a/golang/publish/notes.go b/golang/publish/notes.go index f6ba986..32f1957 100644 --- a/golang/publish/notes.go +++ b/golang/publish/notes.go @@ -18,8 +18,12 @@ var forumTmpl string // for a Github release and writes it to a file named "github.md". It // also prints the gh command to create a new draft release with those release // notes. -func generateGithubNotes(release, previous string) { +func generateGithubNotes(release, previous, changeLogFile string) { filename := "github.md" + changeLog, err := ioutil.ReadFile(changeLogFile) + if err != nil { + log.Fatalf("Error reading file %q: %v", changeLogFile, err) + } writeTemplate( filename, @@ -27,6 +31,7 @@ func generateGithubNotes(release, previous string) { map[string]any{ "ReleaseVersion": release, "PreviousVersion": previous, + "ChangeLog": string(changeLog), }) fmt.Println() @@ -88,6 +93,7 @@ func writeTemplate(filename, tmplText string, data any) { func main() { version := os.Args[1] prevVersion := os.Args[2] - generateGithubNotes(version, prevVersion) + changeLogFile := os.Args[3] + generateGithubNotes(version, prevVersion, changeLogFile) generateForumNotes(version) } diff --git a/golang/publish/publish.sh b/golang/publish/publish.sh index fcc5569..b3aa1cd 100755 --- a/golang/publish/publish.sh +++ b/golang/publish/publish.sh @@ -9,28 +9,42 @@ else fi echo "DRY_RUN=$DRY_RUN" >> $GITHUB_ENV -# Generate notes -go run notes.go $VERSION $PREV_VERSION -cat forum.md >> $GITHUB_STEP_SUMMARY -rm forum.md - -echo "---" >> $GITHUB_STEP_SUMMARY - -NOTES_FILE=$(pwd)/github.md - # Handle GitHub Release if [ "$PUSH_CHANGES" == "true" ]; then pushd $GITHUB_WORKSPACE || exit 1 TITLE="MongoDB Go Driver ${VERSION}" - gh release create v${VERSION} --draft --verify-tag --title "$TITLE" -F $NOTES_FILE + + # Create draft release with generated release notes + gh release create v${VERSION} --draft --verify-tag --title "$TITLE" --generate-notes + + # Extract generated release notes to file + gh release view v${VERSION} --json body --template '{{ .body }}' >> changelog + + NOTES_FILE=$(pwd)/changelog + + popd || exit 1 + + # Generate release notes + go run notes.go $VERSION $PREV_VERSION $NOTES_FILE + cat forum.md >> $GITHUB_STEP_SUMMARY + rm forum.md + + echo "---" >> $GITHUB_STEP_SUMMARY + + NOTES_FILE=$(pwd)/github.md + + pushd $GITHUB_WORKSPACE || exit 1 + + # Update release notes with generated version and upload release assets + gh release create v${VERSION} -F $NOTES_FILE gh release upload v${VERSION} $RELEASE_ASSETS/*.* JSON="url,tagName,assets,author,createdAt" JQ='.url,.tagName,.author.login,.createdAt,.assets[].name' echo "\## $TITLE" >> $GITHUB_STEP_SUMMARY gh release view --json $JSON --jq $JQ v${VERSION} >> $GITHUB_STEP_SUMMARY + popd || exit 1 else - echo "## Skipping draft release with notes:" >> $GITHUB_STEP_SUMMARY - cat $NOTES_FILE >> $GITHUB_STEP_SUMMARY + echo "## Skipping draft release" >> $GITHUB_STEP_SUMMARY fi -rm $NOTES_FILE \ No newline at end of file +rm $NOTES_FILE From 78a668f48785731a82b3f844dab014428ae30a7e Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 31 Jul 2025 12:37:46 +0200 Subject: [PATCH 2/4] Use os.ReadFile to read changelog --- golang/publish/notes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/golang/publish/notes.go b/golang/publish/notes.go index 32f1957..f439170 100644 --- a/golang/publish/notes.go +++ b/golang/publish/notes.go @@ -20,7 +20,7 @@ var forumTmpl string // notes. func generateGithubNotes(release, previous, changeLogFile string) { filename := "github.md" - changeLog, err := ioutil.ReadFile(changeLogFile) + changeLog, err := os.ReadFile(changeLogFile) if err != nil { log.Fatalf("Error reading file %q: %v", changeLogFile, err) } From ddc5644809be60addab65a69f20898d4133e7616 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 31 Jul 2025 12:38:22 +0200 Subject: [PATCH 3/4] Use gh release edit to update release notes --- golang/publish/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/golang/publish/publish.sh b/golang/publish/publish.sh index b3aa1cd..597028e 100755 --- a/golang/publish/publish.sh +++ b/golang/publish/publish.sh @@ -36,7 +36,7 @@ if [ "$PUSH_CHANGES" == "true" ]; then pushd $GITHUB_WORKSPACE || exit 1 # Update release notes with generated version and upload release assets - gh release create v${VERSION} -F $NOTES_FILE + gh release edit v${VERSION} -F $NOTES_FILE gh release upload v${VERSION} $RELEASE_ASSETS/*.* JSON="url,tagName,assets,author,createdAt" JQ='.url,.tagName,.author.login,.createdAt,.assets[].name' From 8a48f24c6de8b18820c04133d9b3ea0b6e363327 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 31 Jul 2025 12:39:54 +0200 Subject: [PATCH 4/4] Add release highlight section to GitHub notes --- golang/publish/github.md.tmpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/golang/publish/github.md.tmpl b/golang/publish/github.md.tmpl index bfe9f71..f695723 100644 --- a/golang/publish/github.md.tmpl +++ b/golang/publish/github.md.tmpl @@ -1,5 +1,9 @@ The MongoDB Go Driver Team is pleased to release version {{ .ReleaseVersion }} of the official MongoDB Go Driver. +## Release Highlights + +This release {description of notable changes}. + {{ .ChangeLog }} For a full list of tickets included in this release, please see the [list of fixed issues](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20fixVersion%3D{{ .ReleaseVersion }}).