Skip to content

chore: migrate to reusable PyPI publish workflow#11

Merged
liuxiaotong merged 1 commit into
mainfrom
chore/unified-publish
Mar 13, 2026
Merged

chore: migrate to reusable PyPI publish workflow#11
liuxiaotong merged 1 commit into
mainfrom
chore/unified-publish

Conversation

@liuxiaotong

Copy link
Copy Markdown
Owner

Summary

  • Replaces inline publish workflow with caller to knowlyr-workflows/reusable-publish-pypi.yml
  • Uses setuptools build + trusted publisher, with tests enabled
  • Part of TD-2026-004 Phase 1

Test plan

  • Next v* tag push triggers the reusable workflow correctly

@liuxiaotong liuxiaotong merged commit 51cdcd1 into main Mar 13, 2026
4 of 5 checks passed
@liuxiaotong liuxiaotong deleted the chore/unified-publish branch March 13, 2026 20:51
@github-actions

Copy link
Copy Markdown

Auto Review (Round 1) — Changes Requested

主要问题:permissions 块在调用 reusable workflow 的 job 中无效,id-token: write 可能无法传递,导致 OIDC trusted publisher 发布失败。另有可复用工作流锁定到 @main 可变 ref 的供应链安全风险,以及 lint 步骤丢失和测试范围收窄的问题,需确认后再合并。

  • .github/workflows/publish.yml L13: permissions 块在调用 reusable workflow 的 job 中不会生效。根据 GitHub Actions 文档,当 job 使用 uses: 调用可复用工作流时,job 级别的 permissions 不会被传递给被调用方。id-token: write 是 OIDC trusted publisher 的必要权限,若 reusable workflow 内部未自行声明该权限,发布步骤将因无法获取 OIDC token 而失败。

修复方案:将 permissions 移至 workflow 顶层(on: 之后、jobs: 之前):

permissions:
  id-token: write
  contents: read

jobs:
  publish:
    uses: liuxiaotong/knowlyr-workflows/...

或者确认 reusable workflow 内部已自行声明 id-token: write,则此处 permissions 可删除。

  • .github/workflows/publish.yml L8: 可复用工作流引用锁定到 @main 可变分支,存在供应链安全风险:knowlyr-workflows 仓库的任何推送都可能静默改变此工作流的行为,包括潜在的恶意变更。建议锁定到具体 tag(如 @v1.2.0)或 commit SHA(如 @abc1234),并在升级时显式 review 变更。
  • .github/workflows/publish.yml L11: 测试命令从 pytest(全量)改为 pytest tests/(限定目录)。若项目在 tests/ 之外存在测试文件(如根目录的 test_*.py 或其他子目录),这些测试将被跳过,发布前质量门降低。请确认 tests/ 目录覆盖了所有测试,或改回 pytest 全量执行。
  • .github/workflows/publish.yml: 原工作流包含独立的 ruff check . lint 步骤,迁移后该步骤被移除。若 reusable-publish-pypi.yml 内部不执行 lint,发布流程将失去这道质量门。请确认可复用工作流是否包含 lint,若不包含,建议在 caller workflow 中添加独立的 lint job,或向 reusable workflow 添加 lint 支持。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant