Skip to content

Publish PyPI

Publish PyPI #41

Workflow file for this run

name: Publish PyPI
on:
release:
types:
- published
workflow_dispatch:
inputs:
ksadk_web_version:
description: KsADK Web npm version to bundle
required: false
default: "0.3.4"
approved_source_commit:
description: Reviewed source commit SHA recorded in docs/maintainer-approval-record.md
required: false
publish_target:
description: Publish target
required: false
default: full
type: choice
options:
- full
- alias-only
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: publish-pypi-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
environment:
name: pypi
env:
KSADK_WEB_VERSION: ${{ github.event.inputs.ksadk_web_version || '0.3.4' }}
KSADK_APPROVED_SOURCE_COMMIT: ${{ github.event.inputs.approved_source_commit || vars.KSADK_APPROVED_SOURCE_COMMIT }}
PUBLISH_TARGET: ${{ github.event.inputs.publish_target || 'full' }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Sync KsADK Web static assets
run: make sync-ksadk-web-static
- name: Run public release preflight
if: env.PUBLISH_TARGET == 'full'
# Mirror the 0.8.2 publish preflight shape: version + audit + ksadk-web
# sync + test + build/twine check. docs-site-build runs in the
# deploy-pages job; the heavy Phase 2 native/browser E2E gates are
# already enforced by the pull-request release-check workflow, so
# re-running them here only doubles work and stalls on the shared CI
# runner.
run: make public-preflight-publish
- name: Run alias-only release checks
if: env.PUBLISH_TARGET == 'alias-only'
run: make public-audit public-test public-build-alias-check
- name: Verify release approval gate
run: make public-publish-gate
- name: Publish to PyPI
if: env.PUBLISH_TARGET == 'full'
uses: pypa/gh-action-pypi-publish@release/v1
- name: Build alias distribution
if: env.PUBLISH_TARGET == 'full'
run: make public-build-alias-check
- name: Publish alias package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist-alias
# 发版时同步部署 Fumadocs 文档站到 GitHub Pages, 文档与 PyPI 版本一致。
# 用 if: always() 让文档部署不被 publish 阻塞(workflow_dispatch 重新部署文档时,
# publish 会因版本门禁失败(版本未变),但 deploy-pages 仍应运行)。
deploy-pages:
needs: publish
if: always() && (github.event_name != 'workflow_dispatch' || github.event.inputs.publish_target != 'alias-only')
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
defaults:
run:
working-directory: docs-site
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Enable pnpm
run: |
corepack enable
corepack prepare pnpm@10.33.2 --activate
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build static site (Fumadocs)
run: pnpm build:static
env:
# GitHub Pages project site serves from /<repo>, 需设 base path
NEXT_PUBLIC_BASE_PATH: /${{ github.event.repository.name }}
NEXT_STATIC_EXPORT: "1"
- name: Upload artifact for GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: docs-site/out
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4