diff --git a/.github/workflows/VERSION_BUMP_GUIDE.md b/.github/workflows/VERSION_BUMP_GUIDE.md new file mode 100644 index 0000000..a4f2055 --- /dev/null +++ b/.github/workflows/VERSION_BUMP_GUIDE.md @@ -0,0 +1,84 @@ +# Version Bump Guide + +This workflow automatically bumps versions when PRs are merged to main. + +## How It Works + +When you merge a PR to main, the version is automatically bumped based on your commit message: + +### Commit Message Format + +Use conventional commits to control version bumping: + +| Commit Message | Version Bump | Example | +|----------------|--------------|---------| +| `feat: add feature` | **Minor** | v0.1.0 → v0.2.0 | +| `feat!: breaking change` | **Major** | v0.1.0 → v1.0.0 | +| `fix: bug fix` | **Patch** | v0.1.0 → v0.1.1 | +| `[alpha] message` | **Alpha** | v0.1.0-alpha.1 → v0.1.0-alpha.2 | +| `[beta] message` | **Beta** | v0.1.0-beta.1 → v0.1.0-beta.2 | +| `[rc] message` | **RC** | v0.1.0-rc.1 → v0.1.0-rc.2 | +| Any other message | **Minor** (default) | v0.1.0 → v0.2.0 | + +### Examples + +```bash +# Feature (minor bump) +git commit -m "feat: add new agent capability" +# Result: v0.1.0 → v0.2.0 + +# Bug fix (patch bump) +git commit -m "fix: correct context loading" +# Result: v0.1.0 → v0.1.1 + +# Breaking change (major bump) +git commit -m "feat!: redesign agent API" +# Result: v0.1.0 → v1.0.0 + +# Alpha release +git commit -m "[alpha] improve prompt" +# Result: v0.1.0-alpha.1 → v0.1.0-alpha.2 + +# Default (minor bump) +git commit -m "improve documentation" +# Result: v0.1.0 → v0.2.0 +``` + +## What Happens Automatically + +1. ✅ Tests run (smoke tests for both agents) +2. ✅ Version is bumped based on commit message +3. ✅ CHANGELOG.md is updated with changes +4. ✅ Git tag is created (e.g., v0.2.0) +5. ✅ Changes are pushed back to main +6. ✅ GitHub release can be created (optional) + +## Manual Override + +If you want to bump version manually: + +```bash +# Bump specific version type +npm run version:bump alpha +npm run version:bump beta +npm run version:bump rc +npm run version:bump patch +npm run version:bump minor +npm run version:bump major + +# Commit and push +git add VERSION package.json CHANGELOG.md +git commit -m "chore: bump version to vX.Y.Z" +git tag vX.Y.Z +git push origin main --tags +``` + +## Skipping Auto-Bump + +Add `[skip ci]` to your commit message: + +```bash +git commit -m "docs: update README [skip ci]" +``` + +This will skip both tests and version bumping. diff --git a/.github/workflows/test-agents.yml b/.github/workflows/test-agents.yml index d904e1b..5388233 100644 --- a/.github/workflows/test-agents.yml +++ b/.github/workflows/test-agents.yml @@ -126,3 +126,105 @@ jobs: echo "### OpenCoder" >> $GITHUB_STEP_SUMMARY cat results/opencoder/latest.json | jq -r '"- Passed: \(.passed)\n- Failed: \(.failed)\n- Total: \(.total)"' >> $GITHUB_STEP_SUMMARY fi + + auto-version-bump: + name: Auto Version Bump + runs-on: ubuntu-latest + needs: [test-openagent, test-opencoder] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Determine version bump type + id: bump-type + run: | + # Get the last commit message + COMMIT_MSG=$(git log -1 --pretty=%B) + + # Determine bump type from commit message + if echo "$COMMIT_MSG" | grep -qiE "^(feat|feature)\(.*\)!:|^BREAKING CHANGE:|^[a-z]+!:"; then + echo "type=major" >> $GITHUB_OUTPUT + echo "Detected BREAKING CHANGE - bumping major version" + elif echo "$COMMIT_MSG" | grep -qiE "^(feat|feature)(\(.*\))?:"; then + echo "type=minor" >> $GITHUB_OUTPUT + echo "Detected feature - bumping minor version" + elif echo "$COMMIT_MSG" | grep -qiE "^(fix|bugfix)(\(.*\))?:"; then + echo "type=patch" >> $GITHUB_OUTPUT + echo "Detected fix - bumping patch version" + elif echo "$COMMIT_MSG" | grep -qiE "^\[alpha\]"; then + echo "type=alpha" >> $GITHUB_OUTPUT + echo "Detected [alpha] tag - bumping alpha version" + elif echo "$COMMIT_MSG" | grep -qiE "^\[beta\]"; then + echo "type=beta" >> $GITHUB_OUTPUT + echo "Detected [beta] tag - bumping beta version" + elif echo "$COMMIT_MSG" | grep -qiE "^\[rc\]"; then + echo "type=rc" >> $GITHUB_OUTPUT + echo "Detected [rc] tag - bumping rc version" + else + echo "type=minor" >> $GITHUB_OUTPUT + echo "No specific type detected - defaulting to minor version bump" + fi + + - name: Bump version + run: | + BUMP_TYPE="${{ steps.bump-type.outputs.type }}" + + # Get current version + CURRENT_VERSION=$(cat VERSION) + echo "Current version: $CURRENT_VERSION" + + # Bump version in package.json + npm run version:bump:$BUMP_TYPE + + # Get new version + NEW_VERSION=$(cat VERSION) + echo "New version: $NEW_VERSION" + + # Update CHANGELOG.md + DATE=$(date +%Y-%m-%d) + COMMIT_MSG=$(git log -1 --pretty=%B) + + # Create changelog entry + cat > /tmp/changelog_entry.md << EOF + ## [$NEW_VERSION] - $DATE + + ### Changes + - $COMMIT_MSG + + EOF + + # Prepend to CHANGELOG.md (after the header) + if [ -f CHANGELOG.md ]; then + # Insert after the first occurrence of "## [" + awk '/^## \[/ && !found {print; system("cat /tmp/changelog_entry.md"); found=1; next} 1' CHANGELOG.md > /tmp/changelog_new.md + mv /tmp/changelog_new.md CHANGELOG.md + fi + + - name: Commit version bump + run: | + NEW_VERSION=$(cat VERSION) + + git add VERSION package.json CHANGELOG.md + git commit -m "chore: bump version to v$NEW_VERSION [skip ci]" + git tag "v$NEW_VERSION" + + - name: Push changes + run: | + git push origin main --tags + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}