Skip to content

Automate the README dependency version on release - #309

Closed
fh-ms wants to merge 2 commits into
mainfrom
automate-readme-version
Closed

Automate the README dependency version on release#309
fh-ms wants to merge 2 commits into
mainfrom
automate-readme-version

Conversation

@fh-ms

@fh-ms fh-ms commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Problem

The version in the Usage dependency snippet of the README was maintained by hand and had fallen two releases behind: it still said 4.0.1 while 4.2.0 is the current release.

It cannot be derived from the pom either, since the pom carries the development version (5.0.0-SNAPSHOT), not the last released one. The release workflow, however, already knows the correct value through github.event.release.tag_name.

Change

Add an update-readme job to maven_release.yml that rewrites the version of the dependency snippet from the release tag and opens a pull request with it, plus a one-off correction of the currently stale version.

The default branch is protected and accepts signed commits only, so the job cannot push to it. It therefore creates a branch, writes the commit through the REST API, and opens a pull request. Going through the API is what makes the commit signed: GitHub signs API-created commits with its web-flow key, which an unattended workflow cannot do on its own. Merging stays a manual, reviewed step.

Details worth noting:

  • needs: publish - the README is only touched once the deploy to Maven Central actually succeeded.
  • if: github.event.release.prerelease == false - pre-releases such as 4.1.0-beta1 leave the README untouched.
  • ref: ${{ github.event.repository.default_branch }} - a release event checks out the tag in detached HEAD, so the branch has to be requested explicitly.
  • The pull request is only opened if the sed actually changed something, and branch creation is skipped when the branch for that version already exists, so a re-run of the workflow neither fails nor produces an empty pull request.
  • The sed expression matches exactly one line and preserves the indentation. It was verified as a dry run against the current README. Should further XML snippets with a <version> element be added to the README later, it needs an anchor.

Notes

  • The commit is created with GITHUB_TOKEN, so it deliberately does not trigger other workflows. That means the checks on the generated pull request will not run by themselves; if that turns out to be a problem, the job needs a token from an app or a bot account instead.
  • No third-party action is used, only the preinstalled gh CLI.

The version in the README usage snippet was maintained by hand and had fallen two releases behind (4.0.1 while 4.2.0 was current). It cannot be derived from the pom, because the pom carries the development version (5.0.0-SNAPSHOT) rather than the last released one.

Add an update-readme job to the release workflow that rewrites the version of the dependency snippet from the release tag and commits it to the default branch. Pre-releases are skipped and the job only runs after a successful deploy. Also correct the currently stale version.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request automates keeping the README’s Maven dependency snippet in sync with the latest released version by updating it as part of the release workflow (rather than relying on manual edits). This fits the codebase by tying documentation versioning to the existing GitHub Releases-based publishing pipeline.

Changes:

  • Updates the hardcoded README dependency version from 4.0.1 to 4.2.0.
  • Adds an update-readme job to the release workflow that rewrites the README dependency <version> from github.event.release.tag_name and pushes the change to the default branch after a successful publish.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
README.md One-off correction of the dependency snippet version to the current release.
.github/workflows/maven_release.yml Adds a post-publish job that updates and commits the README dependency version based on the release tag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The default branch is protected and accepts signed commits only, so the job cannot push the updated README to it directly.

Create the commit through the REST API instead, which signs it with GitHub's web-flow key, and open a pull request for it. Branch creation is skipped when the branch of that version already exists, so a re-run of the workflow does not fail.
@fh-ms fh-ms closed this Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants