Skip to content

Commit

Permalink
Create updateVersion.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Knerio authored May 28, 2024
1 parent 479c0ef commit bfbbdba
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/updateVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update README with Latest Version

on:
release:
types: [published]

jobs:
update-readme:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Get Latest Release Version
id: get_latest_release
uses: actions/github-script@v6
with:
script: |
const latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
return { version: latestRelease.data.tag_name.replace(/^v/, '') };
- name: Update README.md
id: update_readme
run: |
LATEST_VERSION=${{ steps.get_latest_release.outputs.version }}
# Replace the version string in the Gradle dependency line
sed -i "s/de\.derioo:javautils:[0-9]*\.[0-9]*\.[0-9]*/de.derioo:javautils:${LATEST_VERSION}/g" README.md
# Replace the version string in the Maven dependency line
sed -i "s/<version>[0-9]*\.[0-9]*\.[0-9]*<\/version>/<version>${LATEST_VERSION}<\/version>/g" README.md
- name: Commit Changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
git commit -m "Update README with latest version ${{ steps.get_latest_release.outputs.version }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit bfbbdba

Please sign in to comment.