Automate the README dependency version on release - #309
Closed
fh-ms wants to merge 2 commits into
Closed
Conversation
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.
There was a problem hiding this comment.
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.1to4.2.0. - Adds an
update-readmejob to the release workflow that rewrites the README dependency<version>fromgithub.event.release.tag_nameand 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The version in the
Usagedependency snippet of the README was maintained by hand and had fallen two releases behind: it still said4.0.1while4.2.0is 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 throughgithub.event.release.tag_name.Change
Add an
update-readmejob tomaven_release.ymlthat 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 as4.1.0-beta1leave the README untouched.ref: ${{ github.event.repository.default_branch }}- areleaseevent checks out the tag in detached HEAD, so the branch has to be requested explicitly.sedactually 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.sedexpression 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
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.ghCLI.