Skip to content

Commit 947170d

Browse files
Add release-notes generation tooling (#2305)
Signed-off-by: Prajyot Parab <[email protected]>
1 parent 982d67e commit 947170d

File tree

7 files changed

+278
-26
lines changed

7 files changed

+278
-26
lines changed

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,38 @@ CONVERSION_VERIFIER := $(TOOLS_BIN_DIR)/conversion-verifier
5050
SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest
5151
GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck
5252
TRIVY := $(TOOLS_BIN_DIR)/trivy
53+
RELEASE_NOTES := $(TOOLS_BIN_DIR)/release-notes
5354

5455
STAGING_REGISTRY ?= gcr.io/k8s-staging-capi-ibmcloud
5556
STAGING_BUCKET ?= artifacts.k8s-staging-capi-ibmcloud.appspot.com
5657
BUCKET ?= $(STAGING_BUCKET)
5758
PROD_REGISTRY := registry.k8s.io/capi-ibmcloud
5859
REGISTRY ?= $(STAGING_REGISTRY)
5960
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
61+
ifneq (,$(findstring -,$(RELEASE_TAG)))
62+
PRE_RELEASE=true
63+
endif
64+
FULL_VERSION := $(RELEASE_TAG:v%=%)
65+
MAJOR_VERSION := $(shell echo $(FULL_VERSION) | sed -E 's/^([0-9]+)\.([0-9]+)\.([0-9]+).*/\1/')
66+
MINOR_VERSION := $(shell echo $(FULL_VERSION) | sed -E 's/^([0-9]+)\.([0-9]+)\.([0-9]+).*/\2/')
67+
PATCH_VERSION := $(shell echo $(FULL_VERSION) | sed -E 's/^([0-9]+)\.([0-9]+)\.([0-9]+).*/\3/')
68+
# if the release tag is a .0 version, use the main branch
69+
ifeq ($(PATCH_VERSION),0)
70+
RELEASE_BRANCH ?= main
71+
else
72+
RELEASE_BRANCH ?= release-$(MAJOR_VERSION).$(MINOR_VERSION)
73+
endif
74+
PREVIOUS_TAG ?= $(shell git tag --merged $(GIT_REMOTE_NAME)/$(RELEASE_BRANCH) -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | sort -V | tail -n 1 2>/dev/null)
75+
START_SHA ?= $(shell git rev-list -n 1 $(PREVIOUS_TAG) 2>/dev/null)
76+
END_SHA ?= $(shell git rev-parse $(GIT_REMOTE_NAME)/$(RELEASE_BRANCH) 2>/dev/null)
77+
GIT_REPO_NAME ?= cluster-api-provider-ibmcloud
78+
GIT_ORG_NAME ?= kubernetes-sigs
79+
GIT_REMOTE_NAME ?= upstream
80+
6081
PULL_BASE_REF ?= $(RELEASE_TAG) # PULL_BASE_REF will be provided by Prow
6182
RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
6283
RELEASE_DIR := out
84+
RELEASE_NOTES_DIR := CHANGELOG
6385
OUTPUT_TYPE ?= type=registry
6486

6587
# Go
@@ -271,6 +293,9 @@ test-cover: setup-envtest## Run tests with code coverage and code generate repor
271293
$(RELEASE_DIR):
272294
mkdir -p $@
273295

296+
$(RELEASE_NOTES_DIR):
297+
mkdir -p $@
298+
274299
$(ARTIFACTS):
275300
mkdir -p $@
276301

@@ -322,6 +347,19 @@ release-staging: ## Build and push container images to the staging bucket
322347
$(MAKE) release-binaries
323348
$(MAKE) upload-staging-artifacts
324349

350+
.PHONY: release-notes
351+
release-notes: $(RELEASE_NOTES) $(RELEASE_NOTES_DIR) ## Generate/update release notes.
352+
@echo "generating release notes from $(PREVIOUS_TAG) to $(RELEASE_TAG) with start sha $(START_SHA) and end sha $(END_SHA)"
353+
@if [ -n "${PRE_RELEASE}" ]; then \
354+
echo ":rotating_light: This is a RELEASE CANDIDATE. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/new)." > $(RELEASE_NOTES_DIR)/release-notes-$(RELEASE_TAG).md; \
355+
$(RELEASE_NOTES) --org $(GIT_ORG_NAME) --repo $(GIT_REPO_NAME) --branch $(RELEASE_BRANCH) --required-author "" --start-sha $(START_SHA) --end-sha $(END_SHA) --markdown-links true --dependencies false --output $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
356+
(cat $(RELEASE_NOTES_DIR)/release-notes-$(RELEASE_TAG).md; echo ""; cat $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md) > $(RELEASE_NOTES_DIR)/tmp-release-notes.md; \
357+
mv $(RELEASE_NOTES_DIR)/tmp-release-notes.md $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
358+
rm -f $(RELEASE_NOTES_DIR)/release-notes-$(RELEASE_TAG).md; \
359+
else \
360+
$(RELEASE_NOTES) --org $(GIT_ORG_NAME) --repo $(GIT_REPO_NAME) --branch $(RELEASE_BRANCH) --required-author "" --start-sha $(START_SHA) --end-sha $(END_SHA) --markdown-links true --output $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
361+
fi
362+
325363
.PHONY: staging-manifests
326364
staging-manifests:
327365
$(MAKE) $(RELEASE_DIR)/$(CORE_MANIFEST_FILE).yaml TAG=$(RELEASE_ALIAS_TAG)

docs/book/src/developer/release.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
git push origin v0.2.0-alpha.3
99
```
1010
- Wait for the google cloud build to be finished
11+
- [Prepare release notes](#prepare-release-notes)
1112
- Create a draft release with release notes for the tag
1213
- Tick the prerelease checkbox
1314
- Download the artifacts once cloud build is finished
@@ -31,6 +32,7 @@
3132
git push origin v0.1.0
3233
```
3334
- Wait for the google cloud build to be finished
35+
- [Prepare release notes](#prepare-release-notes)
3436
- Create a draft release with release notes for the tag
3537
- Perform the [image promotion process](https://github.com/kubernetes/k8s.io/tree/main/k8s.gcr.io#image-promoter):
3638
- Clone and pull down the latest from [kubernetes/k8s.io](https://github.com/kubernetes/k8s.io)
@@ -49,3 +51,37 @@
4951
- Publish the drafted release
5052

5153
> Note: In the above instructions, `v0.1.0` is the version/tag is being released
54+
55+
### Prepare release notes
56+
57+
1. If you don't have a GitHub token, create one by going to your GitHub settings, in [Personal access tokens](https://github.com/settings/tokens). Make sure you give the token the `repo` scope.
58+
59+
2. Fetch the latest changes from upstream and check out the `main` branch:
60+
61+
```sh
62+
git fetch upstream
63+
git checkout main
64+
```
65+
66+
3. Generate release notes by running the following commands on the `main` branch:
67+
68+
```sh
69+
export GITHUB_TOKEN=<your GH token>
70+
export RELEASE_TAG=v1.2.3 # change this to the tag of the release to be cut
71+
make release-notes
72+
```
73+
74+
4. Review the release notes file generated at `CHANGELOG/<RELEASE_TAG>.md` and make any necessary changes:
75+
76+
- Move items out of "Uncategorized" into an appropriate section.
77+
- Change anything attributed to "k8s-cherrypick-robot" to credit the original author.
78+
- Fix any typos or other errors.
79+
- Add the following section with a link to the full diff:
80+
```md
81+
## The image for this release is:
82+
registry.k8s.io/capi-ibmcloud/cluster-api-ibmcloud-controller:<RELEASE_TAG>
83+
84+
<!-- markdown-link-check-disable-next-line -->
85+
Full Changelog: https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/compare/v0.9.0...v0.10.0
86+
```
87+
Be sure to replace the versions in the URL with the appropriate tags.

hack/tools/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,7 @@ $(GOVULNCHECK): $(BIN_DIR) go.mod go.sum ## Build a local copy of govulncheck.
129129
TRIVY := $(BIN_DIR)/trivy
130130
$(TRIVY): $(BIN_DIR) go.mod go.sum ## Build a local copy of trivy.
131131
go build -tags=capibmtools -o $@ github.com/aquasecurity/trivy/cmd/trivy
132+
133+
RELEASE_NOTES := $(BIN_DIR)/release-notes
134+
$(RELEASE_NOTES): $(BIN_DIR) go.mod go.sum ## Build a local copy of release-notes.
135+
go build -tags=capibmtools -o $@ k8s.io/release/cmd/release-notes

0 commit comments

Comments
 (0)