Skip to content

准备 0.1.7 发布说明 #6

准备 0.1.7 发布说明

准备 0.1.7 发布说明 #6

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install release dependencies
run: python -m pip install -e .[release]
- name: Build package
run: python -m build
- name: Check package metadata
run: python -m twine check dist/*
- name: Validate version and release note
shell: bash
run: |
python - <<'PY'
import pathlib
import tomllib
import sys
root = pathlib.Path(".")
sys.path.insert(0, str(root / "src"))
from code2skill import __version__
tag = "${{ github.ref_name }}"
version = tag.removeprefix("v")
pyproject = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
dynamic = pyproject["project"].get("dynamic", [])
version_attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
if dynamic != ["version"]:
raise SystemExit(f"Expected dynamic version metadata, got {dynamic!r}.")
if version_attr != "code2skill.version.__version__":
raise SystemExit(f"Unexpected dynamic version source: {version_attr}.")
if __version__ != version:
raise SystemExit(f"Tag {tag} does not match runtime version {__version__}.")
release_note = root / "docs" / "releases" / f"v{version}.md"
if not release_note.exists():
raise SystemExit(f"Missing release note file: {release_note}")
PY
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: docs/releases/${{ github.ref_name }}.md