diff --git a/.codegen.json b/.codegen.json index 25c666260..a1886bd80 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1,5 +1,6 @@ { "formatter": "yapf -pri $FILENAMES && autoflake -i $FILENAMES && isort $FILENAMES", + "changelog_config": ".codegen/changelog_config.yml", "template_libraries": [ ".codegen/lib.tmpl" ], diff --git a/.codegen/changelog.md.tmpl b/.codegen/changelog.md.tmpl index 37bf395a7..c9f2e87c4 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,35 @@ 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" -}} + `databricks.sdk.service.{{.Package.Name}}` + {{- else if eq .X "service" -}} + {{template "service" .Service}} + {{- else if eq .X "method" -}} + `{{.Method.SnakeName}}()` + {{- else if eq .X "entity" -}} + {{template "entity" .Entity}} + {{- else if eq .X "field" -}} + `{{.Field.SnakeName}}` + {{- end}} +{{- end -}} + +{{- define "suffix-what" -}} + {{if eq .Type "package" }} package{{if gt (len .Changes) 1}}s{{end}} + {{- else if eq .Type "method" }} method{{if gt (len .Changes) 1}}s{{end}} for {{template "service" .Parent.Service}} + {{- else if eq .Type "entity" }} dataclass{{if gt (len .Changes) 1}}es{{end}} + {{- else if eq .Type "field" }} field{{if gt (len .Changes) 1}}s{{end}} for {{template "entity" .Parent.Entity}} + {{- end}} +{{- end -}} + +{{- define "other-what" -}} {{if eq .X "package" -}} `databricks.sdk.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..a35312305 --- /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: "[Doc]" + - message: Internal Changes + tag: "[Internal]" + # Default for messages without a tag + - message: Other Changes \ No newline at end of file diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 2a2737f16..ff813bfa8 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -39,3 +39,22 @@ jobs: - name: Fail on differences run: git diff --exit-code + + commit-message: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'pull_request' }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Validate Tag + run: | + TAG=$(echo ${{ github.event.pull_request.title }} | sed -ne 's/\[\(.*\)\].*/\1/p') + if grep -q "tag: \"[$TAG]\"" .codegen/changelog_config.yml; then + echo "Invalid or missing tag in commit message: [$TAG]" + exit 1 + else + echo "Valid tag found: [$TAG]" + fi \ No newline at end of file