diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index c1dd3ae..d04dbdd 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -14,3 +14,62 @@ jobs: contents: write pull-requests: read uses: cpp-linter/.github/.github/workflows/release-drafter.yml@main + + # Keep the `rev:` in the README examples equal to the next release, so the + # tagged commit (and the PyPI page built from it) shows the right version. + # This opens or updates a PR; merge it before publishing the draft release. + bump-readme-rev: + needs: draft-release + runs-on: ubuntu-latest + permissions: + # read the draft release, push the PR branch and open the PR + contents: write + pull-requests: write + concurrency: + group: bump-readme-rev + cancel-in-progress: true + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Get the draft release tag + id: draft + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: | + # release-drafter updates the first draft it finds, so read the same one + tag=$(gh api "repos/$REPO/releases" --jq '[.[] | select(.draft)][0].tag_name // ""') + if ! [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "No draft release with a vX.Y.Z tag ('$tag'), nothing to do." + tag="" + fi + echo "tag=$tag" >> "$GITHUB_OUTPUT" + + - name: Use the tag in the README examples + if: steps.draft.outputs.tag != '' + env: + TAG: ${{ steps.draft.outputs.tag }} + run: | + sed -E -i "s/^([[:space:]]*rev: )v[0-9]+\.[0-9]+\.[0-9]+/\1${TAG}/" \ + README.md examples/*/README.md + git diff --stat + + - name: Open or update the pull request + if: steps.draft.outputs.tag != '' + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + token: ${{ github.token }} + sign-commits: true + branch: bump-readme-rev + delete-branch: true + commit-message: "docs: use ${{ steps.draft.outputs.tag }} in README" + title: "docs: use ${{ steps.draft.outputs.tag }} in README" + body: | + Sets `rev:` in the README examples to `${{ steps.draft.outputs.tag }}`, the version of the + current draft release. Merge this PR first, then publish the draft release, so the tag and + the PyPI page show the new version. + labels: | + documentation + skip-changelog diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 861396c..7f6d56f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,3 +49,8 @@ related issues. Releases are tagged by maintainers. Versioning follows [setuptools-scm](https://github.com/pypa/setuptools-scm) — the version is derived from git tags automatically. + +Release Drafter keeps a draft of the next release. Whenever the `rev:` in the +README examples differs from that draft's tag, a bot PR named +`docs: use vX.Y.Z in README` updates it. Merge that PR first, then publish the +draft release, so the tag and the PyPI page show the new version. diff --git a/README.md b/README.md index c9c3207..5d482d7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Add this configuration to your `.pre-commit-config.yaml` file: ```yaml repos: - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 + rev: v1.8.2 hooks: - id: clang-format args: [--style=file] @@ -214,7 +214,7 @@ See [Performance optimization](https://github.com/cpp-linter/cpp-linter-hooks#pe ```yaml repos: - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 # includes --fix support + rev: v1.8.2 # includes --fix support hooks: - id: clang-tidy args: [--fix] @@ -237,7 +237,7 @@ repository root works too. ```yaml repos: - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 + rev: v1.8.2 hooks: - id: clang-tidy # Auto-detects ./build/compile_commands.json if present @@ -292,7 +292,7 @@ Three self-contained templates plus quick snippets for other common setups. ```yaml - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 + rev: v1.8.2 hooks: - id: clang-format args: [--style=file] @@ -306,7 +306,7 @@ or `-j`: ```yaml - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 + rev: v1.8.2 hooks: - id: clang-tidy args: [--jobs=4] @@ -343,7 +343,7 @@ This approach ensures that only modified files are checked, further speeding up ```yaml repos: - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 + rev: v1.8.2 hooks: - id: clang-format args: [--style=file, --verbose] # Shows processed files diff --git a/examples/cmake/README.md b/examples/cmake/README.md index b26e80a..803d98c 100644 --- a/examples/cmake/README.md +++ b/examples/cmake/README.md @@ -7,7 +7,7 @@ If you already have a CMake project, you need **three files**: ```yaml repos: - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 + rev: v1.8.2 hooks: - id: clang-format args: [--style=file] diff --git a/examples/meson/README.md b/examples/meson/README.md index e3e7816..6cd5745 100644 --- a/examples/meson/README.md +++ b/examples/meson/README.md @@ -8,7 +8,7 @@ database. ```yaml repos: - repo: https://github.com/cpp-linter/cpp-linter-hooks - rev: v1.8.1 + rev: v1.8.2 hooks: - id: clang-format args: [--style=file]