Skip to content

Commit 9e9297b

Browse files
committed
feat(dev-tool): add changie and custom generate config
1 parent 5d8ecb3 commit 9e9297b

File tree

6 files changed

+86
-17
lines changed

6 files changed

+86
-17
lines changed

.changes/unreleased/.gitkeep

Whitespace-only changes.

.changie.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
changesDir: .changes
2+
unreleasedDir: unreleased
3+
headerPath: ../.chglog/CHANGELOG_HEADER.tpl.md
4+
changelogPath: CHANGELOG.md
5+
versionExt: md
6+
newlines:
7+
afterChangelogHeader: 0
8+
beforeChangelogVersion: 1
9+
endOfVersion: 1
10+
replacements:
11+
- path: "VERSION"
12+
find: ".*"
13+
replace: "{{.VersionNoPrefix}}"

.chglog/CHANGELOG.tpl.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
# Changelog
2-
3-
All notable changes to this project will be documented in this file.
4-
5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
6-
7-
{{ range .Versions }}
8-
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
1+
{{ range .Versions -}}
2+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
93
{{ range .CommitGroups }}
104
### {{ .Title }}
115
{{ range .Commits }}
@@ -22,12 +16,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
2216
{{ end -}}
2317
{{ end }}
2418
Full Changelog: {{ if .Tag.Previous }}[{{ .Tag.Previous.Name }}...{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/commits/{{ .Tag.Name }}){{ end }}
25-
{{ end }}
26-
27-
{{- if .Versions }}
28-
{{ range .Versions -}}
29-
{{ if .Tag.Previous -}}
30-
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
31-
{{ end -}}
3219
{{ end -}}
33-
{{ end -}}

.chglog/CHANGELOG_HEADER.tpl.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Taskfile.yaml

Taskfile.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# https://taskfile.dev
2+
3+
version: "3"
4+
5+
env:
6+
TAG_PREFIX: v
7+
CHANGES_DIR: .changes
8+
9+
tasks:
10+
prepare:
11+
desc: Install tools
12+
cmds:
13+
- go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest
14+
- go install github.com/miniscruff/changie@latest
15+
16+
batch-changelog:
17+
desc: Generate changelog for existing git tags
18+
cmds:
19+
- rm ${CHANGES_DIR}/${TAG_PREFIX}*.md || true
20+
- for VERSION_TAG in $(git -c 'versionsort.suffix=-' tag --list --sort=v:refname); do git-chglog --output ${CHANGES_DIR}/${VERSION_TAG}.md ${VERSION_TAG} ; done
21+
silent: true
22+
23+
changelog:
24+
desc: Generate changelog for an existing version
25+
vars:
26+
VERSION_TAG: ${TAG_PREFIX}{{.CLI_ARGS}}
27+
cmds:
28+
- git-chglog --output ${CHANGES_DIR}/{{.VERSION_TAG}}.md {{.VERSION_TAG}}
29+
silent: true
30+
31+
changelog-next:
32+
desc: Generate changelog for a new version
33+
vars:
34+
VERSION_TAG: ${TAG_PREFIX}{{.CLI_ARGS}}
35+
cmds:
36+
- git-chglog --output ${CHANGES_DIR}/{{.VERSION_TAG}}.md --next-tag {{.VERSION_TAG}}
37+
silent: true
38+
39+
bump-version:
40+
desc: Bump version
41+
cmds:
42+
- echo {{.CLI_ARGS}} > VERSION
43+
silent: true
44+
45+
commit-release:
46+
desc: Create release commit
47+
vars:
48+
VERSION_TAG: ${TAG_PREFIX}{{.CLI_ARGS}}
49+
cmds:
50+
- git add ${CHANGES_DIR}
51+
- git add CHANGELOG.md
52+
- git add VERSION
53+
- |
54+
git commit -m "chore(release): {{.VERSION_TAG}}"
55+
silent: true
56+
57+
release:
58+
desc: Generate release commit
59+
vars:
60+
VERSION_TAG: ${TAG_PREFIX}{{.CLI_ARGS}}
61+
cmds:
62+
- echo "Releasing version {{.VERSION_TAG}}"
63+
- task changelog-next -- {{.CLI_ARGS}}
64+
- task bump-version -- {{.CLI_ARGS}}
65+
- task commit-release -- {{.CLI_ARGS}}
66+
silent: true

0 commit comments

Comments
 (0)