Skip to content

Commit

Permalink
Support continuous report generation
Browse files Browse the repository at this point in the history
Generate CHANGELOG.md and CHANGELOG_CURRENT.md with `make reno-report` in order
to commit them on pre-release step.

Pick up CHANGELOG_CURRENT.md on `make gorelease`
  • Loading branch information
hairyhum committed Apr 10, 2024
1 parent 4b654a3 commit a7e2098
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/dist
**/*.swp
/.idea
/releasenotes/config.yaml
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ REGISTRY ?= kanisterio
ARCH ?= amd64

# This version-strategy uses git tags to set the version string
VERSION := $(shell git describe --tags --always --dirty)
VERSION ?= $(shell git describe --tags --always --dirty)
#
# This version-strategy uses a manual value to set the version string
#VERSION := 1.2.3
Expand Down Expand Up @@ -70,6 +70,10 @@ GOBORING ?= ""

CONTROLLER_TOOLS_VERSION ?= "v0.12.0"

## Changelog file for goreleaser

CHANGELOG_FILE ?= ./CHANGELOG_CURRENT.md

# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-container' rule.
# If you want to build AND push all containers, see the 'all-push' rule.
Expand Down Expand Up @@ -236,7 +240,7 @@ release-helm:
@/bin/bash ./build/release_helm.sh $(VERSION)

gorelease:
@$(MAKE) run CMD="./build/gorelease.sh $(CHANGELOG_FILE)"
@$(MAKE) run CMD="CHANGELOG_FILE=$(CHANGELOG_FILE) ./build/gorelease.sh"

release-snapshot:
@$(MAKE) run CMD="GORELEASER_CURRENT_TAG=v9.99.9-dev goreleaser --debug release --rm-dist --snapshot --timeout=60m0s"
Expand Down Expand Up @@ -288,4 +292,4 @@ reno-new:
@$(MAKE) run CMD="reno new $(note)"

reno-report:
@$(MAKE) run CMD="reno report > ./CHANGELOG.md"
@$(MAKE) run CMD="./build/reno_report.sh $(VERSION)"
31 changes: 31 additions & 0 deletions build/reno_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

version=${1:-"''"}

## Latest notes should go to current version
## We generate report before tagging the repo, so we need to set this version here
# echo "unreleased_version_title: ${version}" > reno.yaml
sed "s/unreleased_version_title: ''/unreleased_version_title: ${version}/g" reno.yaml > releasenotes/config.yaml


# Update changelog for all versions:

## Generate rst report
echo reno report --output ./CHANGELOG.rst
reno report --output ./CHANGELOG.rst

## Convert rst to markdown
rst2md ./CHANGELOG.rst --output ./CHANGELOG.md

# Generate changelof for current version only:

## Reno `--version` flag does not support "unreleased" setting and requires specific version, event if it's dynamic
## To generate dynamic version, use `reno list`.
## It will be replaced by `unreleased_version_title` setting in the actual report file
UNRELEASED_VERSION=$(reno list 2>/dev/null | grep -E "^[0-9]+\.[0-9]+\.[0-9]+\-[0-9]+")

## Generate rst report
echo reno report --version=${UNRELEASED_VERSION} --output ./CHANGELOG_CURRENT.rst
reno report --version=${UNRELEASED_VERSION} --output ./CHANGELOG_CURRENT.rst
## Convert rst to markdown
rst2md ./CHANGELOG_CURRENT.rst --output ./CHANGELOG_CURRENT.md
2 changes: 1 addition & 1 deletion docker/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN GOBIN=/usr/local/bin go install github.com/ahmetb/gen-crd-api-reference-docs

RUN apt-get update && apt-get install -y pip

RUN pip install reno
RUN pip install reno nb2plots

ENV CGO_ENABLED=0 \
GO111MODULE="on" \
Expand Down
14 changes: 8 additions & 6 deletions releasenotes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ When reviewing a PR, a reviewer should check if there are change notes added if
Changelog can be generated using:

```
reno report ./ > CHANGELOG.md
make reno-report
```
OR
or to mark specific current version:
```
make reno-report
make reno-report VERSION=$CURRENT_VERSION
```

This will create a CHANGELOG.md file with changes from committed release notes.
This will create a CHANGELOG.md and CHANGELOG_CURRENT.md files with changes from committed release notes.
CHANGELOG_CURRENT.md only containing changes for the current version.

It can later be passed to goreleaser build as `CHANGELOG_FILE` variable:
It will be used when running goreleaser build using make (will use `CHANGELOG_CURRENT.md` by default):

```
make gorelease CHANGELOG_FILE=./CHANGELOG.md
make gorelease CHANGELOG_FILE=./CHANGELOG_CURRENT.md
```

2 changes: 2 additions & 0 deletions releasenotes/config.yaml → reno.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ sections:
- [deprecations, Deprecations]
- [other, Other Notes]

unreleased_version_title: ''

prelude_section_name: release_summary
template: |
---
Expand Down

0 comments on commit a7e2098

Please sign in to comment.