From 7c08a7c378cce713c7edcf8f536ec2f0b28691af Mon Sep 17 00:00:00 2001 From: Vladimir Severov Date: Wed, 4 Nov 2026 00:03:26 +0300 Subject: [PATCH 1/4] Add CI: build and test skills, publish dist branch Builds skills from modes/, runs script tests, and on push to master force-publishes the built plugin to the dist branch. --- .github/workflows/ci.yml | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..23eb0b6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,91 @@ +# skills/** в основной ветке не хранится - он собирается из modes/** и публикуется в ветку `dist`, +# откуда плагин ставится по URL одной командой. Основная ветка остаётся источником, `dist` - сборкой. +# +# Публикация пишет в репозиторий, и токен для неё GitHub Actions выдаёт сам: `GITHUB_TOKEN` +# с `permissions: contents: write` пушит в ветки того же репозитория, отдельный PAT не нужен. +# Единственное ограничение - пуш от `GITHUB_TOKEN` не запускает новых workflow, поэтому по `dist` +# пайплайн не побежит; проверок у ветки нет и не надо. Коммитера подписывают переменные +# `SKILLS_PUBLISH_NAME` и `SKILLS_PUBLISH_EMAIL` (Settings → Secrets and variables → Actions → +# Variables), без них коммитит `github-actions[bot]`. Подробности - CONTRIBUTING.md, «Ветка `dist`». + +name: ci + +on: + push: + branches: [master] + pull_request: + workflow_dispatch: + inputs: + publish: + description: 'Publish the dist branch' + type: boolean + default: false + dist_branch: + description: 'Branch to publish to' + type: string + default: dist + +permissions: + contents: read + +jobs: + # Сборка ломается молча: `dist` уедет без скилов, а установка притащит пустой плагин. + # Поэтому собираем в каждом PR и на каждом пуше в основную ветку, а не только перед публикацией. + check-skills: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: ./scripts/build-skills.py + - run: test -f skills/build/SKILL.md + - run: test -f skills/build/common.md + - run: python -m py_compile scripts/*.py scripts/mr_watch/*.py + - run: bash -n scripts/mr-reply.sh + + # Скрипт не только описывает правила треда, но и отказывает по ним. Отказ - это поведение, + # и проверяется он на подменённом `glab`, без похода в GitLab. `jq` и `gawk` уже стоят + # на образе `ubuntu-latest`. + test-scripts: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: pip install --quiet pytest pyyaml + - run: python -m pytest tests -q + + publish-skills: + needs: [check-skills, test-scripts] + # Пуш в основную ветку публикует боевую `dist`; ручной запуск с галкой `publish` - + # способ проверить публикацию до мержа, а `dist_branch` уводит прогон на другую ветку. + if: github.event_name == 'push' || inputs.publish + permissions: + contents: write + runs-on: ubuntu-latest + env: + DIST_BRANCH: ${{ inputs.dist_branch || 'dist' }} + steps: + - uses: actions/checkout@v4 + with: + # Патч версии - число коммитов, shallow-клон его обрезает. + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: ./scripts/build-skills.py --stamp-version + - run: | + git config user.name "${SKILLS_PUBLISH_NAME:-github-actions[bot]}" + git config user.email "${SKILLS_PUBLISH_EMAIL:-41898282+github-actions[bot]@users.noreply.github.com}" + # Ветка сборки - не история: она каждый раз переписывается поверх текущей основной ветки. + git checkout -B "$DIST_BRANCH" + # skills/ лежит в .gitignore - в сборке он нужен, поэтому добавляем принудительно. + git add -f skills .claude-plugin/plugin.json .codex-plugin/plugin.json + git commit --no-gpg-sign -m "Build skills from ${GITHUB_SHA::7}" + git push --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$DIST_BRANCH" + env: + SKILLS_PUBLISH_NAME: ${{ vars.SKILLS_PUBLISH_NAME }} + SKILLS_PUBLISH_EMAIL: ${{ vars.SKILLS_PUBLISH_EMAIL }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 18542aff76861497cc5e8acbcc2b453a966f2470 Mon Sep 17 00:00:00 2001 From: Vladimir Severov Date: Wed, 4 Nov 2026 00:22:29 +0300 Subject: [PATCH 2/4] Harden CI: refuse publishing over master, Node 24 actions A manual run with dist_branch=master would force-push a build over the source branch. Move to the Node 24 majors of checkout and setup-python and keep the workflow comments to one English line each. --- .github/workflows/ci.yml | 40 +++++++++++++++------------------------- CONTRIBUTING.md | 3 ++- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23eb0b6..4894393 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,4 @@ -# skills/** в основной ветке не хранится - он собирается из modes/** и публикуется в ветку `dist`, -# откуда плагин ставится по URL одной командой. Основная ветка остаётся источником, `dist` - сборкой. -# -# Публикация пишет в репозиторий, и токен для неё GitHub Actions выдаёт сам: `GITHUB_TOKEN` -# с `permissions: contents: write` пушит в ветки того же репозитория, отдельный PAT не нужен. -# Единственное ограничение - пуш от `GITHUB_TOKEN` не запускает новых workflow, поэтому по `dist` -# пайплайн не побежит; проверок у ветки нет и не надо. Коммитера подписывают переменные -# `SKILLS_PUBLISH_NAME` и `SKILLS_PUBLISH_EMAIL` (Settings → Secrets and variables → Actions → -# Variables), без них коммитит `github-actions[bot]`. Подробности - CONTRIBUTING.md, «Ветка `dist`». +# skills/** is built from modes/** and published to `dist`, the branch the plugin installs from (CONTRIBUTING.md, «Ветка `dist`»). name: ci @@ -29,13 +21,12 @@ permissions: contents: read jobs: - # Сборка ломается молча: `dist` уедет без скилов, а установка притащит пустой плагин. - # Поэтому собираем в каждом PR и на каждом пуше в основную ветку, а не только перед публикацией. + # A broken build fails silently as an empty plugin, so it is checked on every PR, not only before publishing. check-skills: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 with: python-version: '3.12' - run: ./scripts/build-skills.py @@ -44,14 +35,12 @@ jobs: - run: python -m py_compile scripts/*.py scripts/mr_watch/*.py - run: bash -n scripts/mr-reply.sh - # Скрипт не только описывает правила треда, но и отказывает по ним. Отказ - это поведение, - # и проверяется он на подменённом `glab`, без похода в GitLab. `jq` и `gawk` уже стоят - # на образе `ubuntu-latest`. + # The tests fake `glab`; `jq` and `gawk` come with the runner image. test-scripts: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 with: python-version: '3.12' - run: pip install --quiet pytest pyyaml @@ -59,8 +48,7 @@ jobs: publish-skills: needs: [check-skills, test-scripts] - # Пуш в основную ветку публикует боевую `dist`; ручной запуск с галкой `publish` - - # способ проверить публикацию до мержа, а `dist_branch` уводит прогон на другую ветку. + # A manual run with `publish` checks publishing before merge; `dist_branch` keeps it off the live `dist`. if: github.event_name == 'push' || inputs.publish permissions: contents: write @@ -68,20 +56,21 @@ jobs: env: DIST_BRANCH: ${{ inputs.dist_branch || 'dist' }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: - # Патч версии - число коммитов, shallow-клон его обрезает. + # The version patch is the commit count, which a shallow clone truncates. fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v7 with: python-version: '3.12' - run: ./scripts/build-skills.py --stamp-version - run: | git config user.name "${SKILLS_PUBLISH_NAME:-github-actions[bot]}" git config user.email "${SKILLS_PUBLISH_EMAIL:-41898282+github-actions[bot]@users.noreply.github.com}" - # Ветка сборки - не история: она каждый раз переписывается поверх текущей основной ветки. + # A force-push to the source branch would replace it with a build. + [ "$DIST_BRANCH" != "$DEFAULT_BRANCH" ] || { echo "::error::dist_branch must not be $DEFAULT_BRANCH"; exit 1; } git checkout -B "$DIST_BRANCH" - # skills/ лежит в .gitignore - в сборке он нужен, поэтому добавляем принудительно. + # skills/ is gitignored in the source branch. git add -f skills .claude-plugin/plugin.json .codex-plugin/plugin.json git commit --no-gpg-sign -m "Build skills from ${GITHUB_SHA::7}" git push --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$DIST_BRANCH" @@ -89,3 +78,4 @@ jobs: SKILLS_PUBLISH_NAME: ${{ vars.SKILLS_PUBLISH_NAME }} SKILLS_PUBLISH_EMAIL: ${{ vars.SKILLS_PUBLISH_EMAIL }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b594e09..ae726f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,7 +67,8 @@ python -m pytest tests -q (`fetch-depth: 0`). Проверить публикацию до мержа: ручной запуск workflow с галкой `publish`, а вход `dist_branch` -уводит прогон на другую ветку, чтобы не трогать боевую. +уводит прогон на другую ветку, чтобы не трогать боевую. Основную ветку как `dist_branch` джоба не +примет: форспуш заменил бы её сборкой. ``` gh workflow run ci.yml --ref <ветка> -f publish=true -f dist_branch=dist-test From 45f01faafe4cb9d8a019ea650bf8d7ec6dc1932a Mon Sep 17 00:00:00 2001 From: Vladimir Severov Date: Wed, 4 Nov 2026 00:26:51 +0300 Subject: [PATCH 3/4] Keep branch builds off the live dist, queue publishes A manual run from a branch defaulted to dist and took the version number of the next merge; it now defaults to dist-test and dist is published only from master. Publishes to one branch are queued so the newest lands last. --- .github/workflows/ci.yml | 8 +++++++- CONTRIBUTING.md | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4894393..0ec131f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ on: dist_branch: description: 'Branch to publish to' type: string - default: dist + default: dist-test permissions: contents: read @@ -50,6 +50,10 @@ jobs: needs: [check-skills, test-scripts] # A manual run with `publish` checks publishing before merge; `dist_branch` keeps it off the live `dist`. if: github.event_name == 'push' || inputs.publish + # Queued, not cancelled: the newest build lands last and its version is the highest. + concurrency: + group: publish-${{ inputs.dist_branch || 'dist' }} + cancel-in-progress: false permissions: contents: write runs-on: ubuntu-latest @@ -69,6 +73,8 @@ jobs: git config user.email "${SKILLS_PUBLISH_EMAIL:-41898282+github-actions[bot]@users.noreply.github.com}" # A force-push to the source branch would replace it with a build. [ "$DIST_BRANCH" != "$DEFAULT_BRANCH" ] || { echo "::error::dist_branch must not be $DEFAULT_BRANCH"; exit 1; } + # A branch build would take the live version number from the next merge. + [ "$DIST_BRANCH" != dist ] || [ "$GITHUB_REF_NAME" = "$DEFAULT_BRANCH" ] || { echo "::error::dist is published only from $DEFAULT_BRANCH"; exit 1; } git checkout -B "$DIST_BRANCH" # skills/ is gitignored in the source branch. git add -f skills .claude-plugin/plugin.json .codex-plugin/plugin.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ae726f8..b08d8b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,12 +66,14 @@ python -m pytest tests -q там обрезан, и версия поехала бы назад, поэтому джоба публикации клонирует историю целиком (`fetch-depth: 0`). -Проверить публикацию до мержа: ручной запуск workflow с галкой `publish`, а вход `dist_branch` -уводит прогон на другую ветку, чтобы не трогать боевую. Основную ветку как `dist_branch` джоба не -примет: форспуш заменил бы её сборкой. +Проверить публикацию до мержа: ручной запуск workflow с галкой `publish`. Вход `dist_branch` (по +умолчанию `dist-test`) уводит прогон на другую ветку, чтобы не трогать боевую. Основную ветку как +`dist_branch` джоба не примет: форспуш заменил бы её сборкой. В `dist` она публикует только из основной +ветки: сборка другой ветки заняла бы номер версии следующего мержа. Публикации в одну ветку идут по +очереди, поэтому последней ложится самая новая сборка. ``` -gh workflow run ci.yml --ref <ветка> -f publish=true -f dist_branch=dist-test +gh workflow run ci.yml --ref <ветка> -f publish=true ``` ### Токен публикации From 2ccff23eae82f85d3eca57fc33d1a8301f011d61 Mon Sep 17 00:00:00 2001 From: Vladimir Severov Date: Wed, 4 Nov 2026 00:29:33 +0300 Subject: [PATCH 4/4] Trim dist publishing notes in CONTRIBUTING to instructions The reasons behind the publish guards belong to the commit history, not to the contributor guide. --- CONTRIBUTING.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b08d8b8..b2a9366 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,11 +66,8 @@ python -m pytest tests -q там обрезан, и версия поехала бы назад, поэтому джоба публикации клонирует историю целиком (`fetch-depth: 0`). -Проверить публикацию до мержа: ручной запуск workflow с галкой `publish`. Вход `dist_branch` (по -умолчанию `dist-test`) уводит прогон на другую ветку, чтобы не трогать боевую. Основную ветку как -`dist_branch` джоба не примет: форспуш заменил бы её сборкой. В `dist` она публикует только из основной -ветки: сборка другой ветки заняла бы номер версии следующего мержа. Публикации в одну ветку идут по -очереди, поэтому последней ложится самая новая сборка. +Проверить публикацию до мержа: ручной запуск workflow с галкой `publish`, сборка уходит в ветку из входа +`dist_branch` (по умолчанию `dist-test`). В `dist` публикуется только запуск с основной ветки. ``` gh workflow run ci.yml --ref <ветка> -f publish=true