Skip to content

Commit

Permalink
backport changelog automation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali authored and schmichael committed Sep 20, 2021
1 parent 967cb75 commit e8d0cd6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
56 changes: 56 additions & 0 deletions .changelog/changelog.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{- if .NotesByType.feature }}
FEATURES:

{{range .NotesByType.feature -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- if index .NotesByType "breaking-change" -}}
BREAKING CHANGES:

{{range index .NotesByType "breaking-change" -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- if .NotesByType.security }}
SECURITY:

{{range .NotesByType.security -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- if .NotesByType.improvement }}
IMPROVEMENTS:

{{range .NotesByType.improvement -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- if .NotesByType.deprecation }}
DEPRECATIONS:

{{range .NotesByType.deprecation -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- if .NotesByType.bug }}
BUG FIXES:

{{range .NotesByType.bug -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

{{- if .NotesByType.note }}
NOTES:

{{range .NotesByType.note -}}
* {{ template "note" . }}
{{ end -}}
{{- end -}}

3 changes: 3 additions & 0 deletions .changelog/note.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- define "note" -}}
{{.Body}}{{if not (stringHasPrefix .Issue "_")}} [[GH-{{- .Issue -}}](https://github.com/hashicorp/nomad/issues/{{- .Issue -}})]{{end}}
{{- end -}}
15 changes: 10 additions & 5 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ endif
# tag corresponding to latest release we maintain backward compatibility with
PROTO_COMPARE_TAG ?= v1.0.3$(if $(findstring ent,$(GO_TAGS)),+ent,)

# LAST_RELEASE is the git sha of the latest release corresponding to this branch. main should have the latest
# published release, but backport branches should point to the parent tag (e.g. 1.0.8 in release-1.0.9 after 1.1.0 is cut).
LAST_RELEASE ?= v1.0.10

default: help

ifeq ($(CI),true)
Expand Down Expand Up @@ -97,6 +101,7 @@ deps: ## Install build and development dependencies
GO111MODULE=on cd tools && go get github.com/hashicorp/hcl/v2/cmd/hclfmt@v2.5.1
GO111MODULE=on cd tools && go get github.com/golang/protobuf/protoc-gen-go@v1.3.4
GO111MODULE=on cd tools && go get github.com/hashicorp/go-msgpack/codec/codecgen@v1.1.5
GO111MODULE=on cd tools && go get github.com/hashicorp/go-changelog/cmd/changelog-build@latest

.PHONY: lint-deps
lint-deps: ## Install linter dependencies
Expand Down Expand Up @@ -187,10 +192,10 @@ generate-examples: command/job_init.bindata_assetfs.go
command/job_init.bindata_assetfs.go: command/assets/*
go-bindata-assetfs -pkg command -o command/job_init.bindata_assetfs.go ./command/assets/...

.PHONY: changelogfmt
changelogfmt:
@echo "--> Making [GH-xxxx] references clickable..."
@sed -E 's|([^\[])\[GH-([0-9]+)\]|\1[[GH-\2](https://github.com/hashicorp/nomad/issues/\2)]|g' CHANGELOG.md > changelog.tmp && mv changelog.tmp CHANGELOG.md
.PHONY: changelog
changelog:
@changelog-build -last-release $(LAST_RELEASE) -this-release HEAD \
-entries-dir .changelog/ -changelog-template ./.changelog/changelog.tmpl -note-template ./.changelog/note.tmpl

## We skip the terraform directory as there are templated hcl configurations
## that do not successfully compile without rendering
Expand Down Expand Up @@ -218,7 +223,7 @@ dev: GOOS=$(shell go env GOOS)
dev: GOARCH=$(shell go env GOARCH)
dev: GOPATH=$(shell go env GOPATH)
dev: DEV_TARGET=pkg/$(GOOS)_$(GOARCH)/nomad
dev: changelogfmt hclfmt ## Build for the current development platform
dev: hclfmt ## Build for the current development platform
@echo "==> Removing old development build..."
@rm -f $(PROJECT_ROOT)/$(DEV_TARGET)
@rm -f $(PROJECT_ROOT)/bin/nomad
Expand Down

0 comments on commit e8d0cd6

Please sign in to comment.