-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.28 KB
/
version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Update Version
on:
push:
branches:
- main
paths:
- "package.json"
jobs:
update-packages:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Update README Version Badge
run: |
VERSION=$(node -p "require('./package.json').version")
sed -i "s/Version [0-9]*\.[0-9]*\.[0-9]*/Version $VERSION/g" README.md
sed -i "s/badge\/Version-[0-9]*\.[0-9]*\.[0-9]*-/badge\/Version-$VERSION-/g" README.md
- name: Set up Git user
run: |
git config --global user.name 'GitHub Actions Bot'
git config --global user.email 'actions@github.com'
- name: Commit changes
run: |
git add README.md
git commit -m "Update README version" || echo "No changes to commit!"
# Pull latest changes to avoid conflicts
- name: Pull latest changes from main
run: |
git pull origin main --rebase
# Push changes after pulling the latest updates
- name: Push changes
run: |
git push origin HEAD:${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}