Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions cmd/release/post-release_pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,14 @@ func (pc *PustPostPullRequest) Run(ctx context.Context, yesToPrompt, dryRun bool
majorMinor := semver.MajorMinor(pc.cfg.TargetVer)
isMinorRelease := strings.TrimPrefix(pc.cfg.TargetVer, majorMinor) == ".0"
if isMinorRelease {
// The full changelog of a minor release would exceed the maximum size
// of a GitHub release body, so use the same short body as the
// "Prepare for release" PR and leave it up to the maintainers to
// replace it with the release announcement.
const instructionMsg = "<!-- Copy the slack announcement message to here and adapt emojis -->\n\n"
if _, err := releaseSummaryFileContent.WriteString(instructionMsg); err != nil {
if _, err := releaseSummaryFileContent.WriteString(instructionMsg + prBodyMsg); err != nil {
return fmt.Errorf("unable to write instruction message to release summary file: %w", err)
}

// For minor releases, use the -pr-body.txt file
prBodyFileName := fmt.Sprintf("%s-pr-body.txt", pc.cfg.TargetVer)
prBodyFile := filepath.Join(pc.cfg.RepoDirectory, prBodyFileName)
prBodyFileContent, err := os.Open(prBodyFile)
if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("error reading %s file: %w", prBodyFileName, err)
} else {
return fmt.Errorf("%s file not found, it needs to be present to create a release on GitHub for minor releases", prBodyFileName)
}
}
defer prBodyFileContent.Close()

if _, err := io.Copy(releaseSummaryFileContent, prBodyFileContent); err != nil {
return fmt.Errorf("unable to copy the pr-body file content into the release summary file: %w", err)
}
} else {
// Generate release summary
changelogFile := filepath.Join(pc.cfg.RepoDirectory, "CHANGELOG.md")
Expand Down
7 changes: 6 additions & 1 deletion cmd/release/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import (
github2 "github.com/google/go-github/v62/github"
)

// prBodyMsg is the body used for the "Prepare for release" PR. It is also
// re-used as the body of the draft GitHub release for minor releases, since
// the full changelog would exceed the maximum size of a release body.
const prBodyMsg = "\nSee the included CHANGELOG.md for a full list of changes.\n"

type PushPullRequest struct {
cfg *ReleaseConfig
}
Expand Down Expand Up @@ -144,7 +149,7 @@ func (pc *PushPullRequest) generateSummaryFile() (string, string, error) {
}
defer prBodyFileContent.Close()

prBodyFileContent.WriteString("\nSee the included CHANGELOG.md for a full list of changes.\n")
prBodyFileContent.WriteString(prBodyMsg)

return prTitle, prBodyFileName, err
}
Loading