Skip to content

Commit 28f5645

Browse files
Merge eb1c01e into 3a6e13d
2 parents 3a6e13d + eb1c01e commit 28f5645

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,23 @@ jobs:
3636
poetry run changelog-generator \
3737
changelog changelog.md \
3838
--snippets=.snippets \
39-
--in-place
39+
--in-place \
40+
--no-internal
4041
- name: Parse changelog
4142
id: parse_changelog
4243
run: |
43-
poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt
44+
poetry run changelog2version \
45+
--changelog_file changelog.md \
46+
--output changelog.json \
47+
--print \
48+
--debug
49+
echo "CHANGELOG_JSON=$(jq -c . < changelog.json)" >> $GITHUB_ENV
4450
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
45-
cat latest_description.txt >> $GITHUB_OUTPUT
51+
jq -r ".info.description" changelog.json >> $GITHUB_OUTPUT
4652
echo '"EOT"' >> $GITHUB_OUTPUT
47-
latest_version=$(poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
48-
echo "latest_version=$latest_version" >> $GITHUB_ENV
53+
echo "latest_version=$(jq -r '.info.version' changelog.json)" >> $GITHUB_ENV
4954
- name: Build package
55+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
5056
run: |
5157
poetry run changelog2version \
5258
--changelog_file changelog.md \
@@ -55,13 +61,15 @@ jobs:
5561
--debug
5662
poetry build
5763
- name: Publish package
64+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
5865
uses: pypa/gh-action-pypi-publish@release/v1.5
5966
with:
6067
password: ${{ secrets.PYPI_API_TOKEN }}
6168
skip_existing: true
6269
verbose: true
6370
print_hash: true
6471
- name: Create Release
72+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
6573
uses: actions/create-release@v1
6674
env:
6775
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-release.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@ jobs:
3333
poetry run changelog-generator \
3434
changelog changelog.md \
3535
--snippets=.snippets \
36-
--in-place
36+
--in-place \
37+
--no-internal
3738
- name: Parse changelog
3839
id: parse_changelog
3940
run: |
40-
poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt
41+
poetry run changelog2version \
42+
--changelog_file changelog.md \
43+
--output changelog.json \
44+
--print \
45+
--debug
46+
echo "CHANGELOG_JSON=$(jq -c . < changelog.json)" >> $GITHUB_ENV
4147
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
42-
cat latest_description.txt >> $GITHUB_OUTPUT
48+
jq -r ".info.description" changelog.json >> $GITHUB_OUTPUT
4349
echo '"EOT"' >> $GITHUB_OUTPUT
44-
latest_version=$(poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
45-
echo "latest_version=$latest_version" >> $GITHUB_ENV
50+
echo "latest_version=$(jq -r '.info.version' changelog.json)" >> $GITHUB_ENV
4651
- name: Build package
52+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
4753
run: |
4854
poetry run changelog2version \
4955
--changelog_file changelog.md \
@@ -53,9 +59,11 @@ jobs:
5359
--debug
5460
poetry build
5561
- name: Test built package
62+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
5663
run: |
5764
twine check dist/*.tar.gz
5865
- name: Archive build package artifact
66+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
5967
uses: actions/upload-artifact@v4
6068
with:
6169
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
@@ -64,6 +72,7 @@ jobs:
6472
path: dist/*.tar.gz
6573
retention-days: 14
6674
- name: Publish package
75+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
6776
uses: pypa/gh-action-pypi-publish@release/v1.5
6877
with:
6978
repository_url: https://test.pypi.org/legacy/
@@ -72,6 +81,7 @@ jobs:
7281
verbose: true
7382
print_hash: true
7483
- name: Create Prerelease
84+
if: ${{ !contains(fromJson(env.CHANGELOG_JSON).info.meta.scope, 'internal') }}
7585
uses: actions/create-release@v1
7686
env:
7787
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.snippets/23.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Document and use no-internal option
2+
<!--
3+
type: feature
4+
scope: internal
5+
affected: all
6+
-->
7+
8+
- Document `--no-internal` option in `README`
9+
- Use `jq` instead of complex Python based `changelog.json` parsing in `release` and `test-release` workflows
10+
- Skip building, testing, publishing and creating (pre)releases if the latest change was marked as `internal`

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ version entries and version bumps multiple times otherwise.*
9898
changelog-generator changelog changelog.md --snippets=.snippets [--in-place]
9999
```
100100

101+
The option `--no-internal` ignores all snippets with scope `internal` during
102+
the changelog generation. This is useful if those changes are not affecting
103+
the "product" like internal documentation changes or similar things, which e.g.
104+
do not require a deployment.
105+
101106
### Parse
102107

103108
Parse an existing snippet file and return the data as JSON without indentation
@@ -163,7 +168,8 @@ jobs:
163168
changelog-generator \
164169
changelog changelog.md \
165170
--snippets=.snippets \
166-
--in-place
171+
--in-place \
172+
--no-internal
167173
```
168174
169175
#### Other
@@ -173,7 +179,8 @@ pip install snippets2changelog
173179
changelog-generator \
174180
changelog changelog.md \
175181
--snippets=.snippets \
176-
--in-place
182+
--in-place \
183+
--no-internal
177184
```
178185

179186
## Contributing
@@ -227,6 +234,12 @@ not require any changes by the user to keep the system running after upgrading.
227234
requires the user to perform additional tasks, adopt his currently running
228235
code or in general can't be used as is anymore.
229236

237+
The scope of a change shall either be:
238+
- `internal` if no new deployment is required for this change, like updates in
239+
the documentation for example
240+
- `external` or `all` if this change affects the public API of this package or
241+
requires a new tag and deployment for any other reason
242+
230243
The changelog entry shall be short but meaningful and can of course contain
231244
links and references to other issues or PRs. New lines are only allowed for a
232245
new bulletpoint entry. Usage examples or other code snippets should be placed

0 commit comments

Comments
 (0)