fix(release): document PR-based version bump in bump script #14
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: Version Bump | ||
| # Version bumps land on main through normal PRs (protected branch / ruleset safe). | ||
| # After a version-bump PR merges, this workflow tags v{VERSION_CLI}, which triggers | ||
| # release.yml. workflow_dispatch can open a bump PR or tag the current VERSION_CLI. | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - VERSION_CLI | ||
| - src/cortex-cli/VERSION | ||
| workflow_dispatch: | ||
| inputs: | ||
| action: | ||
| description: "Action to perform" | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - tag-current-version | ||
| - open-bump-pr | ||
| bump_type: | ||
| description: "Bump type (only used with open-bump-pr)" | ||
| required: false | ||
| type: choice | ||
| options: | ||
| - patch | ||
| - minor | ||
| - major | ||
| default: patch | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| jobs: | ||
| # Always-green job so skipped tag/PR jobs do not fail the workflow. | ||
| gate: | ||
| name: Workflow started | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Note | ||
| run: | | ||
| echo "event=${{ github.event_name }}" | ||
| echo "ref=${{ github.ref }}" | ||
| echo "Tagging runs only for 'chore: bump version to …' merges or workflow_dispatch." | ||
| tag-on-version-bump-merge: | ||
| name: Tag release on version-bump merge | ||
| runs-on: ubuntu-latest | ||
| if: | | ||
| github.event_name == 'push' && | ||
| contains(github.event.head_commit.message, 'chore: bump version to') | ||
| outputs: | ||
| version: ${{ steps.version.outputs.version }} | ||
| tagged: ${{ steps.tag.outputs.tagged }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Read VERSION_CLI | ||
| id: version | ||
| run: | | ||
| VERSION=$(tr -d '[:space:]' < VERSION_CLI) | ||
| if [ -z "$VERSION" ]; then | ||
| echo "::error::VERSION_CLI is empty" | ||
| exit 1 | ||
| fi | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "Release version from VERSION_CLI: $VERSION" | ||
| - name: Verify bump commit message | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| MSG="${{ github.event.head_commit.message }}" | ||
| if ! echo "$MSG" | grep -q "chore: bump version to ${VERSION}"; then | ||
| echo "::error::Head commit must be 'chore: bump version to ${VERSION}' (got: ${MSG})" | ||
| exit 1 | ||
| fi | ||
| ./scripts/check-cli-version.sh | ||
| - name: Create and push tag | ||
| id: tag | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| TAG="v${VERSION}" | ||
| if git rev-parse "$TAG" >/dev/null 2>&1; then | ||
| echo "Tag $TAG already exists; skipping" | ||
| echo "tagged=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git tag -a "$TAG" -m "Release $TAG" | ||
| git push origin "$TAG" | ||
| echo "tagged=true" >> "$GITHUB_OUTPUT" | ||
| echo "Created and pushed $TAG" | ||
| open-bump-pr: | ||
| name: Open version-bump PR | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'workflow_dispatch' && inputs.action == 'open-bump-pr' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: main | ||
| fetch-depth: 0 | ||
| - name: Bump version | ||
| id: bump | ||
| run: | | ||
| OLD_VERSION=$(tr -d '[:space:]' < VERSION_CLI) | ||
| echo "old_version=$OLD_VERSION" >> "$GITHUB_OUTPUT" | ||
| chmod +x ./scripts/bump-version.sh | ||
| ./scripts/bump-version.sh "${{ inputs.bump_type }}" | ||
| NEW_VERSION=$(tr -d '[:space:]' < VERSION_CLI) | ||
| echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | ||
| - name: Create pull request | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| NEW_VERSION="${{ steps.bump.outputs.new_version }}" | ||
| BRANCH="chore/bump-version-${NEW_VERSION}" | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git checkout -b "$BRANCH" | ||
| git add VERSION_CLI src/cortex-cli/VERSION Cargo.toml Cargo.lock | ||
| git commit -m "chore: bump version to ${NEW_VERSION}" | ||
| git push -u origin "$BRANCH" | ||
| gh pr create \ | ||
| --base main \ | ||
| --head "$BRANCH" \ | ||
| --title "chore: bump version to ${NEW_VERSION}" \ | ||
| --body "$(cat <<EOF | ||
| ## Summary | ||
| Automated version bump from ${{ steps.bump.outputs.old_version }} to ${NEW_VERSION}. | ||
| ## Release path | ||
| 1. Merge this PR (no direct pushes to \`main\`). | ||
| 2. \`version-bump.yml\` tags \`v${NEW_VERSION}\` on merge. | ||
| 3. The tag triggers \`release.yml\` to build artifacts and create the GitHub Release. | ||
| 4. Publish to R2 manually via \`publish-r2.yml\` workflow_dispatch when ready. | ||
| EOF | ||
| )" | ||
| tag-current-version: | ||
| name: Tag current VERSION_CLI | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'workflow_dispatch' && inputs.action == 'tag-current-version' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Read VERSION_CLI | ||
| id: version | ||
| run: | | ||
| VERSION=$(tr -d '[:space:]' < VERSION_CLI) | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| ./scripts/check-cli-version.sh | ||
| - name: Create and push tag | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| TAG="v${VERSION}" | ||
| if git rev-parse "$TAG" >/dev/null 2>&1; then | ||
| echo "::error::Tag $TAG already exists" | ||
| exit 1 | ||
| fi | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git tag -a "$TAG" -m "Release $TAG" | ||
| git push origin "$TAG" | ||
| echo "Created and pushed $TAG (triggers release.yml)" | ||
| summary: | ||
| name: Summary | ||
| runs-on: ubuntu-latest | ||
| needs: [tag-on-version-bump-merge] | ||
| if: always() && needs.tag-on-version-bump-merge.result != 'skipped' | ||
| steps: | ||
| - name: Summary | ||
| run: | | ||
| echo "## Version tag" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| | |" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "|---|---|" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| **Version** | ${{ needs.tag-on-version-bump-merge.outputs.version }} |" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| **Tagged** | ${{ needs.tag-on-version-bump-merge.outputs.tagged }} |" >> "$GITHUB_STEP_SUMMARY" | ||