From 4cf976d20e6636d1843fc450debc8fdc74f47ba8 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Sun, 11 Aug 2024 16:13:19 -0400 Subject: [PATCH] Add new-changelog to Makefile Signed-off-by: Tiger Kaovilai --- .github/pull_request_template.md | 2 +- Makefile | 15 ++++++++++++++- site/content/docs/main/code-standards.md | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a908648a44..53d631d761 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -9,5 +9,5 @@ Fixes #(issue) # Please indicate you've done the following: - [ ] [Accepted the DCO](https://velero.io/docs/v1.5/code-standards/#dco-sign-off). Commits without the DCO will delay acceptance. -- [ ] [Created a changelog file](https://velero.io/docs/v1.5/code-standards/#adding-a-changelog) or added `/kind changelog-not-required` as a comment on this pull request. +- [ ] [Created a changelog file](https://velero.io/docs/main/code-standards/#adding-a-changelog) or added `/kind changelog-not-required` as a comment on this pull request. - [ ] Updated the corresponding documentation in `site/content/docs/main`. diff --git a/Makefile b/Makefile index 8950bbc1b2..e6505608cd 100644 --- a/Makefile +++ b/Makefile @@ -377,4 +377,17 @@ test-perf: local $(MAKE) -e VERSION=$(VERSION) -C test/ run-perf go-generate: - go generate ./pkg/... \ No newline at end of file + go generate ./pkg/... + +# requires an authenticated gh cli +# gh: https://cli.github.com/ https://github.com/cli/cli#installation +new-changelog: GH_LOGIN ?= $(shell gh pr view --json author --jq .author.login 2> /dev/null) +new-changelog: GH_PR ?= $(shell gh pr view --json number --jq .number 2> /dev/null) +new-changelog: CHANGELOG_BODY ?= "$(shell git log --format="%s" -1)" +new-changelog: + @if [ "$(GH_LOGIN)" = "" ]; then \ + echo "branch does not have PR or cli not logged in, try 'gh auth login' or 'gh pr create'"; \ + exit 1; \ + fi + mkdir -p ./unreleased/ + echo $(CHANGELOG_BODY) > ./unreleased/$(GH_PR)-$(GH_LOGIN) \ No newline at end of file diff --git a/site/content/docs/main/code-standards.md b/site/content/docs/main/code-standards.md index 36984612f7..5825b63fbc 100644 --- a/site/content/docs/main/code-standards.md +++ b/site/content/docs/main/code-standards.md @@ -38,6 +38,8 @@ changelog. Add that to the PR. +A command to do this is `make new-changelog` + If a PR does not warrant a changelog, the CI check for a changelog can be skipped by applying a `changelog-not-required` label on the PR. If you are making a PR on a release branch, you should still make a new file in the `changelogs/unreleased` folder on the release branch for your change. ## Copyright header