Auto-bump develop after release branch created #10
Workflow file for this run
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: Auto-bump develop after release branch created | |
| on: | |
| create: | |
| workflow_dispatch: | |
| inputs: | |
| release_version: | |
| description: 'Release version (e.g., 1.11.0)' | |
| required: true | |
| type: string | |
| env: | |
| PYTHON_VERSION: "3.12" | |
| jobs: | |
| bump-develop: | |
| name: Bump develop to next minor version | |
| runs-on: ubuntu-latest | |
| # Only run for release branch creation or manual dispatch | |
| if: github.event_name == 'workflow_dispatch' || (github.event_name == 'create' && github.ref_type == 'branch' && startsWith(github.ref_name, 'release/')) | |
| timeout-minutes: 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install bump-my-version | |
| run: pip install bump-my-version | |
| - name: Configure git | |
| run: | | |
| git config user.name "stitchee-bot" | |
| git config user.email "stitchee@noreply.github.com" | |
| - name: Extract release version | |
| id: release | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| RELEASE_VERSION="${{ inputs.release_version }}" | |
| else | |
| # For create event, github.ref_name contains the branch name | |
| BRANCH="${{ github.ref_name }}" | |
| RELEASE_VERSION="${BRANCH#release/}" | |
| fi | |
| echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT | |
| echo "📦 Release branch created for version: $RELEASE_VERSION" | |
| - name: Bump develop to next minor | |
| run: | | |
| git fetch origin develop | |
| git checkout develop | |
| CURRENT=$(bump-my-version show current_version) | |
| RELEASE_VERSION="${{ steps.release.outputs.version }}" | |
| echo "Develop is at: $CURRENT" | |
| echo "Release version: $RELEASE_VERSION" | |
| # Only bump if develop is still on the version being released | |
| if [[ "$CURRENT" == "${RELEASE_VERSION}"* ]]; then | |
| echo "✅ Develop needs to be bumped to next minor" | |
| # Calculate next minor version | |
| MAJOR=$(echo "$RELEASE_VERSION" | cut -d. -f1) | |
| MINOR=$(echo "$RELEASE_VERSION" | cut -d. -f2) | |
| NEXT_MINOR=$((MINOR + 1)) | |
| NEXT_VERSION="${MAJOR}.${NEXT_MINOR}.0a1" | |
| echo "Bumping: $CURRENT → $NEXT_VERSION" | |
| bump-my-version bump --new-version "$NEXT_VERSION" | |
| git commit -am "Start $NEXT_VERSION development [skip ci]" | |
| git push origin develop | |
| echo "✅ Develop bumped to $NEXT_VERSION" | |
| else | |
| echo "ℹ️ Develop already at $CURRENT (not on $RELEASE_VERSION), skipping bump" | |
| fi |