diff --git a/.codegen.json b/.codegen.json index 35ce31537..daf9925ae 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1,5 +1,6 @@ { "formatter": "go fmt ./... && go run golang.org/x/tools/cmd/goimports@latest -w $FILENAMES", + "changelog_config": ".codegen/changelog_config.yml", "packages": { ".codegen/api.go.tmpl": "service/{{.Name}}/api.go", ".codegen/impl.go.tmpl": "service/{{.Name}}/impl.go", diff --git a/.codegen/changelog.md.tmpl b/.codegen/changelog.md.tmpl index 1c49e6869..748eabef6 100644 --- a/.codegen/changelog.md.tmpl +++ b/.codegen/changelog.md.tmpl @@ -1,13 +1,17 @@ # Version changelog ## {{.Version}} +{{- range .GroupChanges}} -{{range .Changes -}} +### {{.Type.Message}} +{{range .Changes}} * {{.}}. -{{end}}{{- if .ApiChanges}} -API Changes: -{{range .ApiChanges}} - * {{.Action}} {{template "what" .}}{{if .Extra}} {{.Extra}}{{with .Other}} {{template "what" .}}{{end}}{{end}}. +{{- end}} +{{end}} +{{if .ApiChanges}} +### API Changes: +{{range .ApiChanges.GroupDiff}} + * {{.Action}} {{template "group-what" .}}{{if .Extra}} {{.Extra}}{{with .Other}} {{template "other-what" .}}{{end}}{{end}}. {{- end}} OpenAPI SHA: {{.Sha}}, Date: {{.Changed}} @@ -20,7 +24,39 @@ Dependency updates: ## {{.PrevVersion}} -{{- define "what" -}} + +{{- define "group-what" -}} +{{if gt (len .Changes) 1 -}} {{template "single-what" .Changes.First}}{{end -}} +{{range .Changes.Middle -}}, {{template "single-what" .}}{{end -}} +{{if gt (len .Changes) 1}} and {{end}}{{template "single-what" .Changes.Last}}{{template "suffix-what" .}} +{{- end -}} + + +{{- define "single-what" -}} + {{if eq .X "package" -}} + [{{.Package.Name}}](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}) package + {{- else if eq .X "service" -}} + {{template "service" .Service}} + {{- else if eq .X "method" -}} + `{{.Method.PascalName}}` + {{- else if eq .X "entity" -}} + {{template "entity" .Entity}} + {{- else if eq .X "field" -}} + `{{.Field.PascalName}}` + {{- end}} +{{- end -}} + +{{- define "suffix-what" -}} + {{if eq .Type "method"}} method{{template "plural-suffix" .Changes}} for {{template "service" .Parent.Service}} + {{- else if eq .Type "field"}} field{{template "plural-suffix" .Changes}} for {{template "entity" .Parent.Entity}} + {{- end}} +{{- end -}} + +{{- define "plural-suffix" -}} +{{if gt (len .) 1}}s{{end}} +{{- end -}} + +{{- define "other-what" -}} {{if eq .X "package" -}} [{{.Package.Name}}](https://pkg.go.dev/github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}) package {{- else if eq .X "service" -}} diff --git a/.codegen/changelog_config.yml b/.codegen/changelog_config.yml new file mode 100644 index 000000000..f4ea73945 --- /dev/null +++ b/.codegen/changelog_config.yml @@ -0,0 +1,11 @@ +change_types: + - message: New Features and Improvements + tag: "[Feature]" + - message: Bug Fixes + tag: "[Fix]" + - message: Documentation + tag: "[Docs]" + - message: Internal Changes + tag: "[Internal]" + # Default for messages without a tag + - message: Other Changes \ No newline at end of file