-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts and templates for changelog generation
Signed-off-by: Nikolai Mishin <[email protected]>
- Loading branch information
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{- if index .NotesByType "upgrade-guide" }} | ||
{{range index .NotesByType "upgrade-guide" -}} | ||
{{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if index .NotesByType "breaking-change" }} | ||
BREAKING CHANGES: | ||
|
||
{{range index .NotesByType "breaking-change" -}} | ||
{{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.note }} | ||
NOTES: | ||
|
||
{{range .NotesByType.note -}} | ||
{{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- $features := combineTypes .NotesByType.feature (index .NotesByType "new-resource" ) (index .NotesByType "new-data-source") (index .NotesByType "new-guide") }} | ||
{{- if $features }} | ||
FEATURES: | ||
|
||
{{range $features | sort -}} | ||
{{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.enhancement }} | ||
ENHANCEMENTS: | ||
|
||
{{range .NotesByType.enhancement | sort -}} | ||
{{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.bug }} | ||
BUG FIXES: | ||
|
||
{{range .NotesByType.bug | sort -}} | ||
{{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.internal }} | ||
INTERNAL: | ||
|
||
{{range .NotesByType.internal | sort -}} | ||
{{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.dependency }} | ||
DEPENDENCIES: | ||
|
||
{{range .NotesByType.dependency | sort -}} | ||
{{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
__parent="$(dirname "$__dir")" | ||
|
||
CHANGELOG_FILE_NAME="CHANGELOG.md" | ||
CHANGELOG_TMP_FILE_NAME="CHANGELOG.tmp" | ||
TARGET_SHA=$(git rev-parse HEAD) | ||
PREVIOUS_RELEASE_SHA=$(git rev-list -n 1 $(git describe --abbrev=0 --match='v*.*.*' --tags)) | ||
|
||
if [ $TARGET_SHA == $PREVIOUS_RELEASE_SHA ]; then | ||
echo "Nothing to do" | ||
exit 0 | ||
fi | ||
|
||
PREVIOUS_CHANGELOG=$(sed -n -e "/## $(git describe --abbrev=0 --match='v*.*.*' --tags | tr -d v)/,\$p" $__parent/$CHANGELOG_FILE_NAME) | ||
|
||
if [ -z "$PREVIOUS_CHANGELOG" ] | ||
then | ||
echo "Unable to locate previous changelog contents." | ||
exit 1 | ||
fi | ||
|
||
CHANGELOG=$($(go env GOPATH)/bin/changelog-build -this-release $TARGET_SHA \ | ||
-last-release $PREVIOUS_RELEASE_SHA \ | ||
-git-dir $__parent \ | ||
-entries-dir .changelog \ | ||
-changelog-template $__dir/changelog.tmpl \ | ||
-note-template $__dir/release-note.tmpl) | ||
|
||
if [ -z "$CHANGELOG" ] | ||
then | ||
echo "No changelog generated." | ||
exit 0 | ||
fi | ||
|
||
rm -f $CHANGELOG_TMP_FILE_NAME | ||
|
||
sed -n -e "1{/## /p;}" $__parent/$CHANGELOG_FILE_NAME > $CHANGELOG_TMP_FILE_NAME | ||
echo "$CHANGELOG" >> $CHANGELOG_TMP_FILE_NAME | ||
echo >> $CHANGELOG_TMP_FILE_NAME | ||
echo "$PREVIOUS_CHANGELOG" >> $CHANGELOG_TMP_FILE_NAME | ||
|
||
cp $CHANGELOG_TMP_FILE_NAME $CHANGELOG_FILE_NAME | ||
|
||
rm $CHANGELOG_TMP_FILE_NAME | ||
|
||
echo "Successfully generated changelog." | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{- define "note" -}} | ||
{{- if eq "new-guide" .Type -}} | ||
* **New Guide:** `{{.Body}}` ([#{{- .Issue -}}](https://github.com/tofuutils/tenv/issues/{{- .Issue -}})) | ||
{{- else if eq "upgrade-guide" .Type -}} | ||
{{.Body}} | ||
{{- else -}} | ||
* {{.Body}} ([#{{- .Issue -}}](https://github.com/tofuutils/tenv/issues/{{- .Issue -}})) | ||
{{- end -}} | ||
{{- end -}} |