Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# skills/** is built from modes/** and published to `dist`, the branch the plugin installs from (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-test

permissions:
contents: read

jobs:
# 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@v7
- uses: actions/setup-python@v7
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

# The tests fake `glab`; `jq` and `gawk` come with the runner image.
test-scripts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- run: pip install --quiet pytest pyyaml
- run: python -m pytest tests -q

publish-skills:
Comment thread
hackallcode marked this conversation as resolved.
Resolved
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
env:
DIST_BRANCH: ${{ inputs.dist_branch || 'dist' }}
steps:
- uses: actions/checkout@v7
with:
# The version patch is the commit count, which a shallow clone truncates.
fetch-depth: 0
- 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; }
# 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
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 }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ python -m pytest tests -q
там обрезан, и версия поехала бы назад, поэтому джоба публикации клонирует историю целиком
(`fetch-depth: 0`).

Проверить публикацию до мержа: ручной запуск workflow с галкой `publish`, а вход `dist_branch`
уводит прогон на другую ветку, чтобы не трогать боевую.
Проверить публикацию до мержа: ручной запуск workflow с галкой `publish`, сборка уходит в ветку из входа
`dist_branch` (по умолчанию `dist-test`). В `dist` публикуется только запуск с основной ветки.

```
gh workflow run ci.yml --ref <ветка> -f publish=true -f dist_branch=dist-test
gh workflow run ci.yml --ref <ветка> -f publish=true
```

### Токен публикации
Expand Down
Loading