Skip to content

Commit 83272d3

Browse files
Add workflow to update version badge on release
This workflow updates the version badge in the README file whenever a new release is published.
1 parent ac650a0 commit 83272d3

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

.github/workflows/update-badge.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update Version Badge
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
update-badge:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
18+
- name: Get latest tag
19+
id: tag
20+
run: |
21+
TAG=${GITHUB_REF#refs/tags/}
22+
echo "tag=$TAG" >> $GITHUB_OUTPUT
23+
24+
- name: Update version badge in README
25+
run: |
26+
sed -i "s/version-v[0-9\\.]*-blue/version-${{ steps.tag.outputs.tag }}-blue/g" README.md
27+
28+
- name: Commit changes
29+
run: |
30+
git config user.name "github-actions"
31+
git config user.email "github-actions@github.com"
32+
git add README.md
33+
git commit -m "chore: update version badge to ${{ steps.tag.outputs.tag }}"
34+
git push

0 commit comments

Comments
 (0)