Bump Version, Tag, and Release #8
This file contains hidden or 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: Bump Version, Tag, and Release | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Get current version from __init__.py | |
| id: get_version | |
| run: | | |
| CURRENT_VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]+' runware/__init__.py) | |
| echo "Current version: $CURRENT_VERSION" | |
| echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | |
| - name: Bump patch version | |
| id: bump_version | |
| run: | | |
| IFS='.' read -r major minor patch <<< "$CURRENT_VERSION" | |
| new_patch=$((patch + 1)) | |
| NEW_VERSION="${major}.${minor}.${new_patch}" | |
| echo "New version: $NEW_VERSION" | |
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
| - name: Update version in setup.py | |
| run: | | |
| sed -i -E "s/(version=)[\"']([^\"']+)[\"']/\1\"$NEW_VERSION\"/" setup.py | |
| echo "setup.py updated:" | |
| grep -E "version=" setup.py | |
| - name: Update version in runware/__init__.py | |
| run: | | |
| sed -i -E "s/(__version__\s*=\s*)[\"']([^\"']+)[\"']/\1\"$NEW_VERSION\"/" runware/__init__.py | |
| echo "runware/__init__.py updated:" | |
| grep -E "__version__" runware/__init__.py | |
| - name: Commit version bump changes | |
| run: | | |
| git config user.name "GitHub Action" | |
| git config user.email "action@github.com" | |
| git add setup.py runware/__init__.py | |
| git commit -m "chore: bump version to $NEW_VERSION" || echo "No changes to commit" | |
| - name: Create new tag | |
| run: | | |
| echo "Using NEW_VERSION=$NEW_VERSION from env" | |
| TAG="v$NEW_VERSION" | |
| echo "Creating tag: $TAG" | |
| # Store TAG in GITHUB_ENV for next step | |
| echo "TAG=$TAG" >> $GITHUB_ENV | |
| git tag "$TAG" | |
| - name: Push commit and tag | |
| run: | | |
| echo "Pushing tag $TAG" | |
| git push origin HEAD | |
| git push origin "$TAG" |