Update README with Release Version #4
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 Release Version | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch full history to allow branch operations | |
- name: Switch to Default Branch | |
run: | | |
# Determine the default branch dynamically | |
DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch" | cut -d' ' -f5) | |
git fetch origin $DEFAULT_BRANCH | |
git checkout $DEFAULT_BRANCH | |
- name: Extract Release Version | |
id: extract_version | |
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Update README.md with New Version | |
run: | | |
sed -i "s|multi_conn_ac-[0-9.]*-py3-none-any\.whl|multi_conn_ac-refs/heads/main-py3-none-any\.whl|" README.md | |
- name: Commit and Push Changes | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git add README.md | |
git commit -m "Update README.md with version ${{ env.version }}" | |
git push origin HEAD |