-
Notifications
You must be signed in to change notification settings - Fork 30
ci: add chloggen and workflows for changelog generation #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9255eac
73f59ff
5e84dcb
2d78772
fbe9856
e9eca46
9a6b8ec
5f54e27
a0abc94
86758f5
1e0b043
74e30ad
e86cb3f
6b36720
6279c76
d1ad6be
b8dad2f
c9f41a4
62078fb
c357bac
9f2455f
d98aa8c
90577b3
fea2f7c
6a0bdd5
7973252
fd6757f
1a4c14d
93d9f05
7fc83a2
3e5787e
3307625
b202fcb
c4d34df
428a316
0931577
f3f1d12
5fc4534
f523b9b
a0c8d59
68f750a
6797a8f
6e69111
bcb8f69
4fb49ed
37d172b
a840cb0
8bb0997
3a6a268
224dcdb
90ca848
193e5d2
69fa422
833bda6
0656c6c
3d46f47
1d400de
153d8b5
f0396d6
c466abc
f710005
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ### Changelog folder | ||
|
|
||
| This repo uses `chloggen` to manage its changelog files. You can find the source code for the tool [here](https://github.com/open-telemetry/opentelemetry-go-build-tools/tree/main/chloggen). | ||
|
|
||
| Here is a quick explanation of the `config.yaml` file for chloggen: | ||
|
|
||
| ```yaml | ||
| # The directory that stores individual changelog entries. | ||
| # Each entry is stored in a dedicated yaml file. | ||
| # - 'chloggen new' will copy the 'template_yaml' to this directory as a new entry file. | ||
| # - 'chloggen validate' will validate that all entry files are valid. | ||
| # - 'chloggen update' will read and delete all entry files in this directory, and update 'changelog_md'. | ||
| # Specify as relative path from root of repo. | ||
| # (Optional) Default: .chloggen | ||
| entries_dir: .chloggen | ||
|
|
||
| # This file is used as the input for individual changelog entries. | ||
| # Specify as relative path from root of repo. | ||
| # (Optional) Default: .chloggen/TEMPLATE.yaml | ||
| template_yaml: .chloggen/TEMPLATE.yaml | ||
|
|
||
| summary_template: .chloggen/summary.tmpl | ||
|
|
||
| # The CHANGELOG file or files to which 'chloggen update' will write new entries | ||
| # (Optional) Default filename: CHANGELOG.md | ||
| change_logs: | ||
| user: CHANGELOG.md | ||
|
|
||
| # The default change_log or change_logs to which an entry should be added. | ||
| # If 'change_logs' is specified in this file, and no value is specified for 'default_change_logs', | ||
| # then 'change_logs' MUST be specified in every entry file. | ||
| default_change_logs: [user] | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Use this changelog template to create an entry for release notes. | ||
|
|
||
| # One of 'feature', 'bug_fix', 'docs'. Inferred from conventional commit tag if PR created before `make chlog-new`. | ||
| change_type: | ||
|
|
||
| # Mandatory. One of: distributions, distributions/nrdot-collector, distributions/nrdot-collector-experimental, examples | ||
| component: | ||
|
|
||
| # Mandatory. Put the PR number here. Inferred from PR number if PR created before `make chlog-new`. | ||
| issues: [] | ||
|
|
||
| # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
| note: | ||
|
|
||
| # (Optional) One or more lines of additional information to render under the primary note. | ||
| # These lines will be padded with 2 spaces and then inserted directly into the document. | ||
| # Use pipe (|) for multiline entries. | ||
| subtext: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| change_logs: | ||
| user: CHANGELOG.md | ||
| default_change_logs: | ||
| - user | ||
| entries_dir: .chloggen | ||
| template_yaml: .chloggen/TEMPLATE.yaml | ||
| summary_template: .chloggen/summary.tmpl | ||
| components: | ||
| - distributions | ||
| - distributions/nrdot-collector | ||
| - distributions/nrdot-collector-experimental | ||
| - examples | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| {{- define "entry" -}} | ||
| - `{{ .Component }}`: {{ .Note }} ( | ||
| {{- range $i, $issue := .Issues }} | ||
| {{- if $i }}, {{ end -}} | ||
| #{{ $issue }} | ||
| {{- end -}} | ||
| ) | ||
|
|
||
| {{- if .SubText }} | ||
| {{ .SubText | indent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| ## {{ .Version }} | ||
|
|
||
| {{- if .Enhancements }} | ||
|
|
||
| ### Features | ||
|
|
||
| {{- range $i, $change := .Enhancements }} | ||
| {{- if eq $i 0}} | ||
| {{end}} | ||
| {{ template "entry" $change }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- if .BugFixes }} | ||
|
|
||
| ### Bug Fixes | ||
|
|
||
| {{- range $i, $change := .BugFixes }} | ||
| {{- if eq $i 0}} | ||
| {{end}} | ||
| {{ template "entry" $change }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- if .NewComponents }} | ||
|
|
||
| ### Docs | ||
|
|
||
| {{- range $i, $change := .NewComponents }} | ||
| {{- if eq $i 0}} | ||
| {{end}} | ||
| {{ template "entry" $change }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| <!-- previous-version --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # This action requires that any PR targeting the main branch should add a | ||
| # yaml file to the ./.chloggen/ directory. If a CHANGELOG entry is not required, | ||
| # or if performing maintenance on the Changelog, add the "Skip Changelog" label, | ||
| # or prefix the pull request title with any of the following: "chore", | ||
| # "build", "ci", "refactor", "style", "test". | ||
|
|
||
| name: changelog | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, labeled, unlabeled, edited] | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| # Make sure to exit early if cache segment download times out after 2 minutes. | ||
| # We limit cache download as a whole to 5 minutes. | ||
| SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious what this is about? Is there some kind of link validation in chloggen?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a great question - I took most of this workflow from the components repo and missed this. I just did some research and found that it's an environment variable used to set cache download timeout in The default timeout is 10 minutes. I imagine this would be a lot more relevant for repos with bigger caches than releases (like our components repo or upstream contrib), but we're probably safe to remove this from here if need be. |
||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| changelog: | ||
| runs-on: ubuntu-24.04 | ||
| if: ${{ github.actor != 'dependabot[bot]' }} | ||
| env: | ||
| PR_HEAD: ${{ github.event.pull_request.head.sha }} | ||
|
|
||
| steps: | ||
| - name: Check if changelog exempt | ||
| id: check | ||
| env: | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }} | ||
| run: | | ||
| CHLOG_EXEMPT_PREFIXES=('chore' 'build' 'ci' 'refactor' 'style' 'test') | ||
| for prefix in "${CHLOG_EXEMPT_PREFIXES[@]}"; do | ||
| if [[ "$PR_TITLE" == "$prefix"* ]]; then | ||
| echo "Title has exempt prefix '$prefix'; changelog not required." | ||
| echo "exempt=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| done | ||
|
|
||
| CHLOG_EXEMPT_LABELS=('Skip Changelog' 'dependencies') | ||
| for label in "${CHLOG_EXEMPT_LABELS[@]}"; do | ||
| if echo "$PR_LABELS" | grep -qF "\"$label\""; then | ||
| echo "PR has exempt label '$label'; changelog not required." | ||
| echo "exempt=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| done | ||
|
|
||
| echo "No exempt prefix or label; changelog required." | ||
| echo "exempt=false" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| # Fetch complete history unless the PR is changelog-exempt. | ||
| fetch-depth: ${{ steps.check.outputs.exempt == 'true' && '1' || '0' }} | ||
| - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | ||
| with: | ||
| go-version: oldstable | ||
| cache-dependency-path: "**/*.sum" | ||
|
|
||
| - name: Ensure no changes to CHANGELOG.md | ||
| if: ${{ steps.check.outputs.exempt != 'true' }} | ||
| run: | | ||
| if [[ "$(git diff --name-only "$(git merge-base origin/main "$PR_HEAD")" "$PR_HEAD" ./CHANGELOG*.md)" ]] | ||
| then | ||
| echo "CHANGELOG.md should not be directly modified." | ||
| echo "Please add a .yaml file to the ./.chloggen/ directory." | ||
| echo "Alternately, add the \"Skip Changelog\" label or prefix the pull request title with any of the following: \"chore\", \"build\", \"ci\", \"refactor\", \"style\", or \"test\"." | ||
| false | ||
| else | ||
| echo "CHANGELOG.md was not modified." | ||
| fi | ||
|
|
||
| - name: Ensure ./.chloggen/*.yaml addition(s) | ||
| if: ${{ steps.check.outputs.exempt != 'true' }} | ||
| run: | | ||
| excluded_yamls=(config.yaml TEMPLATE.yaml) | ||
| chloggen_yamls="$(git diff --diff-filter=AM --name-only "$(git merge-base origin/main "$PR_HEAD")" "$PR_HEAD" ./.chloggen)" | ||
| if [[ 1 -gt "$(echo "$chloggen_yamls" | grep \\.yaml | grep -vc -f <(printf '/%s$\n' "${excluded_yamls[@]}"))" ]] | ||
| then | ||
| echo "No changelog entry was added or changed in the ./.chloggen/ directory." | ||
| echo "Please add or edit an existing .yaml file in the ./.chloggen/ directory." | ||
| echo "See CONTRIBUTING.md for more details." | ||
| echo "Alternately, add \"chore:\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped." | ||
| false | ||
| else | ||
| echo "A changelog entry was added to the ./.chloggen/ directory." | ||
| fi | ||
|
|
||
| - name: Validate ./.chloggen/*.yaml changes | ||
| run: | | ||
| make chlog-validate \ | ||
| || { echo "New ./.chloggen/*.yaml file failed validation."; exit 1; } | ||
|
|
||
| # In order to validate any links in the yaml file, render the config to markdown | ||
| - name: Render .chloggen changelog entries | ||
| if: ${{ steps.check.outputs.exempt != 'true' }} | ||
| run: make chlog-preview > changelog_preview.md | ||
| - name: Link Checker | ||
| if: ${{ steps.check.outputs.exempt != 'true' }} | ||
| id: lychee | ||
| uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0 | ||
| with: | ||
| args: "--verbose --no-progress ./changelog_preview.md --config .github/lychee.toml" | ||
| failIfEmpty: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ jobs: | |
| token: ${{ secrets.RELEASE_TOKEN }} | ||
|
|
||
| - name: Import GPG key | ||
| if: ${{ !env.ACT }} | ||
| uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7 | ||
| with: | ||
| gpg_private_key: ${{ secrets.OTELCOMM_BOT_GPG_PRIVATE_KEY_BASE64 }} | ||
|
|
@@ -71,7 +72,7 @@ jobs: | |
| fi | ||
|
|
||
| - name: Commit Component Version Bump | ||
| if: steps.bump_component_versions.outputs.has_changes == 'true' | ||
| if: ${{ !env.ACT && steps.bump_component_versions.outputs.has_changes == 'true' }} | ||
| run: | | ||
| # Check if branch exists remotely | ||
| if git ls-remote --heads origin ${{ env.branch }} | grep -q ${{ env.branch }}; then | ||
|
|
@@ -134,11 +135,31 @@ jobs: | |
|
|
||
| echo "Updated PR #$pr_number" | ||
| else | ||
| echo "Creating new PR..." | ||
| echo "Creating new draft PR..." | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For our auto-generated PRs, we cannot generate a passing changelog before we have a PR number, which means we must create a PR beforehand. This leads to the following issue:
The CI run in step 2 will always fail, either because of the lack of changelog, or because it was cancelled by the CI run at 4. I don't think this would affect the release process, but my idea here was to mark it as a draft PR here, then mark it as 'ready' after the changelog is added so we don't get emailed until it's ready. |
||
| gh pr create \ | ||
| --draft \ | ||
| --title "$pr_title" \ | ||
| --body "$pr_body" \ | ||
| --repo "${{ github.repository }}" \ | ||
| --base main \ | ||
| --head "${{ env.branch }}" | ||
| fi | ||
|
|
||
| # Changelog entry must be added after PR is created, so that its PR number may be added | ||
| - name: Add changelog entry | ||
| id: add_changelog_entry | ||
| if: ${{ steps.bump_component_versions.outputs.has_changes == 'true' }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
| run: | | ||
| ./scripts/generate-version-bump-chlog.sh -c "${{ env.current_beta_core }}" -n "${{ env.next_beta_core }}" | ||
|
|
||
| - name: Commit changelog entry | ||
| if: ${{ !env.ACT && steps.bump_component_versions.outputs.has_changes == 'true' }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
| run: | | ||
| git add .chloggen/ | ||
| git commit -S -m "chore: add changelog entry for otel component version bump" | ||
| git push origin ${{ env.branch }} | ||
| gh pr ready "${{ env.branch }}" --repo "${{ github.repository }}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <!-- This file is autogenerated. See CONTRIBUTING.md for instructions to add an entry. --> | ||
|
|
||
| <!-- next version --> |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this list to the config enforces that only these components may be added to each entry. If this is too restrictive, we could instead omit this section entirely (then users would still be mandated to add some "component" to their changelog, but would be free to choose whatever.)