|
14 | 14 | contents: write |
15 | 15 | pull-requests: read |
16 | 16 | 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 |
0 commit comments