feat: add mkt-changelog task
This commit is contained in:
parent
cd2f1bad66
commit
e2f267757a
|
@ -36,4 +36,5 @@ Tâches [Make](https://fr.wikipedia.org/wiki/Make) génériques à utiliser de p
|
|||
|Tâches|Description|Documentation|
|
||||
|------|-----------|-------------|
|
||||
|`make mkt-webdav-upload`|Téléverser un fichier dans un répertoire WebDAV (Nextcloud)|[Voir ./doc/tasks/webdav.md](./doc/tasks/webdav.md)|
|
||||
|`make mkt-gitea-release`|Créer une release sur un projet Gitea et téléverser des fichiers attachés|[Voir ./doc/tasks/gitea.md](./doc/tasks/gitea.md)|
|
||||
|`make mkt-gitea-release`|Créer une release sur un projet Gitea et téléverser des fichiers attachés|[Voir ./doc/tasks/gitea.md](./doc/tasks/gitea.md)|
|
||||
|`make mkt-changelog`|Générer un fichier de `CHANGELOG.md` pour votre projet|[Voir ./doc/tasks/changelog.md](./doc/tasks/changelog.md)|
|
|
@ -0,0 +1,26 @@
|
|||
# Tâches Changelog
|
||||
|
||||
## `make mkt-changelog`
|
||||
|
||||
La tâche `mkt-changelog` permet de générer un fichier `CHANGELOG.md` avec l'outil [`git-chglog`](https://github.com/git-chglog/git-chglog) et de l'historique Git de votre projet.
|
||||
|
||||
L'usage de cette tâche a pour prérequis que vos messages de commit respectent la spécification ["Conventional Commit"](https://www.conventionalcommits.org/fr/v1.0.0/).
|
||||
|
||||
Par défaut voici [les types de commit](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#type) référencés par le fichier généré:
|
||||
|
||||
- `feat`
|
||||
- `fix`
|
||||
- `perf`
|
||||
- `refactor`
|
||||
- `docs`
|
||||
|
||||
### Usage
|
||||
|
||||
Exemple d'utilisation de la tâche pour la génération du changelog du projet `https://forge.cadoles.com/MyOrg/MyProject` sur la forge:
|
||||
|
||||
```makefile
|
||||
my-changelog:
|
||||
$(MAKE) MKT_GIT_CHGLOG_PROJECT_ORG=MyOrg MKT_GIT_CHGLOG_PROJECT_NAME=MyProject mkt-changelog
|
||||
```
|
||||
|
||||
> **Note** Assurez vous d'avoir créé un premier tag sur la branche en cours avant d'exécuter la tâche.
|
|
@ -0,0 +1,110 @@
|
|||
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 -}}
|
||||
<a name="unreleased"></a>
|
||||
## [Unreleased]
|
||||
|
||||
{{ if .Unreleased.CommitGroups -}}
|
||||
{{ 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: .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 )
|
Loading…
Reference in New Issue