Skip to content

Commit 23ce0c7

Browse files
authored
docs: keep the README version in step with the next release (#315)
1 parent a4d15e4 commit 23ce0c7

5 files changed

Lines changed: 72 additions & 8 deletions

File tree

‎.github/workflows/release-drafter.yml‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,62 @@ jobs:
1414
contents: write
1515
pull-requests: read
1616
uses: cpp-linter/.github/.github/workflows/release-drafter.yml@main
17+
18+
# Keep the `rev:` in the README examples equal to the next release, so the
19+
# tagged commit (and the PyPI page built from it) shows the right version.
20+
# This opens or updates a PR; merge it before publishing the draft release.
21+
bump-readme-rev:
22+
needs: draft-release
23+
runs-on: ubuntu-latest
24+
permissions:
25+
# read the draft release, push the PR branch and open the PR
26+
contents: write
27+
pull-requests: write
28+
concurrency:
29+
group: bump-readme-rev
30+
cancel-in-progress: true
31+
steps:
32+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
33+
with:
34+
persist-credentials: false
35+
36+
- name: Get the draft release tag
37+
id: draft
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
REPO: ${{ github.repository }}
41+
run: |
42+
# release-drafter updates the first draft it finds, so read the same one
43+
tag=$(gh api "repos/$REPO/releases" --jq '[.[] | select(.draft)][0].tag_name // ""')
44+
if ! [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
45+
echo "No draft release with a vX.Y.Z tag ('$tag'), nothing to do."
46+
tag=""
47+
fi
48+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
49+
50+
- name: Use the tag in the README examples
51+
if: steps.draft.outputs.tag != ''
52+
env:
53+
TAG: ${{ steps.draft.outputs.tag }}
54+
run: |
55+
sed -E -i "s/^([[:space:]]*rev: )v[0-9]+\.[0-9]+\.[0-9]+/\1${TAG}/" \
56+
README.md examples/*/README.md
57+
git diff --stat
58+
59+
- name: Open or update the pull request
60+
if: steps.draft.outputs.tag != ''
61+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
62+
with:
63+
token: ${{ github.token }}
64+
sign-commits: true
65+
branch: bump-readme-rev
66+
delete-branch: true
67+
commit-message: "docs: use ${{ steps.draft.outputs.tag }} in README"
68+
title: "docs: use ${{ steps.draft.outputs.tag }} in README"
69+
body: |
70+
Sets `rev:` in the README examples to `${{ steps.draft.outputs.tag }}`, the version of the
71+
current draft release. Merge this PR first, then publish the draft release, so the tag and
72+
the PyPI page show the new version.
73+
labels: |
74+
documentation
75+
skip-changelog

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ related issues.
4949
Releases are tagged by maintainers. Versioning follows
5050
[setuptools-scm](https://github.com/pypa/setuptools-scm) — the version is
5151
derived from git tags automatically.
52+
53+
Release Drafter keeps a draft of the next release. Whenever the `rev:` in the
54+
README examples differs from that draft's tag, a bot PR named
55+
`docs: use vX.Y.Z in README` updates it. Merge that PR first, then publish the
56+
draft release, so the tag and the PyPI page show the new version.

‎README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Add this configuration to your `.pre-commit-config.yaml` file:
1919
```yaml
2020
repos:
2121
- repo: https://github.com/cpp-linter/cpp-linter-hooks
22-
rev: v1.8.1
22+
rev: v1.8.2
2323
hooks:
2424
- id: clang-format
2525
args: [--style=file]
@@ -214,7 +214,7 @@ See [Performance optimization](https://github.com/cpp-linter/cpp-linter-hooks#pe
214214
```yaml
215215
repos:
216216
- repo: https://github.com/cpp-linter/cpp-linter-hooks
217-
rev: v1.8.1 # includes --fix support
217+
rev: v1.8.2 # includes --fix support
218218
hooks:
219219
- id: clang-tidy
220220
args: [--fix]
@@ -237,7 +237,7 @@ repository root works too.
237237
```yaml
238238
repos:
239239
- repo: https://github.com/cpp-linter/cpp-linter-hooks
240-
rev: v1.8.1
240+
rev: v1.8.2
241241
hooks:
242242
- id: clang-tidy
243243
# Auto-detects ./build/compile_commands.json if present
@@ -292,7 +292,7 @@ Three self-contained templates plus quick snippets for other common setups.
292292

293293
```yaml
294294
- repo: https://github.com/cpp-linter/cpp-linter-hooks
295-
rev: v1.8.1
295+
rev: v1.8.2
296296
hooks:
297297
- id: clang-format
298298
args: [--style=file]
@@ -306,7 +306,7 @@ or `-j`:
306306

307307
```yaml
308308
- repo: https://github.com/cpp-linter/cpp-linter-hooks
309-
rev: v1.8.1
309+
rev: v1.8.2
310310
hooks:
311311
- id: clang-tidy
312312
args: [--jobs=4]
@@ -343,7 +343,7 @@ This approach ensures that only modified files are checked, further speeding up
343343
```yaml
344344
repos:
345345
- repo: https://github.com/cpp-linter/cpp-linter-hooks
346-
rev: v1.8.1
346+
rev: v1.8.2
347347
hooks:
348348
- id: clang-format
349349
args: [--style=file, --verbose] # Shows processed files

‎examples/cmake/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If you already have a CMake project, you need **three files**:
77
```yaml
88
repos:
99
- repo: https://github.com/cpp-linter/cpp-linter-hooks
10-
rev: v1.8.1
10+
rev: v1.8.2
1111
hooks:
1212
- id: clang-format
1313
args: [--style=file]

‎examples/meson/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ database.
88
```yaml
99
repos:
1010
- repo: https://github.com/cpp-linter/cpp-linter-hooks
11-
rev: v1.8.1
11+
rev: v1.8.2
1212
hooks:
1313
- id: clang-format
1414
args: [--style=file]

0 commit comments

Comments
 (0)