-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Pre Publish | ||
description: Pre Publish Action for Go Driver | ||
inputs: | ||
version: | ||
description: The published version | ||
required: true | ||
push_changes: | ||
description: Whether to push the changes | ||
default: "true" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: mongodb-labs/drivers-github-tools/bump-version@v2 | ||
with: | ||
version: ${{ inputs.version }} | ||
version_bump_script: "go run ${{ github.action_path }}/bump-version.go" | ||
commit_template: "BUMP v${VERSION}" | ||
push_commit: ${{ inputs.push_changes }} | ||
- uses: mongodb-labs/drivers-github-tools/tag-version@v2 | ||
with: | ||
version: v${{ inputs.version }} | ||
push_tag: ${{ inputs.push_changes }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
) | ||
|
||
const ( | ||
versionFile = "version/version.go" | ||
prefix = `// Copyright (C) MongoDB, Inc. 2017-present. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. You may obtain | ||
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// Package version defines the Go Driver version. | ||
package version // import "go.mongodb.org/mongo-driver/version" | ||
// Driver is the current version of the driver. | ||
` | ||
) | ||
|
||
func main() { | ||
repoDir, err := os.Getwd() | ||
versionFilePath := path.Join(repoDir, versionFile) | ||
|
||
writeFile, err := os.OpenFile(versionFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
text := prefix + "var Driver = \"" + os.Args[1] + "\"\n" | ||
fmt.Fprint(writeFile, text) | ||
writeFile.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Publish | ||
description: Publish Go Driver Release | ||
inputs: | ||
version: | ||
description: The published version | ||
required: true | ||
prev_version: | ||
description: The previous version | ||
required: true | ||
silk_asset_group: | ||
description: The Silk Asset Group | ||
required: true | ||
evergreen_project: | ||
description: The evergreen project name. | ||
required: true | ||
push_changes: | ||
description: Whether to push the changes | ||
default: "true" | ||
token: | ||
description: The GitHub token | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Get the evergreen commit | ||
id: evergreen-commit | ||
shell: bash | ||
run: | | ||
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | ||
- uses: mongodb-labs/drivers-github-tools/full-report@v2 | ||
with: | ||
product_name: mongo-go-driver | ||
release_version: ${{ inputs.version }} | ||
silk_asset_group: ${{ inputs.silk_asset_group }} | ||
evergreen_project: ${{ inputs.evergreen_project }} | ||
evergreen_commit: ${{ steps.evergreen-commit.outputs.commit }} | ||
security_report_location: ${{ env.SECURITY_REPORT_URL }} | ||
token: ${{ inputs.token }} | ||
- name: Publish GitHub Release | ||
shell: bash -eux {0} | ||
working-directory: ${{ github.action_path }} | ||
env: | ||
VERSION: ${{ inputs.version }} | ||
PREV_VERSION: ${{ inputs.prev_version }} | ||
PUSH_CHANGES: ${{ inputs.push_changes }} | ||
GH_TOKEN: ${{ inputs.token }} | ||
run: ./publish.sh | ||
- name: Upload S3 assets | ||
uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2 | ||
with: | ||
version: ${{ inputs.version }} | ||
product_name: mongo-go-driver | ||
dry_run: ${{ env.DRY_RUN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
\## MongoDB Go Driver {{ .ReleaseVersion }} Released | ||
|
||
The MongoDB Go Driver Team is pleased to release version {{ .ReleaseVersion }} of the \[MongoDB Go Driver](https://github.com/mongodb/mongo-go-driver). | ||
|
||
This release {description of notable changes}. For more information please see the \[{{ .ReleaseVersion }} release notes](https://github.com/mongodb/mongo-go-driver/releases/tag/v{{ .ReleaseVersion }}). | ||
|
||
You can obtain the driver source from GitHub under the \[v{{ .ReleaseVersion }} tag](https://github.com/mongodb/mongo-go-driver/tree/v{{ .ReleaseVersion }}). | ||
|
||
Documentation for the Go driver can be found on \[pkg.go.dev](https://pkg.go.dev/go.mongodb.org/mongo-driver/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/bson?tab=doc). | ||
Questions and inquiries can be asked on the \[MongoDB Developer Community](https://community.mongodb.com/). | ||
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! | ||
|
||
Thank you,\ | ||
The Go Driver Team |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
The MongoDB Go Driver Team is pleased to release version {{ .ReleaseVersion }} of the official Go driver. | ||
|
||
## Release Notes | ||
|
||
This release {description of notable changes}. | ||
|
||
### {Notable Release Feature 1} | ||
|
||
{Description of notable release feature 1} | ||
|
||
*** | ||
|
||
For a full list of tickets included in this release, please see the links below: | ||
|
||
* [Projects](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3Depic%20and%20status%20%3D%20Closed%20and%20fixVersion%3D{{ .ReleaseVersion }}) | ||
* [New Features](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22new%20feature%22%20and%20status%20%3D%20Closed%20and%20fixVersion%3D{{ .ReleaseVersion }}) | ||
* [Improvements](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3Dimprovement%20and%20status%20%3D%20Closed%20and%20fixVersion%3D{{ .ReleaseVersion }}) | ||
* [Bugs](https://jira.mongodb.org/issues/?jql=project%3DGODRIVER%20and%20type%3DBug%20and%20status%3Dclosed%20and%20fixVersion%3D{{ .ReleaseVersion }}) | ||
* [Tasks](https://jira.mongodb.org/issues/?jql=project%3Dgodriver%20and%20type%3D%22task%22%20and%20status%20%3D%20Closed%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/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/bson?tab=doc). Questions and inquiries can be asked on the [MongoDB Developer Community](https://community.mongodb.com/). 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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package main | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"log" | ||
"os" | ||
"text/template" | ||
) | ||
|
||
//go:embed github.md.tmpl | ||
var githubTmpl string | ||
|
||
//go:embed forum.md.tmpl | ||
var forumTmpl string | ||
|
||
// generateGithubNotes generates a partially filled out release notes template | ||
// 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) { | ||
filename := "github.md" | ||
|
||
writeTemplate( | ||
filename, | ||
githubTmpl, | ||
map[string]any{ | ||
"ReleaseVersion": release, | ||
"PreviousVersion": previous, | ||
}) | ||
|
||
fmt.Println() | ||
fmt.Print( | ||
`Wrote Github notes template to "`, | ||
filename, | ||
`".`, | ||
"\n") | ||
fmt.Println("Fill out any missing information and run the following command to create the Github release:") | ||
fmt.Println() | ||
fmt.Println( | ||
"\tgh auth refresh && gh release create v%[1]s --verify-tag --draft -R 'mongodb/mongo-go-driver' -t 'MongoDB Go Driver %[1]s' -F '%[2]s'", | ||
release, | ||
filename) | ||
} | ||
|
||
// generateForumNotes generates a partially filled out release notes template | ||
// for a MongoDB community forum release post and writes it to a file named | ||
// "forum.md". | ||
func generateForumNotes(version string) { | ||
data := map[string]any{ | ||
"ReleaseVersion": version, | ||
} | ||
|
||
forumFilename := "forum.md" | ||
writeTemplate( | ||
forumFilename, | ||
forumTmpl, | ||
data) | ||
|
||
fmt.Println() | ||
fmt.Print( | ||
`Wrote MongoDB community forum notes template to "`, | ||
forumFilename, | ||
`".`, | ||
"\n") | ||
fmt.Println("Fill out any missing information and paste the contents into a new MongoDB community forum post in section:") | ||
fmt.Println("https://www.mongodb.com/community/forums/c/announcements/driver-releases/110") | ||
} | ||
|
||
func writeTemplate(filename, tmplText string, data any) { | ||
tmpl, err := template.New(filename).Parse(tmplText) | ||
if err != nil { | ||
log.Fatalf("Error creating new template for %q: %v", filename, err) | ||
} | ||
|
||
f, err := os.Create(filename) | ||
if err != nil { | ||
log.Fatalf("Error creating file %q: %v", filename, err) | ||
} | ||
defer f.Close() | ||
|
||
err = tmpl.Execute(f, data) | ||
if err != nil { | ||
log.Fatalf("Error executing template for %q: %v", filename, err) | ||
} | ||
} | ||
|
||
func main() { | ||
version := os.Args[1] | ||
prevVersion := os.Args[2] | ||
generateGithubNotes(version, prevVersion) | ||
generateForumNotes(version) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /bin/bash | ||
set -eux | ||
|
||
# Handle DRY_RUN | ||
if [ "$PUSH_CHANGES" != "true" ]; then | ||
export DRY_RUN=true | ||
else | ||
export DRY_RUN=false | ||
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 | ||
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 | ||
fi | ||
rm $NOTES_FILE |