Skip to content

Commit

Permalink
Determine previous tag
Browse files Browse the repository at this point in the history
  • Loading branch information
dippynark committed Jan 9, 2024
1 parent fef5c3b commit b7648d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md
1. Create a new release branch from main: `git checkout -b release-<MAJOR.MINOR>`
2. Push the new branch to the remote repository: ` git push --set-upstream origin release-<MAJOR.MINOR>`
3. Fetch all tags from the remote: `git fetch --all --tags`
4. Generate the release notes from the previous tag: `go run ./hack/notes --from vMAJOR.MINOR.PATCH`
4. Generate the release notes: `go run ./hack/notes`
5. Create a new release in GitHub from the release branch, pasting the generated release notes
19 changes: 16 additions & 3 deletions hack/notes/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ func main() {
}

func run(from, to string) error {
if from == "" {
return fmt.Errorf("Git reference to start from must be specified")
}
if to == "" {
to = "HEAD"
}
var err error
if from == "" {
from, err = previousTag(to)
if err != nil {
return err
}
}

cmd := exec.Command("git", "rev-list", fmt.Sprintf("%s..%s", from, to), "--pretty=format:%B")
out, err := cmd.CombinedOutput()
Expand Down Expand Up @@ -106,3 +110,12 @@ func run(from, to string) error {

return nil
}

func previousTag(to string) (string, error) {
cmd := exec.Command("git", "describe", "--abbrev=0", "--tags", fmt.Sprintf("%s^", to))
out, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
return strings.TrimSpace(string(out)), nil
}

0 comments on commit b7648d9

Please sign in to comment.