110 lines
2.9 KiB
Makefile
110 lines
2.9 KiB
Makefile
MKT_GIT_CHGLOG_VERSION ?= 0.15.4
|
|
MKT_GIT_CHGLOG_DOWNLOAD_URL ?= https://github.com/git-chglog/git-chglog/releases/download/v$(MKT_GIT_CHGLOG_VERSION)/git-chglog_$(MKT_GIT_CHGLOG_VERSION)_linux_amd64.tar.gz
|
|
MKT_GIT_CHGLOG_ARGS ?=
|
|
MKT_GIT_CHGLOG_PROJECT_ORG ?=
|
|
export MKT_GIT_CHGLOG_PROJECT_ORG
|
|
MKT_GIT_CHGLOG_PROJECT_NAME ?=
|
|
export MKT_GIT_CHGLOG_PROJECT_NAME
|
|
|
|
define _MKT_GIT_CHGLOG_CONFIG_SCRIPT =
|
|
mkdir -p .chglog
|
|
cat > .chglog/config.yml << EOF
|
|
style: github
|
|
template: CHANGELOG.tpl.md
|
|
info:
|
|
title: CHANGELOG
|
|
repository_url: https://forge.cadoles.com/${MKT_GIT_CHGLOG_PROJECT_ORG}/${MKT_GIT_CHGLOG_PROJECT_NAME}
|
|
options:
|
|
commits:
|
|
filters:
|
|
Type:
|
|
- feat
|
|
- fix
|
|
- perf
|
|
- refactor
|
|
- docs
|
|
commit_groups:
|
|
title_maps:
|
|
feat: Features
|
|
fix: Bug Fixes
|
|
perf: Performance Improvements
|
|
refactor: Code Refactoring
|
|
docs: Documentation
|
|
header:
|
|
pattern: "^(\\\\w*)(?:\\\\(([\\\\w\\\\$\\\\.\\\\-\\\\*\\\\s]*)\\\\))?\\\\:\\\\s(.*)$"
|
|
pattern_maps:
|
|
- Type
|
|
- Scope
|
|
- Subject
|
|
notes:
|
|
keywords:
|
|
- BREAKING CHANGE
|
|
issues:
|
|
prefix:
|
|
- '#'
|
|
EOF
|
|
endef
|
|
export MKT_GIT_CHGLOG_CONFIG_SCRIPT = $(value _MKT_GIT_CHGLOG_CONFIG_SCRIPT)
|
|
|
|
define _MKT_GIT_CHGLOG_TEMPLATE_SCRIPT =
|
|
mkdir -p .chglog
|
|
cat > .chglog/CHANGELOG.tpl.md << EOF
|
|
{{ if .Versions -}}
|
|
{{ if .Unreleased.CommitGroups -}}
|
|
<a name="unreleased"></a>
|
|
## [Unreleased]
|
|
|
|
{{ range .Unreleased.CommitGroups -}}
|
|
### {{ .Title }}
|
|
{{ range .Commits -}}
|
|
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
|
|
{{ end }}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
|
|
{{ range .Versions }}
|
|
<a name="{{ .Tag.Name }}"></a>
|
|
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
|
|
{{ range .CommitGroups -}}
|
|
### {{ .Title }}
|
|
{{ range .Commits -}}
|
|
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
|
|
{{ end }}
|
|
{{ end -}}
|
|
|
|
{{- if .NoteGroups -}}
|
|
{{ range .NoteGroups -}}
|
|
### {{ .Title }}
|
|
{{ range .Notes }}
|
|
{{ .Body }}
|
|
{{ end }}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
|
|
{{- if .Versions }}
|
|
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ \$latest := index .Versions 0 }}{{ \$latest.Tag.Name }}...HEAD
|
|
{{ range .Versions -}}
|
|
{{ if .Tag.Previous -}}
|
|
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
{{ end -}}
|
|
EOF
|
|
endef
|
|
export MKT_GIT_CHGLOG_TEMPLATE_SCRIPT = $(value _MKT_GIT_CHGLOG_TEMPLATE_SCRIPT)
|
|
|
|
mkt-changelog: tools/git-chglog/bin/git-chglog .chglog/config.yml .chglog/CHANGELOG.tpl.md
|
|
tools/git-chglog/bin/git-chglog --output CHANGELOG.md $(MKT_GIT_CHGLOG_ARGS)
|
|
|
|
.chglog/config.yml:
|
|
@eval "$$MKT_GIT_CHGLOG_CONFIG_SCRIPT"
|
|
|
|
.chglog/CHANGELOG.tpl.md:
|
|
@eval "$$MKT_GIT_CHGLOG_TEMPLATE_SCRIPT"
|
|
|
|
tools/git-chglog/bin/git-chglog:
|
|
mkdir -p tools/git-chglog/bin
|
|
grep -qF -- "tools/" ".gitignore" 2>/dev/null || echo "tools/" >> ".gitignore"
|
|
( cd tools/git-chglog/bin && curl -sL "$(MKT_GIT_CHGLOG_DOWNLOAD_URL)" | tar -xz git-chglog )
|