Prepare Release #11
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: Prepare Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Type of version bump' | |
| required: true | |
| default: 'minor' | |
| type: choice | |
| options: | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| jobs: | |
| check-bumpver: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_run: ${{ steps.check.outputs.should_run }} | |
| steps: | |
| - name: Check for bumpver commit | |
| id: check | |
| run: | | |
| if [[ "${{ github.event.head_commit.message }}" == *"bump: version"* ]]; then | |
| echo "should_run=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_run=true" >> $GITHUB_OUTPUT | |
| fi | |
| bump-version: | |
| name: Bump Version | |
| if: needs.check-bumpver.outputs.should_run == 'true' | |
| needs: check-bumpver | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: 'false' | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install . | |
| - name: Generate GitHub App token | |
| id: generate_token | |
| uses: tibdex/github-app-token@v2 | |
| with: | |
| app_id: ${{ secrets.HAWKY_APP_ID }} | |
| private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} | |
| - name: Set up git for pushing | |
| run: | | |
| git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git | |
| - name: Set git user for HawkyMcBuilderFace bot | |
| run: | | |
| git config user.name "${{ secrets.HAWKY_APP_USER }}" | |
| git config user.email "${{ secrets.HAWKY_APP_USER_EMAIL }}" | |
| - name: Bump version with bumpver | |
| run: | | |
| if [[ "${{ github.event.inputs.bump_type }}" == "major" ]]; then | |
| bumpver update --major --commit | |
| else | |
| bumpver update --minor --commit | |
| fi | |
| - name: Push version bump commit | |
| run: | | |
| git push | |
| tag-version: | |
| name: Tag Version | |
| if: needs.check-bumpver.outputs.should_run == 'true' | |
| needs: [check-bumpver, bump-version] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: 'false' | |
| fetch-depth: 0 | |
| - name: Generate GitHub App token | |
| id: generate_token | |
| uses: tibdex/github-app-token@v2 | |
| with: | |
| app_id: ${{ secrets.HAWKY_APP_ID }} | |
| private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} | |
| - name: Set up git for pulling latest | |
| run: | | |
| git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git | |
| - name: Fetch and checkout latest main | |
| run: | | |
| git fetch origin main | |
| git checkout origin/main | |
| - name: Get version from pyproject.toml | |
| id: get_version | |
| run: | | |
| VERSION=$(grep '^version =' pyproject.toml | head -1 | cut -d '"' -f2) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create and push tag for current version (with verbose logging) | |
| run: | | |
| git remote -v | |
| git tag v${{ steps.get_version.outputs.version }} | |
| git fetch origin --tags --verbose | |
| git push origin v${{ steps.get_version.outputs.version }} | |
| bump-patch-version: | |
| name: Bump Patch Version | |
| if: needs.check-bumpver.outputs.should_run == 'true' | |
| needs: [check-bumpver, bump-version, tag-version] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: 'false' | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install . | |
| - name: Generate GitHub App token | |
| id: generate_token | |
| uses: tibdex/github-app-token@v2 | |
| with: | |
| app_id: ${{ secrets.HAWKY_APP_ID }} | |
| private_key: ${{ secrets.HAWKY_APP_PRIVATE_KEY }} | |
| - name: Set up git for pushing | |
| run: | | |
| git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.repository }}.git | |
| - name: Set git user for HawkyMcBuilderFace bot | |
| run: | | |
| git config user.name "${{ secrets.HAWKY_APP_USER }}" | |
| git config user.email "${{ secrets.HAWKY_APP_USER_EMAIL }}" | |
| - name: Fetch and checkout latest main | |
| run: | | |
| git fetch origin main | |
| git checkout origin/main | |
| - name: Bump patch version with bumpver | |
| run: bumpver update --patch --commit | |
| - name: Push patch version bump commit | |
| run: | | |
| git push origin HEAD:main |