Bump Version #2
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
| # Copyright 2025 qBraid | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License.\ | |
| name: Bump Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Select the version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - major | |
| - minor | |
| - patch | |
| default: 'patch' | |
| jobs: | |
| bump-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: 'main' | |
| - name: Create feature branch | |
| run: git checkout -b qbraid-bot/${{ github.run_id }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install "qbraid-core>=0.1.17" pyyaml | |
| - name: Setup Git config | |
| run: | | |
| git config --global user.name 'qbraidTeam' | |
| git config --global user.email 'qbraid.team@qbraid.com' | |
| - name: Bump version, commit and push | |
| id: bump_version | |
| run: | | |
| BUMP_TYPE=${{ github.event.inputs.bump_type }} | |
| VERSION=$(python3 bin/bump_version.py $BUMP_TYPE) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| git add qbraid_algorithms/_version.py | |
| git commit -m "Bump $BUMP_TYPE version to $VERSION" | |
| git push origin qbraid-bot/${{ github.run_id }} | |
| - name: Create Pull Request | |
| id: create_pr | |
| run: | | |
| VERSION=${{ steps.bump_version.outputs.version }} | |
| PR_URL=$(gh pr create -B main -H qbraid-bot/${{ github.run_id }} --title "Bump project version to $VERSION" --body "This PR bumps the project version to $VERSION") | |
| PR_NUMBER=$(echo "$PR_URL" | grep -o '[0-9]*$') | |
| echo "url=$PR_URL" >> $GITHUB_OUTPUT | |
| echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Summary | |
| run: | | |
| VERSION=${{ steps.bump_version.outputs.version }} | |
| PR_URL=${{ steps.create_pr.outputs.url }} | |
| PR_NUMBER=${{ steps.create_pr.outputs.number }} | |
| echo "Opened PR [#$PR_NUMBER]($PR_URL) to update project to version **$VERSION**." >> $GITHUB_STEP_SUMMARY |