name: Auto Version Bump on: workflow_dispatch: inputs: bump_type: description: 'Version bump type' required: true type: choice options: - patch - minor - major update_readme: description: 'Update README with changes' required: false type: boolean default: true jobs: bump-version: name: Bump Version runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.13" - name: Install dependencies run: pip install toml - name: Bump version id: bump run: | python3 << 'EOF' import toml import sys # Read current version with open('nexus-mcp/pyproject.toml', 'r') as f: config = toml.load(f) current = config['project']['version'] major, minor, patch = map(int, current.split('.')) bump_type = '${{ github.event.inputs.bump_type }}' if bump_type == 'major': major += 1 minor = 0 patch = 0 elif bump_type == 'minor': minor += 1 patch = 0 else: # patch patch += 1 new_version = f"{major}.{minor}.{patch}" # Update version config['project']['version'] = new_version with open('nexus-mcp/pyproject.toml', 'w') as f: toml.dump(config, f) print(f"{current}→{new_version}") # Export for GitHub Actions with open(process.env['GITHUB_OUTPUT'], 'a') as f: f.write(f"old_version={current}\n") f.write(f"new_version={new_version}\n") EOF - name: Update README if: github.event.inputs.update_readme == 'true' run: | DATE=$(date +"%Y-%m-%d") OLD="${{ steps.bump.outputs.old_version }}" NEW="${{ steps.bump.outputs.new_version }}" # Add version entry to README sed -i "s/version = \"$OLD\"/version = \"$NEW\"/" nexus-mcp/pyproject.toml echo "Updated version: $OLD → $NEW" - name: Commit changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add nexus-mcp/pyproject.toml git commit -m "chore: bump version to ${{ steps.bump.outputs.new_version }}" git tag "v${{ steps.bump.outputs.new_version }}" - name: Push changes uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} tags: true - name: Create Release Notes run: | echo "## Release v${{ steps.bump.outputs.new_version }}" > release_notes.md echo "" >> release_notes.md echo "**Previous version:** ${{ steps.bump.outputs.old_version }}" >> release_notes.md echo "**Bump type:** ${{ github.event.inputs.bump_type }}" >> release_notes.md echo "" >> release_notes.md echo "### Changes" >> release_notes.md git log v${{ steps.bump.outputs.old_version }}..HEAD --pretty=format:"- %s" >> release_notes.md cat release_notes.md