PR 2: Convert self-improvement loops to deterministic command+gate #34
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: Release | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ssh-key: ${{ secrets.VERSION_BUMP_KEY }} | |
| fetch-depth: 0 | |
| - name: Determine version | |
| id: version | |
| run: | | |
| PLUGIN_VERSION=$(jq -r '.version' .claude-plugin/plugin.json) | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0") | |
| echo "plugin=$PLUGIN_VERSION latest_tag=$LATEST_TAG" | |
| # If plugin.json version is ahead of the latest tag, use it (manual bump) | |
| if [ "$PLUGIN_VERSION" != "$LATEST_TAG" ]; then | |
| P_MAJOR=$(echo "$PLUGIN_VERSION" | cut -d. -f1) | |
| P_MINOR=$(echo "$PLUGIN_VERSION" | cut -d. -f2) | |
| P_PATCH=$(echo "$PLUGIN_VERSION" | cut -d. -f3) | |
| TAG_MAJOR=$(echo "$LATEST_TAG" | cut -d. -f1) | |
| TAG_MINOR=$(echo "$LATEST_TAG" | cut -d. -f2) | |
| TAG_PATCH=$(echo "$LATEST_TAG" | cut -d. -f3) | |
| if [ "$P_MAJOR" -gt "$TAG_MAJOR" ] 2>/dev/null || \ | |
| ([ "$P_MAJOR" -eq "$TAG_MAJOR" ] && [ "$P_MINOR" -gt "$TAG_MINOR" ]) 2>/dev/null || \ | |
| ([ "$P_MAJOR" -eq "$TAG_MAJOR" ] && [ "$P_MINOR" -eq "$TAG_MINOR" ] && [ "$P_PATCH" -gt "$TAG_PATCH" ]) 2>/dev/null; then | |
| echo "Manual version bump detected: $LATEST_TAG → $PLUGIN_VERSION" | |
| echo "version=$PLUGIN_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "bumped=manual" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "plugin.json version $PLUGIN_VERSION is not ahead of tag $LATEST_TAG — auto-bumping patch" | |
| echo "bumped=auto" >> "$GITHUB_OUTPUT" | |
| fi | |
| else | |
| echo "No manual bump — auto-bumping patch" | |
| echo "bumped=auto" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Auto-bump patch if no manual bump was set | |
| if ! grep -q "version=" "$GITHUB_OUTPUT" 2>/dev/null; then | |
| MAJOR=$(echo "$LATEST_TAG" | cut -d. -f1) | |
| MINOR=$(echo "$LATEST_TAG" | cut -d. -f2) | |
| PATCH=$(echo "$LATEST_TAG" | cut -d. -f3) | |
| NEW_PATCH=$((PATCH + 1)) | |
| NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}" | |
| echo "Auto-bumping: $LATEST_TAG → $NEW_VERSION" | |
| echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Sync version files | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| jq --arg v "$VERSION" '.version = $v' .claude-plugin/plugin.json > tmp.json && mv tmp.json .claude-plugin/plugin.json | |
| - name: Commit version bump | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add .claude-plugin/plugin.json | |
| # Only commit if there are changes | |
| if git diff --cached --quiet; then | |
| echo "Version files already at $VERSION — no commit needed" | |
| else | |
| git commit -m "bump to v${VERSION}" | |
| git push | |
| fi | |
| - name: Generate release notes | |
| id: notes | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| NOTES=$(awk "/^## ${VERSION}$/,/^## /{if(/^## ${VERSION}$/)next; if(/^## /)exit; print}" CHANGELOG.md 2>/dev/null) | |
| if [ -z "$NOTES" ]; then | |
| # Try with v prefix | |
| NOTES=$(awk "/^## v${VERSION}$/,/^## /{if(/^## v${VERSION}$/)next; if(/^## /)exit; print}" CHANGELOG.md 2>/dev/null) | |
| fi | |
| if [ -z "$NOTES" ]; then | |
| NOTES="Merged: ${{ github.event.pull_request.title }}" | |
| fi | |
| { | |
| echo "notes<<EOF" | |
| echo "$NOTES" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create tag and release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ steps.version.outputs.version }}" | |
| if git ls-remote --tags origin "refs/tags/$TAG" | grep -q "$TAG"; then | |
| echo "Tag $TAG already exists — skipping release" | |
| exit 0 | |
| fi | |
| git tag "$TAG" | |
| git push origin "$TAG" | |
| gh release create "$TAG" --title "$TAG" --notes "${{ steps.notes.outputs.notes }}" |