-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from hashicorp/f-changelog
Add go-changelog support
- Loading branch information
Showing
9 changed files
with
185 additions
and
4 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,55 @@ | ||
{{- if index .NotesByType "breaking-change" -}} | ||
BREAKING CHANGES: | ||
|
||
{{range index .NotesByType "breaking-change" -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.security }} | ||
SECURITY: | ||
|
||
{{range .NotesByType.security -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.deprecation -}} | ||
DEPRECATIONS: | ||
|
||
{{range .NotesByType.deprecation -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.feature }} | ||
FEATURES: | ||
|
||
{{range .NotesByType.feature -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.improvement }} | ||
IMPROVEMENTS: | ||
|
||
{{range .NotesByType.improvement -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.bug }} | ||
BUG FIXES: | ||
|
||
{{range .NotesByType.bug -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.note -}} | ||
NOTES: | ||
|
||
{{range .NotesByType.note -}} | ||
* {{ 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,3 @@ | ||
{{- define "note" -}} | ||
{{.Body}} [[GH-{{- .Issue -}}](https://github.com/hashicorp/hcp/issues/{{- .Issue -}})] | ||
{{- 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,7 @@ | ||
breaking-change | ||
security | ||
deprecation | ||
feature | ||
improvement | ||
bug | ||
note |
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,17 @@ | ||
### Changes proposed in this PR: | ||
|
||
### How I've tested this PR: | ||
|
||
### How I expect reviewers to test this PR: | ||
|
||
<!-- If you are adding a new command or editing an existing one, please provide | ||
an example of the command being invoked. | ||
### Output of affected commands: | ||
--> | ||
|
||
### Checklist: | ||
- [ ] Tests added | ||
- [ ] CHANGELOG entry added | ||
> Run `make changelog-entry` for guidance in authoring a changelog entry, and | ||
> commit the resulting file, which should have a name matching your PR number. | ||
> Entries should use imperative present tense (e.g. Add support for...) |
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,30 @@ | ||
set -euo pipefail | ||
|
||
# check if there is a diff in the .changelog directory | ||
# for PRs against the main branch, the changelog file name should match the PR number | ||
if [ "$GITHUB_BASE_REF" = "$GITHUB_DEFAULT_BRANCH" ]; then | ||
enforce_matching_pull_request_number="matching this PR number " | ||
changelog_file_path=".changelog/(_)?$PR_NUMBER.txt" | ||
else | ||
changelog_file_path=".changelog/[_0-9]*.txt" | ||
fi | ||
|
||
changelog_files=$(git --no-pager diff --name-only HEAD "$(git merge-base HEAD "origin/main")" | egrep "${changelog_file_path}") | ||
|
||
# If we do not find a file in .changelog/, we fail the check | ||
if [ -z "$changelog_files" ]; then | ||
# Fail status check when no .changelog entry was found on the PR | ||
echo "Did not find a .changelog entry ${enforce_matching_pull_request_number}and the 'pr/no-changelog' label was not applied." | ||
exit 1 | ||
fi | ||
|
||
# Validate format with make changelog-check, exit with error if any note has an | ||
# invalid format | ||
for file in $changelog_files; do | ||
if ! cat $file | make changelog/check; then | ||
echo "Found a changelog entry ${enforce_matching_pull_request_number}but the note format in ${file} was invalid." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Found valid changelog entry!" |
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,31 @@ | ||
# This workflow checks that there is either a 'pr/no-changelog' label applied to a PR | ||
# or there is a .changelog/<pr number>.txt file associated with a PR for a changelog entry | ||
|
||
name: Changelog Checker | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, labeled] | ||
# Runs on PRs to main and all release branches | ||
branches: | ||
- main | ||
- release/* | ||
|
||
jobs: | ||
# checks that a .changelog entry is present for a PR | ||
changelog-check: | ||
# If there a `pr/no-changelog` label we ignore this check. | ||
if: "! ( contains(github.event.pull_request.labels.*.name, 'pr/no-changelog')" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 # by default the checkout action doesn't checkout all branches | ||
- name: Check for changelog entry in diff | ||
run: ./.github/scripts/changelog_checker.sh | ||
env: | ||
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }} | ||
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} |
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
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
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