Skip to content

Commit b170cc7

Browse files
jaronoff97frzifus
andauthored
Add chloggen to the repository (#1326)
* Add changelog gen * Doc update * Forgot a file in the copypasta * Apply suggestions from code review Co-authored-by: Ben B. <[email protected]> * pin version Co-authored-by: Ben B. <[email protected]>
1 parent 0cf9da2 commit b170cc7

File tree

7 files changed

+183
-7
lines changed

7 files changed

+183
-7
lines changed

.chloggen/1317-chloggen.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component: github_actions
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Introduces the chloggen package to manage the changelog
9+
10+
# One or more tracking issues related to the change
11+
issues:
12+
- 1317
13+
14+
# (Optional) One or more lines of additional information to render under the primary note.
15+
# These lines will be padded with 2 spaces and then inserted directly into the document.
16+
# Use pipe (|) for multiline entries.
17+
subtext:

.chloggen/TEMPLATE.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type:
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component:
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note:
9+
10+
# One or more tracking issues related to the change
11+
issues: []
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

.github/workflows/changelog.yaml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This action requires that any PR targeting the main branch should add a
2+
# yaml file to the ./.chloggen/ directory. If a CHANGELOG entry is not required,
3+
# or if performing maintance on the Changelog, add either \"[chore]\" to the title of
4+
# the pull request or add the \"Skip Changelog\" label to disable this action.
5+
6+
name: changelog
7+
8+
on:
9+
pull_request:
10+
types: [opened, synchronize, reopened, labeled, unlabeled]
11+
branches:
12+
- main
13+
14+
env:
15+
# See: https://github.com/actions/cache/issues/810#issuecomment-1222550359
16+
# Cache downloads for this workflow consistently run in under 1 minute
17+
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
changelog:
25+
runs-on: ubuntu-latest
26+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && !contains(github.event.pull_request.title, '[chore]')}}
27+
28+
steps:
29+
- name: Checkout Repo
30+
uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0
33+
- name: Setup Go
34+
uses: actions/setup-go@v3
35+
with:
36+
go-version: 1.19
37+
- name: Cache Go
38+
id: go-cache
39+
uses: actions/cache@v3
40+
with:
41+
path: |
42+
~/go/bin
43+
~/go/pkg/mod
44+
key: changelog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
45+
46+
- name: Ensure no changes to the CHANGELOG
47+
run: |
48+
if [[ $(git diff --name-only $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} ./CHANGELOG.md) ]]
49+
then
50+
echo "The CHANGELOG should not be directly modified."
51+
echo "Please add a .yaml file to the ./.chloggen/ directory."
52+
echo "See CONTRIBUTING.md for more details."
53+
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped."
54+
false
55+
else
56+
echo "The CHANGELOG was not modified."
57+
fi
58+
59+
- name: Ensure ./.chloggen/*.yaml addition(s)
60+
run: |
61+
if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} ./.chloggen | grep -c \\.yaml) ]]
62+
then
63+
echo "No changelog entry was added to the ./.chloggen/ directory."
64+
echo "Please add a .yaml file to the ./.chloggen/ directory."
65+
echo "See CONTRIBUTING.md for more details."
66+
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped."
67+
false
68+
else
69+
echo "A changelog entry was added to the ./.chloggen/ directory."
70+
fi
71+
72+
- name: Validate ./.chloggen/*.yaml changes
73+
run: |
74+
make chlog-validate \
75+
|| { echo "New ./.chloggen/*.yaml file failed validation."; exit 1; }
76+
77+
# In order to validate any links in the yaml file, render the config to markdown
78+
- name: Render .chloggen changelog entries
79+
run: make chlog-preview > changelog_preview.md
80+
- name: Install markdown-link-check
81+
run: npm install -g markdown-link-check
82+
- name: Run markdown-link-check
83+
run: |
84+
markdown-link-check \
85+
--verbose \
86+
--config .github/workflows/check_links_config.json \
87+
changelog_preview.md \
88+
|| { echo "Check that anchor links are lowercase"; exit 1; }
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "http(s)?://\\d+\\.\\d+\\.\\d+\\.\\d+"
5+
},
6+
{
7+
"pattern": "http(s)?://localhost"
8+
},
9+
{
10+
"pattern": "http(s)?://example.com"
11+
},
12+
{
13+
"pattern": "^#"
14+
}
15+
],
16+
"aliveStatusCodes": [429, 200]
17+
}

CONTRIBUTING.md

+16
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ Every bug fix should be accompanied with a unit test, so that we can prevent reg
135135

136136
They are mostly welcome!
137137

138+
### Adding a Changelog Entry
139+
140+
The [CHANGELOG.md](./CHANGELOG.md) file in this repo is autogenerated from `.yaml` files in the `./.chloggen` directory.
141+
142+
Your pull-request should add a new `.yaml` file to this directory. The name of your file must be unique since the last release.
143+
144+
During the collector release process, all `./.chloggen/*.yaml` files are transcribed into `CHANGELOG.md` and then deleted.
145+
146+
**Recommended Steps**
147+
1. Create an entry file using `make chlog-new`. This generates a file based on your current branch (e.g. `./.chloggen/my-branch.yaml`)
148+
2. Fill in all fields in the new file
149+
3. Run `make chlog-validate` to ensure the new file is valid
150+
4. Commit and push the file
151+
152+
Alternately, copy `./.chloggen/TEMPLATE.yaml`, or just create your file from scratch.
153+
138154
## Operator Lifecycle Manager (OLM)
139155

140156
For production environments, it is recommended to use the [Operator Lifecycle Manager (OLM)](https://github.com/operator-framework/operator-lifecycle-manager) to provision and update the OpenTelemetry Operator. Our operator is available in the [Operator Hub](https://operatorhub.io/operator/opentelemetry-operator), and when making changes involving those manifests the following steps can be used for testing. Refer to the [OLM documentation](https://sdk.operatorframework.io/docs/olm-integration/quickstart-bundle/) for more complete information.

Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ cmctl:
249249
KUSTOMIZE ?= $(LOCALBIN)/kustomize
250250
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
251251
ENVTEST ?= $(LOCALBIN)/setup-envtest
252+
CHLOGGEN ?= $(LOCALBIN)/chloggen
252253

253254
## Tool Versions
254255
KUSTOMIZE_VERSION ?= v4.5.5
@@ -360,3 +361,27 @@ api-docs: crdoc kustomize
360361
$(KUSTOMIZE) build config/crd -o $$TMP_DIR/crd-output.yaml ;\
361362
$(CRDOC) --resources $$TMP_DIR/crd-output.yaml --output docs/api.md ;\
362363
}
364+
365+
366+
.PHONY: chlog-install
367+
chlog-install: $(CHLOGGEN)
368+
$(CHLOGGEN): $(LOCALBIN)
369+
GOBIN=$(LOCALBIN) go install go.opentelemetry.io/build-tools/[email protected]
370+
371+
FILENAME?=$(shell git branch --show-current)
372+
.PHONY: chlog-new
373+
chlog-new: chlog-install
374+
$(CHLOGGEN) new --filename $(FILENAME)
375+
376+
.PHONY: chlog-validate
377+
chlog-validate: chlog-install
378+
$(CHLOGGEN) validate
379+
380+
.PHONY: chlog-preview
381+
chlog-preview: chlog-install
382+
$(CHLOGGEN) update --dry
383+
384+
.PHONY: chlog-update
385+
chlog-update: chlog-install
386+
$(CHLOGGEN) update --version $(VERSION)
387+

RELEASE.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ Steps to release a new version of the OpenTelemetry Operator:
1616

1717
## Generating the changelog
1818

19-
Run this generator:
19+
We now use the chloggen to generate the changelog, simply run the following to generate the Changelog:
20+
2021
```bash
21-
docker run --rm -v "${PWD}:/app" pavolloffay/gch:latest --oauth-token ${GH_WRITE_TOKEN} --owner open-telemetry --repo opentelemetry-operator --branch main
22+
make chlog-update
2223
```
23-
* Note that you must generate a Personal Access Token (PAT) and set `GH_WRITE_TOKEN` as that.
2424

25-
Remove the commits that are not relevant to users, like:
26-
* CI or testing-specific commits (e2e, unit test, ...)
27-
* bug fixes for problems that are not part of a release yet
28-
* version bumps for internal dependencies
25+
This will delete all entries (other than the template) in the `.chloggen` directory and create a populated Changelog.md entry. Make sure that the PR you are generating for the release has the `[chore]` prefix, otherwise CI will not pass.

0 commit comments

Comments
 (0)