Skip to content

Commit c27ac20

Browse files
committed
#165 Update Versions in README.md during Release Workflow
1 parent 6bcae48 commit c27ac20

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,33 @@ jobs:
2121
git config user.name "Matomo Java Tracker"
2222
- id: version
2323
run: |
24-
VERSION=$( mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout )
25-
echo "::set-output name=version::${VERSION%-SNAPSHOT}"
24+
VERSION=$(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)
25+
echo "version=${VERSION%-SNAPSHOT}" >> $GITHUB_OUTPUT
2626
- run: mvn -B release:prepare release:perform
2727
env:
2828
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
2929
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
3030
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
31+
- name: Update README.md with release version
32+
env:
33+
RELEASE_VERSION: ${{ steps.version.outputs.version }}
34+
run: |
35+
# Update <version> tags in Maven XML snippets.
36+
# The pattern intentionally excludes -SNAPSHOT versions because the regex
37+
# requires </version> to follow immediately after the numeric version.
38+
sed -i -E \
39+
"s|<version>[0-9]+\.[0-9]+\.[0-9]+</version>|<version>${RELEASE_VERSION}</version>|g" \
40+
README.md
41+
# Update version in Gradle dependency snippets (Groovy and Kotlin DSL).
42+
# Matches the groupId:artifactId:version pattern for this project's artifacts.
43+
sed -i -E \
44+
"s|(org\.piwik\.java\.tracking:[^:\"]+:)[0-9]+\.[0-9]+\.[0-9]+|\1${RELEASE_VERSION}|g" \
45+
README.md
46+
git add README.md
47+
# Only commit if the file actually changed (idempotent on re-runs).
48+
git diff --cached --quiet || \
49+
git commit -m "[ci skip] Update README.md dependency snippets to ${RELEASE_VERSION}"
50+
git push
3151
- uses: release-drafter/release-drafter@v7
3252
with:
3353
version: ${{ steps.version.outputs.version }}

0 commit comments

Comments
 (0)