From e88a3896115889eb99ada7bb07c1358ae3d53bac Mon Sep 17 00:00:00 2001 From: Jon Langevin Date: Wed, 13 May 2026 22:55:59 -0400 Subject: [PATCH] ci: add sync-plugin-version workflow (auto-bump plugin.json on tag) --- .github/workflows/sync-plugin-version.yml | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/sync-plugin-version.yml diff --git a/.github/workflows/sync-plugin-version.yml b/.github/workflows/sync-plugin-version.yml new file mode 100644 index 0000000..f74f8a9 --- /dev/null +++ b/.github/workflows/sync-plugin-version.yml @@ -0,0 +1,59 @@ +name: Sync plugin.json version +on: + push: + tags: ['v*'] +permissions: + contents: write + pull-requests: write +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + - name: Compute target version from tag + id: ver + run: | + TAG="${GITHUB_REF_NAME}" + VERSION="${TAG#v}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "tag=$TAG" >> $GITHUB_OUTPUT + - name: Update plugin.json + run: | + if [ ! -f plugin.json ]; then echo "no plugin.json; skipping"; exit 0; fi + CURRENT=$(python3 -c "import json; print(json.load(open('plugin.json')).get('version',''))") + TARGET="${{ steps.ver.outputs.version }}" + if [ "$CURRENT" = "$TARGET" ]; then + echo "plugin.json already at $TARGET; no action" + exit 0 + fi + python3 -c " + import json + p = json.load(open('plugin.json')) + p['version'] = '$TARGET' + json.dump(p, open('plugin.json', 'w'), indent=2) + open('plugin.json', 'a').write('\n') + " + - name: Open sync PR if plugin.json changed + run: | + if git diff --quiet plugin.json; then + echo "no changes" + exit 0 + fi + BRANCH="chore/sync-plugin-version-${{ steps.ver.outputs.tag }}" + git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + git checkout -b "$BRANCH" + git add plugin.json + git commit -m "chore: sync plugin.json version to ${{ steps.ver.outputs.tag }}" + git push origin "$BRANCH" + gh pr create \ + --base main \ + --head "$BRANCH" \ + --title "chore: sync plugin.json version to ${{ steps.ver.outputs.tag }}" \ + --body "Triggered by release ${{ steps.ver.outputs.tag }}. Auto-sync to prevent drift. Closes workflow-registry#37." + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}