diff --git a/cmd/release/post-release_pull_request.go b/cmd/release/post-release_pull_request.go index 69f6eb7..df3812e 100644 --- a/cmd/release/post-release_pull_request.go +++ b/cmd/release/post-release_pull_request.go @@ -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 = "\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") diff --git a/cmd/release/pull_request.go b/cmd/release/pull_request.go index 6a5bff1..89943f1 100644 --- a/cmd/release/pull_request.go +++ b/cmd/release/pull_request.go @@ -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 } @@ -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 }