Skip to content

Commit

Permalink
feat(cli): add Golang based changelog generator (#1)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Datong Sun <[email protected]>
  • Loading branch information
vm-001 and dndx authored Sep 27, 2023
1 parent b49d325 commit b525126
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
32 changes: 32 additions & 0 deletions changelog-markdown.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- /* ===== entry template ==== */ -}}
{{ define "entry" }}
- {{ trim $.Message }}
{{ range $i, $github := $.ParsedGithubs }} [{{ $github.Name }}]({{ $github.Link }}) {{- end }}
{{ range $i, $jira := $.ParsedJiras }} [{{ $jira.ID }}]({{ $jira.Link }}) {{- end }}
{{- end }}
{{- /* ===== entry template ==== */ -}}
{{- /* ==== section template ==== */ -}}
{{- define "section" }}
{{- if .scopes }}
{{- $length := len .scopes }}
{{- if gt $length 0 }}
### {{ .sectionName }}
{{- range $i, $scope := .scopes }}
#### {{ $scope.ScopeName }}
{{- range $j, $entry := $scope.Entries }}
{{ template "entry" $entry }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- /* ==== section template ==== */ -}}

## {{ .System }}

{{ template "section" (dict "sectionName" "Performance" "scopes" .Type.performance) }}
{{ template "section" (dict "sectionName" "Breaking Changes" "scopes" .Type.breaking_change ) }}
{{ template "section" (dict "sectionName" "Deprecations" "scopes" .Type.deprecation ) }}
{{ template "section" (dict "sectionName" "Dependencies" "scopes" .Type.dependency ) }}
{{ template "section" (dict "sectionName" "Features" "scopes" .Type.feature ) }}
{{ template "section" (dict "sectionName" "Fixes" "scopes" .Type.bugfix ) }}
14 changes: 14 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module konghq.com/changelog

go 1.20

require (
github.com/urfave/cli/v2 v2.25.7
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
)
Loading

0 comments on commit b525126

Please sign in to comment.