Skip to content

Commit 4cf1e66

Browse files
authored
Update readme-version.yml
1 parent cf38a77 commit 4cf1e66

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

.github/workflows/readme-version.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
release:
55
types:
66
- published
7+
workflow_dispatch:
78

89
jobs:
910
update-version:
@@ -13,15 +14,26 @@ jobs:
1314
- name: Checkout repository
1415
uses: actions/checkout@v2
1516

17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
1622
- name: Update version in README
1723
run: |
18-
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///g')
19-
sed -E -i "s/\d+\.\d+\.\d+/$VERSION/g" README.md
24+
# Install the required Python packages
25+
python -m pip install --upgrade pip
26+
pip install beautifulsoup4
27+
28+
# Extract the version from the build.gradle.kts file
29+
VERSION=$(grep -oP 'version\s*=\s*"\K\d+\.\d+\.\d+' build.gradle.kts)
30+
31+
# Update the README.md file
32+
python -c "import re; with open('README.md', 'r') as file: content = file.read(); content = re.sub(r'\d+\.\d+\.\d+', f'{VERSION}', content); with open('README.md', 'w') as file: file.write(content)"
2033
2134
- name: Commit and push changes
2235
run: |
2336
git config --global user.name "GitHub Actions Bot"
24-
git config --global user.email "collinjbarber@gmail.com"
37+
git config --global user.email "<your-email-here>"
2538
git add README.md
26-
git commit -m "Update version in README.md"
27-
git push
39+
git diff --quiet && git diff --staged --quiet || (git commit -m "Update version in README.md" && git push)

0 commit comments

Comments
 (0)