chore: bump version to #25
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: Version Bump and Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Version bump type' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| push: | |
| branches: [ main, master ] | |
| paths-ignore: | |
| - '**.md' | |
| - '.github/**' | |
| jobs: | |
| version-bump: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.AI_GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.13" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install semver | |
| - name: Get current version | |
| id: current_version | |
| run: | | |
| CURRENT_VERSION=$(python setup.py --version) | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $CURRENT_VERSION" | |
| - name: Calculate new version | |
| id: new_version | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| BUMP_TYPE="${{ github.event.inputs.bump_type }}" | |
| else | |
| BUMP_TYPE="patch" | |
| fi | |
| CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}" | |
| # Split version into components | |
| IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" | |
| MAJOR="${VERSION_PARTS[0]}" | |
| MINOR="${VERSION_PARTS[1]}" | |
| PATCH="${VERSION_PARTS[2]}" | |
| case $BUMP_TYPE in | |
| major) | |
| NEW_MAJOR=$((MAJOR + 1)) | |
| NEW_MINOR=0 | |
| NEW_PATCH=0 | |
| ;; | |
| minor) | |
| NEW_MAJOR=$MAJOR | |
| NEW_MINOR=$((MINOR + 1)) | |
| NEW_PATCH=0 | |
| ;; | |
| patch) | |
| NEW_MAJOR=$MAJOR | |
| NEW_MINOR=$MINOR | |
| NEW_PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEW_VERSION="$NEW_MAJOR.$NEW_MINOR.$NEW_PATCH" | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION" | |
| - name: Update version in setup.py | |
| run: | | |
| sed -i "s/version=\"${{ steps.current_version.outputs.current_version }}\"/version=\"${{ steps.new_version.outputs.new_version }}\"/" setup.py | |
| echo "Updated setup.py version to ${{ steps.new_version.outputs.new_version }}" | |
| - name: Create and push tag | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add setup.py | |
| git commit -m "Bump version to ${{ steps.new_version.outputs.new_version }}" | |
| git tag -a "v${{ steps.new_version.outputs.new_version }}" -m "Release version ${{ steps.new_version.outputs.new_version }}" | |
| git push origin HEAD:${{ github.ref }} | |
| git push origin "v${{ steps.new_version.outputs.new_version }}" | |
| - name: Trigger publish workflow | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'publish.yml', | |
| ref: context.ref | |
| }) |