Skip to content

Commit 1981f2a

Browse files
chore: Enable CHANGELOG.md generation(#37)
1 parent 67d5281 commit 1981f2a

File tree

4 files changed

+154
-0
lines changed

4 files changed

+154
-0
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{ if .Versions -}}
2+
<a name="unreleased"></a>
3+
## [Unreleased]
4+
5+
{{ if .Unreleased.CommitGroups -}}
6+
{{ range .Unreleased.CommitGroups -}}
7+
### {{ .Title }}
8+
9+
{{ range .Commits -}}
10+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
11+
{{ end }}
12+
{{ end -}}
13+
{{ end -}}
14+
{{ end -}}
15+
16+
{{ range .Versions }}
17+
<a name="{{ .Tag.Name }}"></a>
18+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
19+
{{ range .CommitGroups -}}
20+
### {{ .Title }}
21+
22+
{{ range .Commits -}}
23+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
24+
{{ end }}
25+
{{ end -}}
26+
27+
{{- if .RevertCommits -}}
28+
### Reverts
29+
30+
{{ range .RevertCommits -}}
31+
- {{ .Revert.Header }}
32+
{{ end }}
33+
{{ end -}}
34+
35+
{{- if .MergeCommits -}}
36+
### Pull Requests
37+
{{ range .MergeCommits -}}
38+
- {{ .Header }}
39+
{{ end }}
40+
{{ end -}}
41+
42+
{{- if .NoteGroups -}}
43+
{{ range .NoteGroups -}}
44+
### {{ .Title }}
45+
46+
{{ range .Notes }}
47+
{{ .Body }}
48+
{{ end }}
49+
{{ end -}}
50+
{{ end -}}
51+
{{ end -}}
52+
53+
{{- if .Versions }}
54+
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
55+
{{ range .Versions -}}
56+
{{ if .Tag.Previous -}}
57+
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
58+
{{ end -}}
59+
{{ end -}}
60+
{{ end -}}

.chglog/config.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
style: none
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/KubeRocketCI/gitfusion
6+
7+
options:
8+
tag_filter_pattern: '^v'
9+
sort: "semVer"
10+
11+
commits:
12+
filters:
13+
Type:
14+
- chore
15+
- docs
16+
- feat
17+
- fix
18+
- refactor
19+
- style
20+
- test
21+
22+
commit_groups:
23+
group_by: Type
24+
sort_by: Custom
25+
title_order:
26+
- feat
27+
- fix
28+
- refactor
29+
- style
30+
- test
31+
- chore
32+
- docs
33+
title_maps:
34+
chore: Routine
35+
docs: Documentation
36+
feat: Features
37+
fix: Bug Fixes
38+
refactor: Code Refactoring
39+
style: Formatting
40+
test: Testing
41+
42+
header:
43+
pattern: "^(feat|fix|docs|style|refactor|test|chore)+!?:\\s(.*)$"
44+
pattern_maps:
45+
- Type
46+
- Subject
47+
48+
notes:
49+
keywords:
50+
- "BREAKING CHANGE:"

.chglog/release.tpl.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{ range .Versions }}
2+
<a name="{{ .Tag.Name }}"></a>
3+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
4+
{{ range .CommitGroups -}}
5+
### {{ .Title }}
6+
7+
{{ range .Commits -}}
8+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
9+
{{ end }}
10+
{{ end -}}
11+
12+
{{- if .NoteGroups -}}
13+
{{ range .NoteGroups -}}
14+
### {{ .Title }}
15+
16+
{{ range .Notes }}
17+
{{ .Body }}
18+
{{ end }}
19+
{{ end -}}
20+
{{ end -}}
21+
{{ end -}}
22+
23+
{{- if .Versions }}
24+
{{ range .Versions -}}
25+
{{ if .Tag.Previous -}}
26+
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
27+
{{ end -}}
28+
{{ end -}}
29+
{{ end -}}

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
OAPICODEGEN_VERSION ?= v2.4.1
22
GOLANGCI_LINT_VERSION ?= v2.1.6
33
HELMDOCS_VERSION ?= v1.14.2
4+
GITCHGLOG_VERSION ?= v0.15.4
45

56
CURRENT_DIR=$(shell pwd)
67
HOST_OS?=$(shell go env GOOS)
@@ -41,6 +42,15 @@ lint: golangci-lint ## Run go lint
4142
lint-fix: golangci-lint ## Run go lint fix
4243
${GOLANGCI_LINT} run -v -c .golangci.yaml ./... --fix
4344

45+
# use https://github.com/git-chglog/git-chglog/
46+
.PHONY: changelog
47+
changelog: git-chglog ## generate changelog
48+
ifneq (${NEXT_RELEASE_TAG},)
49+
$(GITCHGLOG) --next-tag v${NEXT_RELEASE_TAG} -o CHANGELOG.md
50+
else
51+
$(GITCHGLOG) -o CHANGELOG.md
52+
endif
53+
4454
# Run tests
4555
test:
4656
go test ./... -coverprofile=coverage.out
@@ -65,6 +75,11 @@ HELMDOCS = $(LOCALBIN)/helm-docs
6575
helmdocs: ## Download helm-docs locally if necessary.
6676
$(call go-install-tool,$(HELMDOCS),github.com/norwoodj/helm-docs/cmd/helm-docs,$(HELMDOCS_VERSION))
6777

78+
GITCHGLOG = $(LOCALBIN)/git-chglog
79+
.PHONY: git-chglog
80+
git-chglog: ## Download git-chglog locally if necessary.
81+
$(call go-install-tool,$(GITCHGLOG),github.com/git-chglog/git-chglog/cmd/git-chglog,$(GITCHGLOG_VERSION))
82+
6883
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
6984
# $1 - target path with name of binary
7085
# $2 - package url which can be installed

0 commit comments

Comments
 (0)