Update update-readme.yml #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update README with Latest Version and Date | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Extract latest version | |
id: get_version | |
run: | | |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "v3.13.0") | |
DATE=$(date +'%a, %b %d, %Y') | |
mkdir -p .temp | |
echo "**Current Version:** $VERSION" > .temp/VERSION.txt | |
echo "**Release Date:** $(date +'%a, %b %d, %Y' || echo "Wed, Oct 30, 2024")" > .temp/DATE.txt | |
- name: Update README | |
run: | | |
version=$(cat .temp/VERSION.txt) | |
date=$(cat .temp/DATE.txt) | |
grep -v '**Current Version:**' .github/README.md > temp && mv temp .github/README.md | |
echo "$version <br>" >> .github/README.md | |
grep -v '**Release Date:**' .github/README.md > temp && mv temp .github/README.md | |
echo "$date" >> .github/README.md | |
- name: Commit changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add .github/README.md | |
git commit -m "Update README with latest version and date" | |
git push |