build: add `git-chglog`
authorJulien Moutinho <julm+symantic-parser@sourcephile.fr>
Thu, 7 Oct 2021 23:08:54 +0000 (01:08 +0200)
committerJulien Moutinho <julm+symantic-parser@sourcephile.fr>
Fri, 8 Oct 2021 00:07:07 +0000 (02:07 +0200)
.chglog/CHANGELOG.tpl.md [new file with mode: 0755]
.chglog/config.yml [new file with mode: 0755]
.reuse/dep5
Makefile

diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md
new file mode 100755 (executable)
index 0000000..07711aa
--- /dev/null
@@ -0,0 +1,37 @@
+{{ range .Versions }}
+## {{ .Tag.Name }} ({{ datetime "2006-01-02" .Tag.Date }})
+
+{{ range .CommitGroups -}}
+### {{ .Title }}
+
+{{ range .Commits -}}
+* {{ upperFirst .Type }}{{ if .Subject }} {{ .Subject }}{{ end }}.
+{{ end }}
+{{ end -}}
+
+{{- if .RevertCommits -}}
+### Reverts
+
+{{ range .RevertCommits -}}
+* {{ .Revert.Header }}
+{{ end }}
+{{ end -}}
+
+{{- if .MergeCommits -}}
+### Merges
+
+{{ range .MergeCommits -}}
+* {{ .Header }}
+{{ end }}
+{{ end -}}
+
+{{- if .NoteGroups -}}
+{{ range .NoteGroups -}}
+### {{ .Title }}
+
+{{ range .Notes }}
+{{ .Body }}
+{{ end }}
+{{ end -}}
+{{ end -}}
+{{ end -}}
diff --git a/.chglog/config.yml b/.chglog/config.yml
new file mode 100755 (executable)
index 0000000..6ff0ecc
--- /dev/null
@@ -0,0 +1,35 @@
+style: none
+template: CHANGELOG.tpl.md
+info:
+  title: ChangeLog
+  repository_url: "https://git.hut.sourcephile.fr/~julm/symantic-parser"
+options:
+  sort: "date"
+
+  commits:
+    sort_by: Type
+
+  commit_groups:
+    group_by: Scope
+    sort_by: Custom
+    title_order:
+      - iface
+      - doc
+      - impl
+      - build
+    title_maps:
+      build: Build
+      doc: Documentation
+      iface: Interface
+      impl: Implementation
+
+  header:
+    pattern: "^([\\w\\$\\.\\-\\*\\s]*)\\:\\s(\\w*)\\s*(.*)$"
+    pattern_maps:
+      - Scope
+      - Type
+      - Subject
+
+  notes:
+    keywords:
+      - BREAKING CHANGE
index 9bc5b81c9536c46ec966bdea0408ba24ce996209..16d0aa89204804b09b9e2f67977f75f04e229932 100644 (file)
@@ -3,7 +3,7 @@ Upstream-Name: symantic-parser
 Upstream-Contact: Julien Moutinho <julm+symantic-parser@sourcephile.fr>
 Source: https://git.code.sourcephile.fr/~julm/symantic-parser
 
-Files: *.nix *.lock cabal.project *.cabal *.md .envrc .gitignore .hlint.yaml Makefile
+Files: *.nix *.lock cabal.project *.cabal *.md .chglog/* .envrc .gitignore .hlint.yaml Makefile
 Copyright: Julien Moutinho <julm+symantic-parser@sourcephile.fr>
 License: CC0-1.0
 
index 7642fc96b6121de77d3977647bd9510889fc15bf..d936a2b2b112b002eb0d74b88b2912f6fd7a7157 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -95,9 +95,20 @@ $(project)-benchmark.prof2:
 doc:
        cabal haddock --haddock-css ocean --haddock-hyperlink-source
 
-tag:
-       git tag --merged | grep -Fqx "$(package)-$(version)" || \
-       git tag -f -s -m "$(package) v$(version)" $(package)-$(version)
+.PHONY: ChangeLog.md
+ChangeLog.md:
+       ! git tag --merged | grep -Fqx $(package)-$(version)
+       git diff --exit-code
+       git tag -f $(package)-$(version)
+       git-chglog --output $@.new $(package)-$(version)
+       touch $@
+       cat $@ >>$@.new
+       mv -f $@.new $@
+       git tag -d $(package)-$(version)
+       git add '$@'
+       git commit -m 'doc: update `$@`'
+tag: ChangeLog.md
+       git tag -s -m $(package)-$(version) $(package)-$(version)
 
 tar:
        git diff --exit-code
@@ -128,7 +139,6 @@ nix-shell:
        echo >>$@ '# BEGIN: generated hints'
        hlint --find . | grep -- '- fixity:' | sort -u >>$@
        echo >>$@ '# END: generated hints'
-
 lint: .hlint.yaml
        if hlint --quiet --report=hlint.html -XNoCPP $(HLINT_FLAGS) .; \
        then rm -f hlint.html; \