Skip to content

Commit 5b30579

Browse files
committed
Document release flow and add manual PyPI workflow
1 parent 916efb5 commit 5b30579

5 files changed

Lines changed: 83 additions & 149 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
expected_version:
7+
description: "Package version expected from the selected ref, for example 0.1.6"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
environment: pypi
15+
permissions:
16+
id-token: write
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v6
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: "3.12"
26+
27+
- name: Upgrade pip
28+
run: python -m pip install --upgrade pip
29+
30+
- name: Install release dependencies
31+
run: python -m pip install -e .[release]
32+
33+
- name: Validate version
34+
shell: bash
35+
run: |
36+
python - <<'PY'
37+
import pathlib
38+
import tomllib
39+
import sys
40+
41+
root = pathlib.Path(".")
42+
sys.path.insert(0, str(root / "src"))
43+
from code2skill import __version__
44+
45+
expected = "${{ inputs.expected_version }}"
46+
pyproject = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
47+
declared = pyproject["project"]["version"]
48+
if declared != expected:
49+
raise SystemExit(f"Expected version {expected}, but pyproject version is {declared}.")
50+
if __version__ != expected:
51+
raise SystemExit(f"Expected version {expected}, but runtime version is {__version__}.")
52+
PY
53+
54+
- name: Build package
55+
run: python -m build
56+
57+
- name: Check package metadata
58+
run: python -m twine check dist/*
59+
60+
- name: Publish to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1

README.md

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -456,90 +456,19 @@ Common reasons to fall back to a full rebuild:
456456
- cached state was generated for a different repository root
457457

458458
Recommended GitHub Actions workflow:
459-
460-
```yaml
461-
name: code2skill
462-
463-
on:
464-
pull_request:
465-
push:
466-
branches:
467-
- main
468-
469-
jobs:
470-
build-skills:
471-
runs-on: ubuntu-latest
472-
473-
steps:
474-
- name: Checkout
475-
uses: actions/checkout@v4
476-
with:
477-
fetch-depth: 0
478-
479-
- name: Setup Python
480-
uses: actions/setup-python@v5
481-
with:
482-
python-version: "3.11"
483-
484-
- name: Restore code2skill cache
485-
uses: actions/cache@v4
486-
with:
487-
path: .code2skill
488-
key: code2skill-${{ runner.os }}-${{ github.ref_name }}-${{ github.sha }}
489-
restore-keys: |
490-
code2skill-${{ runner.os }}-${{ github.ref_name }}-
491-
code2skill-${{ runner.os }}-
492-
493-
- name: Install
494-
run: pip install code2skill
495-
496-
- name: Run code2skill
497-
env:
498-
QWEN_API_KEY: ${{ secrets.QWEN_API_KEY }}
499-
CODE2SKILL_LLM: qwen
500-
CODE2SKILL_MODEL: qwen-plus-latest
501-
run: |
502-
code2skill ci \
503-
--mode auto \
504-
--base-ref origin/${{ github.base_ref || 'main' }} \
505-
--head-ref HEAD
506-
507-
- name: Upload artifacts
508-
uses: actions/upload-artifact@v4
509-
with:
510-
name: code2skill-output
511-
path: .code2skill
512-
```
459+
See [CI Guide](./docs/ci.md) for a consumer workflow example and the checked-in repository workflows.
513460

514461
Notes:
515462

516463
- `fetch-depth: 0` matters, otherwise the base ref may not exist locally.
517464
- Caching `.code2skill` is what enables fast incremental reuse.
518465
- The first CI run on a branch usually behaves like a full build because there is no prior state.
519466
- If you want a no-LLM CI sanity check, use `code2skill ci --mode auto --structure-only`.
520-
- This repository now includes checked-in workflows under `.github/workflows/` for CI and tagged releases.
467+
- This repository now includes checked-in workflows under `.github/workflows/` for CI, GitHub Releases, and manual PyPI publication.
521468

522469
## Output Layout
523470

524-
Typical output:
525-
526-
```text
527-
.code2skill/
528-
project-summary.md
529-
skill-blueprint.json
530-
skill-plan.json
531-
report.json
532-
references/
533-
architecture.md
534-
code-style.md
535-
workflows.md
536-
api-usage.md
537-
skills/
538-
index.md
539-
*.md
540-
state/
541-
analysis-state.json
542-
```
471+
See [Output Layout](./docs/output-layout.md) for the command-by-command artifact matrix and adapted target files.
543472

544473
## Typical Use Cases
545474

README.zh-CN.md

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -455,90 +455,19 @@ code2skill estimate --pricing-file pricing.json
455455
- 缓存 state 记录的 `repo_root` 与当前仓库根目录不一致
456456

457457
推荐的 GitHub Actions 配置:
458-
459-
```yaml
460-
name: code2skill
461-
462-
on:
463-
pull_request:
464-
push:
465-
branches:
466-
- main
467-
468-
jobs:
469-
build-skills:
470-
runs-on: ubuntu-latest
471-
472-
steps:
473-
- name: Checkout
474-
uses: actions/checkout@v4
475-
with:
476-
fetch-depth: 0
477-
478-
- name: Setup Python
479-
uses: actions/setup-python@v5
480-
with:
481-
python-version: "3.11"
482-
483-
- name: Restore code2skill cache
484-
uses: actions/cache@v4
485-
with:
486-
path: .code2skill
487-
key: code2skill-${{ runner.os }}-${{ github.ref_name }}-${{ github.sha }}
488-
restore-keys: |
489-
code2skill-${{ runner.os }}-${{ github.ref_name }}-
490-
code2skill-${{ runner.os }}-
491-
492-
- name: Install
493-
run: pip install code2skill
494-
495-
- name: Run code2skill
496-
env:
497-
QWEN_API_KEY: ${{ secrets.QWEN_API_KEY }}
498-
CODE2SKILL_LLM: qwen
499-
CODE2SKILL_MODEL: qwen-plus-latest
500-
run: |
501-
code2skill ci \
502-
--mode auto \
503-
--base-ref origin/${{ github.base_ref || 'main' }} \
504-
--head-ref HEAD
505-
506-
- name: Upload artifacts
507-
uses: actions/upload-artifact@v4
508-
with:
509-
name: code2skill-output
510-
path: .code2skill
511-
```
458+
完整示例见 [CI Guide](./docs/ci.md)。该文档同时说明了仓库内已提供的 workflow。
512459

513460
说明:
514461

515462
- `fetch-depth: 0` 很重要,否则 base ref 可能不在本地历史里
516463
- 缓存 `.code2skill` 是增量提速的关键
517464
- 一个分支上的第一次 CI 通常接近 `full`,因为还没有历史 state
518465
- 如果只想做不调用 LLM 的 CI 健康检查,可以运行 `code2skill ci --mode auto --structure-only`
519-
- 当前仓库已经提供 `.github/workflows/` 下的 CI 和 release workflow
466+
- 当前仓库已经提供 `.github/workflows/` 下的 CI、GitHub Release 和手动 PyPI 发布 workflow
520467

521468
## 输出目录
522469

523-
典型输出如下:
524-
525-
```text
526-
.code2skill/
527-
project-summary.md
528-
skill-blueprint.json
529-
skill-plan.json
530-
report.json
531-
references/
532-
architecture.md
533-
code-style.md
534-
workflows.md
535-
api-usage.md
536-
skills/
537-
index.md
538-
*.md
539-
state/
540-
analysis-state.json
541-
```
470+
按命令区分的产物矩阵和适配后文件位置见 [Output Layout](./docs/output-layout.md)
542471

543472
## 典型场景
544473

docs/ci.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This repository includes checked-in workflows under `.github/workflows/`:
1818

1919
- `ci.yml`: test matrix, build, metadata check, and install smoke test
2020
- `release.yml`: version validation, build, metadata check, and GitHub Release creation on version tags
21+
- `publish-pypi.yml`: manual PyPI publication workflow
2122

2223
The README includes a sample consumer workflow for running `code2skill` inside another repository.
2324

docs/release.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,23 @@ This repository includes:
5353

5454
- `.github/workflows/ci.yml`: unit tests plus package build and install smoke check
5555
- `.github/workflows/release.yml`: version validation, build, `twine check`, and GitHub Release creation on version tags
56+
- `.github/workflows/publish-pypi.yml`: manual PyPI publishing from a selected ref
5657

5758
The checked-in release workflow is intentionally repository-focused. It does not publish to PyPI automatically.
58-
If you want package publishing later, treat that as a separate manual or dedicated workflow concern.
59+
PyPI publishing is handled separately through the manual `publish-pypi.yml` workflow.
60+
61+
## Manual PyPI Publish
62+
63+
Use `.github/workflows/publish-pypi.yml` only when you explicitly want to publish a built version to PyPI.
64+
65+
Recommended flow:
66+
67+
1. prepare and push the final release commit
68+
2. make sure the version in `pyproject.toml` and `src/code2skill/__init__.py` is final
69+
3. run the `Release` workflow via a version tag so GitHub Release creation succeeds
70+
4. manually run `Publish PyPI` from the same ref and provide the exact version string
71+
72+
This keeps repository release automation and package publication separate.
5973

6074
## Manual Release Safety Notes
6175

0 commit comments

Comments
 (0)