Version Bump #8
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 | |
| # Workflow to automatically bump version and create release | |
| # Usage: | |
| # - Manual trigger: Choose version bump type (patch/minor/major) | |
| # - Automatically creates PR with version changes | |
| # - After PR merge, creates git tag to trigger release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch # 0.1.9 -> 0.1.10 | |
| - minor # 0.1.9 -> 0.2.0 | |
| - major # 0.1.9 -> 1.0.0 | |
| default: 'patch' | |
| create_tag: | |
| description: 'Create git tag after version bump (triggers release)' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| bump-version: | |
| name: Bump Version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }} | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-edit | |
| run: cargo install cargo-edit | |
| - name: Get current version | |
| id: current | |
| run: | | |
| CURRENT_VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2) | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $CURRENT_VERSION" | |
| - name: Bump version in Cargo.toml | |
| id: bump | |
| run: | | |
| cargo set-version --bump ${{ inputs.bump_type }} | |
| NEW_VERSION=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2) | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION" | |
| - name: Extract major.minor version | |
| id: version_parts | |
| run: | | |
| NEW_VERSION="${{ steps.bump.outputs.version }}" | |
| MAJOR_MINOR=$(echo $NEW_VERSION | cut -d. -f1-2) | |
| echo "major_minor=$MAJOR_MINOR" >> $GITHUB_OUTPUT | |
| echo "Interface version (major.minor): $MAJOR_MINOR" | |
| - name: Check INTERFACE_SPEC.md consistency | |
| run: | | |
| CARGO_MINOR="${{ steps.version_parts.outputs.major_minor }}" | |
| SPEC_VERSION=$(grep '^\*\*Version\*\*:' docs/INTERFACE_SPEC.md | head -1 | sed 's/.*: //') | |
| if [ "$CARGO_MINOR" != "$SPEC_VERSION" ]; then | |
| echo "❌ ERROR: Version mismatch detected!" | |
| echo " Cargo.toml (major.minor): $CARGO_MINOR" | |
| echo " INTERFACE_SPEC.md: $SPEC_VERSION" | |
| echo "" | |
| echo "🚨 INTERFACE_SPEC.md must be manually updated when interface changes!" | |
| echo " - If this is a breaking change: update INTERFACE_SPEC.md version" | |
| echo " - If this is a new feature: update INTERFACE_SPEC.md version" | |
| echo " - If this is a bug fix only: INTERFACE_SPEC.md should NOT change" | |
| exit 1 | |
| fi | |
| echo "✅ INTERFACE_SPEC.md version is consistent: $SPEC_VERSION" | |
| - name: Update version in CLAUDE.md | |
| run: | | |
| MAJOR_MINOR="${{ steps.version_parts.outputs.major_minor }}" | |
| sed -i "s/^\*\*Version\*\*: .*/\*\*Version\*\*: $MAJOR_MINOR/" CLAUDE.md | |
| sed -i "s/^\*\*Spec Version\*\*: .*/\*\*Spec Version\*\*: $MAJOR_MINOR/" CLAUDE.md | |
| echo "✅ Updated CLAUDE.md to version $MAJOR_MINOR" | |
| - name: Update mcp-server.json | |
| run: | | |
| MAJOR_MINOR="${{ steps.version_parts.outputs.major_minor }}" | |
| jq --arg version "$MAJOR_MINOR" '.version = $version' mcp-server.json > mcp-server.json.tmp | |
| mv mcp-server.json.tmp mcp-server.json | |
| echo "✅ Updated mcp-server.json to version $MAJOR_MINOR" | |
| - name: Update Cargo.lock | |
| run: cargo update -p intent-engine | |
| - name: Create Pull Request | |
| if: inputs.create_tag == false | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: | | |
| chore: bump version to ${{ steps.bump.outputs.version }} | |
| - Update Cargo.toml version to ${{ steps.bump.outputs.version }} | |
| - Update CLAUDE.md version to ${{ steps.version_parts.outputs.major_minor }} | |
| - Update mcp-server.json version to ${{ steps.version_parts.outputs.major_minor }} | |
| - Verify INTERFACE_SPEC.md consistency (${{ steps.version_parts.outputs.major_minor }}) | |
| - Update Cargo.lock | |
| branch: release/v${{ steps.bump.outputs.version }} | |
| delete-branch: true | |
| title: "chore: Release v${{ steps.bump.outputs.version }}" | |
| body: | | |
| ## 🚀 Release v${{ steps.bump.outputs.version }} | |
| This PR bumps the version from **v${{ steps.current.outputs.version }}** to **v${{ steps.bump.outputs.version }}**. | |
| ### Changes | |
| - ✅ Updated `Cargo.toml` version to **${{ steps.bump.outputs.version }}** | |
| - ✅ Updated `CLAUDE.md` version to **${{ steps.version_parts.outputs.major_minor }}** | |
| - ✅ Updated `mcp-server.json` version to **${{ steps.version_parts.outputs.major_minor }}** | |
| - ✅ Verified `INTERFACE_SPEC.md` consistency (**${{ steps.version_parts.outputs.major_minor }}**) | |
| - ✅ Updated `Cargo.lock` | |
| ### Version Strategy | |
| - **Implementation version** (Cargo.toml): `${{ steps.bump.outputs.version }}` (major.minor.patch) | |
| - **Interface version** (INTERFACE_SPEC.md): `${{ steps.version_parts.outputs.major_minor }}` (major.minor) | |
| - INTERFACE_SPEC.md is the source of truth for interface contract | |
| ### Next Steps | |
| 1. Review the changes | |
| 2. Merge this PR | |
| 3. Manually create tag `v${{ steps.bump.outputs.version }}` to trigger release build | |
| Or re-run this workflow with "Create git tag" option to automatically create the tag. | |
| --- | |
| <sub>Bump type: **${{ inputs.bump_type }}**</sub> | |
| labels: | | |
| release | |
| automated | |
| - name: Commit and tag (direct to main) | |
| if: inputs.create_tag == true | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Cargo.toml Cargo.lock CLAUDE.md mcp-server.json | |
| git commit -m "chore: bump version to ${{ steps.bump.outputs.version }}" | |
| # Handle existing tags | |
| TAG="v${{ steps.bump.outputs.version }}" | |
| # Delete local tag if exists | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "⚠️ Tag $TAG already exists locally, deleting..." | |
| git tag -d "$TAG" | |
| fi | |
| # Create new tag | |
| git tag -a "$TAG" -m "Release $TAG" | |
| # Push commit | |
| git push origin main | |
| # Push tag with force to overwrite if exists remotely | |
| echo "Pushing tag $TAG (will overwrite if exists)..." | |
| git push -f origin "$TAG" | |
| echo "✅ Version bumped and tagged: $TAG" | |
| echo "🚀 Release workflow should be triggered automatically (requires GH_PAT secret)" | |
| - name: Summary | |
| run: | | |
| echo "## 🎉 Version Bump Complete" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Previous version**: ${{ steps.current.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **New version**: ${{ steps.bump.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Bump type**: ${{ inputs.bump_type }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Create tag**: ${{ inputs.create_tag }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ inputs.create_tag }}" == "true" ]; then | |
| echo "✅ Tag created: \`v${{ steps.bump.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -n "${{ secrets.GH_PAT }}" ]; then | |
| echo "🚀 Release workflow will start shortly" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "⚠️ **Release workflow NOT triggered** (GH_PAT secret not configured)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Manual action required:**" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Go to [Release Workflow](https://github.com/${{ github.repository }}/actions/workflows/release.yml)" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Click 'Run workflow'" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Enter tag: \`v${{ steps.bump.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**To fix permanently:** Add GH_PAT secret with repo scope" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| else | |
| echo "📝 Pull request created for review" >> $GITHUB_STEP_SUMMARY | |
| fi |