From 7857dc0de20050cdded34907d826c63184a65f3d Mon Sep 17 00:00:00 2001 From: ojowwalker77 Date: Sun, 18 Jan 2026 14:46:36 -0300 Subject: [PATCH 1/3] fix: version sync for fork PRs - Change version-sync trigger from pull_request to push on main - Use PAT (MATRIX_BOT_TOKEN) for write access - Add workflow_run trigger to release-plugin - Release now triggers after version-sync completes --- .github/workflows/release-plugin.yml | 10 +++- .github/workflows/version-sync.yml | 85 ++++++---------------------- 2 files changed, 25 insertions(+), 70 deletions(-) diff --git a/.github/workflows/release-plugin.yml b/.github/workflows/release-plugin.yml index 3c66b83..74ef7cf 100644 --- a/.github/workflows/release-plugin.yml +++ b/.github/workflows/release-plugin.yml @@ -1,10 +1,11 @@ name: Release Plugin on: - push: + workflow_run: + workflows: ["Version Sync"] + types: [completed] branches: [main] - paths: - - 'CHANGELOG.md' + push: tags: - 'v*' workflow_dispatch: @@ -19,6 +20,9 @@ permissions: jobs: check-release: name: Check & Create Tag + if: > + github.event_name != 'workflow_run' || + github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} diff --git a/.github/workflows/version-sync.yml b/.github/workflows/version-sync.yml index ce06606..a16c832 100644 --- a/.github/workflows/version-sync.yml +++ b/.github/workflows/version-sync.yml @@ -1,98 +1,49 @@ name: Version Sync on: - pull_request: - types: [opened, synchronize] + push: + branches: [main] paths: - 'CHANGELOG.md' jobs: sync-versions: - name: Sync Version Files runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.MATRIX_BOT_TOKEN }} - name: Extract version from CHANGELOG id: changelog run: | - # Get the first version number from CHANGELOG.md (latest release) VERSION=$(grep -oP '(?<=^## \[)[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -1) - if [ -z "$VERSION" ]; then - echo "No version found in CHANGELOG.md" - exit 1 - fi echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Found version: $VERSION" - - name: Check current versions - id: current + - name: Check if update needed + id: check run: | - PKG_VERSION=$(jq -r '.version' package.json) - PLUGIN_VERSION=$(jq -r '.version' .claude-plugin/plugin.json) - MARKET_VERSION=$(jq -r '.version' .claude-plugin/marketplace.json) - MARKET_PLUGIN_VERSION=$(jq -r '.plugins[0].version' .claude-plugin/marketplace.json) - - echo "package=$PKG_VERSION" >> $GITHUB_OUTPUT - echo "plugin=$PLUGIN_VERSION" >> $GITHUB_OUTPUT - echo "marketplace=$MARKET_VERSION" >> $GITHUB_OUTPUT - echo "marketplace_plugin=$MARKET_PLUGIN_VERSION" >> $GITHUB_OUTPUT - - CHANGELOG_VERSION="${{ steps.changelog.outputs.version }}" - - if [ "$PKG_VERSION" = "$CHANGELOG_VERSION" ] && \ - [ "$PLUGIN_VERSION" = "$CHANGELOG_VERSION" ] && \ - [ "$MARKET_VERSION" = "$CHANGELOG_VERSION" ] && \ - [ "$MARKET_PLUGIN_VERSION" = "$CHANGELOG_VERSION" ]; then - echo "needs_update=false" >> $GITHUB_OUTPUT + PKG=$(jq -r '.version' package.json) + CHANGELOG="${{ steps.changelog.outputs.version }}" + if [ "$PKG" = "$CHANGELOG" ]; then + echo "skip=true" >> $GITHUB_OUTPUT else - echo "needs_update=true" >> $GITHUB_OUTPUT + echo "skip=false" >> $GITHUB_OUTPUT fi - - name: Update version files - if: steps.current.outputs.needs_update == 'true' + - name: Update versions + if: steps.check.outputs.skip == 'false' run: | VERSION="${{ steps.changelog.outputs.version }}" + jq --arg v "$VERSION" '.version = $v' package.json > tmp && mv tmp package.json + jq --arg v "$VERSION" '.version = $v' .claude-plugin/plugin.json > tmp && mv tmp .claude-plugin/plugin.json + jq --arg v "$VERSION" '.version = $v | .plugins[0].version = $v' .claude-plugin/marketplace.json > tmp && mv tmp .claude-plugin/marketplace.json - # Update package.json - jq --arg v "$VERSION" '.version = $v' package.json > package.json.tmp - mv package.json.tmp package.json - - # Update plugin.json - jq --arg v "$VERSION" '.version = $v' .claude-plugin/plugin.json > .claude-plugin/plugin.json.tmp - mv .claude-plugin/plugin.json.tmp .claude-plugin/plugin.json - - # Update marketplace.json (both top-level and plugins[0].version) - jq --arg v "$VERSION" '.version = $v | .plugins[0].version = $v' .claude-plugin/marketplace.json > .claude-plugin/marketplace.json.tmp - mv .claude-plugin/marketplace.json.tmp .claude-plugin/marketplace.json - - echo "Updated all version files to $VERSION" - - - name: Commit changes - if: steps.current.outputs.needs_update == 'true' + - name: Commit & push + if: steps.check.outputs.skip == 'false' run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - - git add package.json .claude-plugin/plugin.json .claude-plugin/marketplace.json + git add -A git commit -m "chore: sync versions to ${{ steps.changelog.outputs.version }}" git push - - - name: Comment on PR - if: steps.current.outputs.needs_update == 'true' - uses: actions/github-script@v7 - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `Version files synced to **${{ steps.changelog.outputs.version }}** from CHANGELOG.md` - }) From 37464e1622c756894bb7c29bbf8396177488bdf9 Mon Sep 17 00:00:00 2001 From: ojowwalker77 Date: Sun, 18 Jan 2026 14:49:54 -0300 Subject: [PATCH 2/3] fix: address greptile review comments --- .github/workflows/release-plugin.yml | 7 ++++--- .github/workflows/version-sync.yml | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-plugin.yml b/.github/workflows/release-plugin.yml index 74ef7cf..0f71018 100644 --- a/.github/workflows/release-plugin.yml +++ b/.github/workflows/release-plugin.yml @@ -20,9 +20,10 @@ permissions: jobs: check-release: name: Check & Create Tag - if: > - github.event_name != 'workflow_run' || - github.event.workflow_run.conclusion == 'success' + if: | + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' || + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} diff --git a/.github/workflows/version-sync.yml b/.github/workflows/version-sync.yml index a16c832..732e6ad 100644 --- a/.github/workflows/version-sync.yml +++ b/.github/workflows/version-sync.yml @@ -9,6 +9,8 @@ on: jobs: sync-versions: runs-on: ubuntu-latest + permissions: + contents: write steps: - uses: actions/checkout@v4 with: @@ -18,6 +20,10 @@ jobs: id: changelog run: | VERSION=$(grep -oP '(?<=^## \[)[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -1) + if [ -z "$VERSION" ]; then + echo "No version found in CHANGELOG.md" + exit 1 + fi echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Check if update needed From edf280efb46323b7d0463a447fc1c442713bb808 Mon Sep 17 00:00:00 2001 From: ojowwalker77 Date: Sun, 18 Jan 2026 15:43:45 -0300 Subject: [PATCH 3/3] fix: check all version files before skipping --- .github/workflows/version-sync.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/version-sync.yml b/.github/workflows/version-sync.yml index 732e6ad..8650ce3 100644 --- a/.github/workflows/version-sync.yml +++ b/.github/workflows/version-sync.yml @@ -29,9 +29,12 @@ jobs: - name: Check if update needed id: check run: | - PKG=$(jq -r '.version' package.json) CHANGELOG="${{ steps.changelog.outputs.version }}" - if [ "$PKG" = "$CHANGELOG" ]; then + PKG=$(jq -r '.version' package.json) + PLUGIN=$(jq -r '.version' .claude-plugin/plugin.json) + MARKET=$(jq -r '.version' .claude-plugin/marketplace.json) + MARKET_PLUGIN=$(jq -r '.plugins[0].version' .claude-plugin/marketplace.json) + if [ "$PKG" = "$CHANGELOG" ] && [ "$PLUGIN" = "$CHANGELOG" ] && [ "$MARKET" = "$CHANGELOG" ] && [ "$MARKET_PLUGIN" = "$CHANGELOG" ]; then echo "skip=true" >> $GITHUB_OUTPUT else echo "skip=false" >> $GITHUB_OUTPUT