From 2e9d484de102aa98f3f5d62670a46001e2ee000c Mon Sep 17 00:00:00 2001 From: chaoqun Date: Sun, 28 Jun 2026 21:05:31 +0800 Subject: [PATCH 1/4] ci: add release asset workflow Change-Id: I08e117abb79ac77603898bccfdaa52dc00739edb --- .github/workflows/release.yml | 163 ++++++++++++++++++++++++++++++++++ AGENTS.md | 12 +++ README.MD | 4 + docs/release.md | 103 +++++++++++++++++++++ 4 files changed, 282 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 docs/release.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2dae482 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,163 @@ +name: Release + +on: + pull_request: + paths: + - '.github/workflows/release.yml' + - 'docs/release.md' + - 'README.MD' + - 'AGENTS.md' + - 'go.mod' + - 'go.sum' + - '**/*.go' + - 'video_subtitle/**' + - 'emby_plugins/video_subtitle/**' + - 'sample/life_tools/**' + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Build release assets + runs-on: ubuntu-latest + env: + GO_VERSION: '1.18.x' + DOTNET_VERSION: '8.0.x' + PYTHONDONTWRITEBYTECODE: '1' + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Run Go tests + run: go test ./... + + - name: Run video_subtitle tests + run: | + python3 -m unittest video_subtitle/video_subtitle_test.py + python3 -m py_compile \ + video_subtitle/video_subtitle.py \ + video_subtitle/video_subtitle_test.py \ + video_subtitle/lib/*.py + + - name: Run Emby plugin tests + run: dotnet test emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release + + - name: Build release assets + shell: bash + run: | + set -euo pipefail + + tag="${GITHUB_REF_NAME}" + if [ "${GITHUB_REF_TYPE:-}" != "tag" ]; then + tag="v0.0.0-ci" + fi + root="$PWD" + dist="$root/dist" + tmp="$root/.release-tmp" + platforms=(linux/amd64 linux/arm64 darwin/amd64 darwin/arm64) + + rm -rf "$dist" "$tmp" + mkdir -p "$dist" "$tmp" + + for platform in "${platforms[@]}"; do + os="${platform%/*}" + arch="${platform#*/}" + pkg="life_tools_${os}_${arch}_${tag}" + out="$tmp/$pkg" + mkdir -p "$out/bin" "$out/sample/life_tools" "$out/docs" + + GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags "-s -w" -o "$out/bin/renameV1" ./renameV1/... + GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags "-s -w" -o "$out/bin/check_keywords" ./save_work/... + GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags "-s -w" -o "$out/bin/retry_exec" ./retry_exec/... + GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags "-s -w" -o "$out/bin/codex_hook_notify" ./codex_hook_notify/... + GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags "-s -w" -o "$out/bin/file_share" ./file_share/... + + cp README.MD install.sh "$out/" + cp sample/life_tools/*.json "$out/sample/life_tools/" + cp docs/install.md docs/codex_hook_notify.md docs/file_share.md "$out/docs/" + cp docs/release.md "$out/docs/" + + ( + cd "$tmp" + zip -qr "$dist/$pkg.zip" "$pkg" + ) + done + + video_pkg="life_tools_video_subtitle_source_${tag}" + video_out="$tmp/$video_pkg" + mkdir -p "$video_out/video_subtitle" "$video_out/sample/life_tools" "$video_out/docs" + cp -R video_subtitle/*.py video_subtitle/lib video_subtitle/prompts video_subtitle/requirements.txt "$video_out/video_subtitle/" + cp sample/life_tools/video_subtitle.json "$video_out/sample/life_tools/" + cp README.MD install.sh "$video_out/" + cp docs/video_subtitle.md docs/release.md "$video_out/docs/" + ( + cd "$tmp" + zip -qr "$dist/$video_pkg.zip" "$video_pkg" + ) + + dotnet build emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release + plugin_pkg="life_tools_emby_video_subtitle_plugin_${tag}" + plugin_out="$tmp/$plugin_pkg" + mkdir -p "$plugin_out" "$plugin_out/docs" "$plugin_out/emby_plugins/video_subtitle" + cp emby_plugins/video_subtitle/src/LifeTools.Emby.VideoSubtitle.Emby/bin/Release/netstandard2.0/LifeTools.Emby.VideoSubtitle.Emby.dll "$plugin_out/" + cp emby_plugins/video_subtitle/install.sh emby_plugins/video_subtitle/build.sh "$plugin_out/emby_plugins/video_subtitle/" + cp docs/emby_video_subtitle_plugin.md docs/video_subtitle.md docs/release.md "$plugin_out/docs/" + { + echo '# Life Tools Emby Video Subtitle Plugin' + echo + echo 'Copy only `LifeTools.Emby.VideoSubtitle.Emby.dll` into the Emby plugins directory, then restart Emby.' + echo + echo 'Default local install:' + echo + echo '```bash' + echo 'sudo install -m 0644 LifeTools.Emby.VideoSubtitle.Emby.dll /var/lib/emby/plugins/LifeTools.Emby.VideoSubtitle.Emby.dll' + echo 'sudo systemctl restart emby-server' + echo '```' + echo + echo 'The plugin calls `/usr/local/bin/video_subtitle` by default. Install and configure `video_subtitle` before submitting jobs.' + } > "$plugin_out/README.md" + ( + cd "$tmp" + zip -qr "$dist/$plugin_pkg.zip" "$plugin_pkg" + ) + + ( + cd "$dist" + sha256sum *.zip > checksums.txt + ) + + ls -lh "$dist" + + - name: Create GitHub release + if: github.ref_type == 'tag' + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + tag="${GITHUB_REF_NAME}" + title="life_tools ${tag}" + if gh release view "$tag" >/dev/null 2>&1; then + gh release upload "$tag" dist/*.zip dist/checksums.txt --clobber + else + gh release create "$tag" dist/*.zip dist/checksums.txt --title "$title" --generate-notes + fi diff --git a/AGENTS.md b/AGENTS.md index 82320d2..2efa3ed 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -139,6 +139,18 @@ emby_plugins/video_subtitle/install.sh --help - 只改和任务直接相关的文件。 - 不使用 `git reset --hard`、`git checkout --`、批量删除或其他破坏性命令,除非用户明确要求。 + +## Release Workflow 规则 + +`.github/workflows/release.yml` 负责 tag 发布,不是普通 CI。修改发布流程时要同时关注 Go、Python `video_subtitle` 和 Emby 插件三类产物。 + +- tag 触发规则保持 `v*`,避免普通分支 push 意外创建 Release;`pull_request` 只能做 dry-run,不能创建 Release。 +- Go 二进制包只放稳定 CLI 工具:`renameV1`、`check_keywords`、`retry_exec`、`codex_hook_notify`、`file_share`。 +- `video_subtitle` 只能按源码包发布,不能宣传成免依赖二进制;它仍依赖 Python、ffmpeg、TOS、ASR 和 LLM 配置。 +- Emby 插件包只放 `LifeTools.Emby.VideoSubtitle.Emby.dll` 和文档,不要把 `MediaBrowser.*`、`Emby.*` 或核心库 DLL 打进插件发布包。 +- 修改发布包内容时同步更新 `docs/release.md` 和 README 的发布入口。 +- 发布 workflow 需要 `permissions: contents: write`,不要扩大到无关权限。 + ## 文档规则 - README 已经是中文,新增仓库文档优先中文。 diff --git a/README.MD b/README.MD index ce06c30..8da8b7f 100644 --- a/README.MD +++ b/README.MD @@ -33,6 +33,10 @@ 完整安装说明和 AI Agent 快速安装步骤见:[docs/install.md](docs/install.md)。 +## 发布包 + +推送 `v*` tag 会通过 GitHub Actions 自动构建 GitHub Release 资产,包括 Linux/macOS Go 二进制包、`video_subtitle` 源码包和 Emby 插件包。发布流程和资产说明见:[docs/release.md](docs/release.md)。 + ## 哪些工具? ## retry_exec diff --git a/docs/release.md b/docs/release.md new file mode 100644 index 0000000..d5d21ff --- /dev/null +++ b/docs/release.md @@ -0,0 +1,103 @@ +# 发布说明 + +本仓库通过 GitHub Actions 在推送 `v*` tag 时自动构建发布包,并把 zip 上传到 GitHub Release。PR 会执行同一套测试和打包 dry-run,但不会创建 Release。 + +## 触发方式 + +从最新 `master` 创建 tag 并推送: + +```bash +git checkout master +git pull --ff-only origin master +git tag v0.0.3 +git push origin v0.0.3 +``` + +workflow 文件: + +```text +.github/workflows/release.yml +``` + +触发条件: + +```yaml +on: + pull_request: + paths: + - '.github/workflows/release.yml' + - 'docs/release.md' + - 'README.MD' + - 'AGENTS.md' + - 'go.mod' + - 'go.sum' + - '**/*.go' + - 'video_subtitle/**' + - 'emby_plugins/video_subtitle/**' + - 'sample/life_tools/**' + push: + tags: + - 'v*' +``` + +`pull_request` 只做测试和打包 dry-run;只有 tag push 才执行 `gh release create` 或 `gh release upload`。 + +## 发布包 + +每次 tag 发布会生成这些资产: + +```text +life_tools_linux_amd64_.zip +life_tools_linux_arm64_.zip +life_tools_darwin_amd64_.zip +life_tools_darwin_arm64_.zip +life_tools_video_subtitle_source_.zip +life_tools_emby_video_subtitle_plugin_.zip +checksums.txt +``` + +Go 二进制包包含: + +```text +bin/renameV1 +bin/check_keywords +bin/retry_exec +bin/codex_hook_notify +bin/file_share +install.sh +sample/life_tools/*.json +docs/*.md +``` + +`video_subtitle` 发布包包含 Python 源码、prompts、`requirements.txt`、示例配置和文档。它不是纯二进制工具,使用前仍需要 Python 依赖、ffmpeg、TOS、ASR、LLM 配置。 + +Emby 插件发布包只包含部署需要的插件 DLL 和文档。安装到 Emby 插件目录时只复制: + +```text +LifeTools.Emby.VideoSubtitle.Emby.dll +``` + +不要把 `MediaBrowser.*`、`Emby.*` 或核心库 DLL 放进 Emby 插件目录。 + +## CI 验证 + +发布前 workflow 会运行: + +```bash +go test ./... +python3 -m unittest video_subtitle/video_subtitle_test.py +python3 -m py_compile video_subtitle/video_subtitle.py video_subtitle/video_subtitle_test.py video_subtitle/lib/*.py +dotnet test emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release +dotnet build emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release +``` + +## 权限 + +Release workflow 需要: + +```yaml +permissions: + contents: write +``` + +这是 `gh release create` 和 `gh release upload` 上传资产所需的最小仓库权限。 From e5e6b77a24264f7ffbff26db032ec260c133532c Mon Sep 17 00:00:00 2001 From: chaoqun Date: Sun, 28 Jun 2026 21:18:56 +0800 Subject: [PATCH 2/4] ci: split go tests from release workflow Change-Id: Id173201ccd5d947191b7d4c80823f809fb8947f6 --- .github/workflows/go-test.yml | 46 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 5 +--- AGENTS.md | 1 + docs/release.md | 16 +++++++++--- 4 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/go-test.yml diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 0000000..afaef4f --- /dev/null +++ b/.github/workflows/go-test.yml @@ -0,0 +1,46 @@ +name: Go Test Reminder + +on: + pull_request: + paths: + - '.github/workflows/go-test.yml' + - 'go.mod' + - 'go.sum' + - '**/*.go' + push: + branches: + - master + paths: + - '.github/workflows/go-test.yml' + - 'go.mod' + - 'go.sum' + - '**/*.go' + +permissions: + contents: read + +jobs: + go-test: + name: Go test reminder + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + cache: true + + - name: Run Go tests + id: go-test + continue-on-error: true + run: go test ./... + + - name: Write reminder summary + if: steps.go-test.outcome == 'failure' + run: | + echo '## Go test reminder' >> "$GITHUB_STEP_SUMMARY" + echo '' >> "$GITHUB_STEP_SUMMARY" + echo '`go test ./...` failed. This workflow is advisory and does not block release packaging.' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2dae482..341e38e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: name: Build release assets runs-on: ubuntu-latest env: - GO_VERSION: '1.18.x' + GO_VERSION: '1.21.x' DOTNET_VERSION: '8.0.x' PYTHONDONTWRITEBYTECODE: '1' steps: @@ -48,9 +48,6 @@ jobs: with: dotnet-version: ${{ env.DOTNET_VERSION }} - - name: Run Go tests - run: go test ./... - - name: Run video_subtitle tests run: | python3 -m unittest video_subtitle/video_subtitle_test.py diff --git a/AGENTS.md b/AGENTS.md index 2efa3ed..b76bc35 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -145,6 +145,7 @@ emby_plugins/video_subtitle/install.sh --help `.github/workflows/release.yml` 负责 tag 发布,不是普通 CI。修改发布流程时要同时关注 Go、Python `video_subtitle` 和 Emby 插件三类产物。 - tag 触发规则保持 `v*`,避免普通分支 push 意外创建 Release;`pull_request` 只能做 dry-run,不能创建 Release。 +- Go 测试放在 `.github/workflows/go-test.yml`,在 `Run Go tests` step 上用 `continue-on-error: true` 做提醒,不要阻塞 release workflow。 - Go 二进制包只放稳定 CLI 工具:`renameV1`、`check_keywords`、`retry_exec`、`codex_hook_notify`、`file_share`。 - `video_subtitle` 只能按源码包发布,不能宣传成免依赖二进制;它仍依赖 Python、ffmpeg、TOS、ASR 和 LLM 配置。 - Emby 插件包只放 `LifeTools.Emby.VideoSubtitle.Emby.dll` 和文档,不要把 `MediaBrowser.*`、`Emby.*` 或核心库 DLL 打进插件发布包。 diff --git a/docs/release.md b/docs/release.md index d5d21ff..2c7463c 100644 --- a/docs/release.md +++ b/docs/release.md @@ -1,6 +1,6 @@ # 发布说明 -本仓库通过 GitHub Actions 在推送 `v*` tag 时自动构建发布包,并把 zip 上传到 GitHub Release。PR 会执行同一套测试和打包 dry-run,但不会创建 Release。 +本仓库通过 GitHub Actions 在推送 `v*` tag 时自动构建发布包,并把 zip 上传到 GitHub Release。PR 会执行发布包打包 dry-run,但不会创建 Release。Go 测试在单独 workflow 里运行,失败只作为提醒,不阻塞发布包流程。 ## 触发方式 @@ -26,6 +26,7 @@ on: pull_request: paths: - '.github/workflows/release.yml' + - '.github/workflows/go-test.yml' - 'docs/release.md' - 'README.MD' - 'AGENTS.md' @@ -40,7 +41,7 @@ on: - 'v*' ``` -`pull_request` 只做测试和打包 dry-run;只有 tag push 才执行 `gh release create` 或 `gh release upload`。 +`pull_request` 在 release workflow 中只做 Python、Emby 插件测试和打包 dry-run;只有 tag push 才执行 `gh release create` 或 `gh release upload`。Go 测试由 `.github/workflows/go-test.yml` 单独执行,并在 `Run Go tests` step 上配置 `continue-on-error: true`。 ## 发布包 @@ -81,16 +82,23 @@ LifeTools.Emby.VideoSubtitle.Emby.dll ## CI 验证 -发布前 workflow 会运行: +发布前 release workflow 会运行: ```bash -go test ./... python3 -m unittest video_subtitle/video_subtitle_test.py python3 -m py_compile video_subtitle/video_subtitle.py video_subtitle/video_subtitle_test.py video_subtitle/lib/*.py dotnet test emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release dotnet build emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release ``` +Go 测试提示 workflow 会运行: + +```bash +go test ./... +``` + +该 workflow 不阻塞 release workflow。 + ## 权限 Release workflow 需要: From b3ac8a3794c3588b9dd6811236fdfa124340650c Mon Sep 17 00:00:00 2001 From: chaoqun Date: Sun, 28 Jun 2026 21:28:25 +0800 Subject: [PATCH 3/4] ci: split python tests from release workflow Change-Id: I0808a72f646a014802c3eb3e996ad349627c6f46 --- .github/workflows/python-test.yml | 43 +++++++++++++++++++++++++++++++ .github/workflows/release.yml | 5 ++-- AGENTS.md | 2 +- docs/release.md | 11 ++++---- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/python-test.yml diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml new file mode 100644 index 0000000..1690d43 --- /dev/null +++ b/.github/workflows/python-test.yml @@ -0,0 +1,43 @@ +name: Python Test Reminder + +on: + pull_request: + paths: + - '.github/workflows/python-test.yml' + - 'video_subtitle/**' + push: + branches: + - master + paths: + - '.github/workflows/python-test.yml' + - 'video_subtitle/**' + +permissions: + contents: read + +jobs: + python-test: + name: Python test reminder + runs-on: ubuntu-latest + env: + PYTHONDONTWRITEBYTECODE: '1' + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Run video_subtitle tests + id: python-test + continue-on-error: true + run: python3 -m unittest video_subtitle/video_subtitle_test.py + + - name: Write reminder summary + if: steps.python-test.outcome == 'failure' + run: | + echo '## Python test reminder' >> "$GITHUB_STEP_SUMMARY" + echo '' >> "$GITHUB_STEP_SUMMARY" + echo '`python3 -m unittest video_subtitle/video_subtitle_test.py` failed. This workflow is advisory and does not block release packaging.' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 341e38e..113cb67 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,8 @@ on: pull_request: paths: - '.github/workflows/release.yml' + - '.github/workflows/go-test.yml' + - '.github/workflows/python-test.yml' - 'docs/release.md' - 'README.MD' - 'AGENTS.md' @@ -48,9 +50,8 @@ jobs: with: dotnet-version: ${{ env.DOTNET_VERSION }} - - name: Run video_subtitle tests + - name: Compile video_subtitle Python files run: | - python3 -m unittest video_subtitle/video_subtitle_test.py python3 -m py_compile \ video_subtitle/video_subtitle.py \ video_subtitle/video_subtitle_test.py \ diff --git a/AGENTS.md b/AGENTS.md index b76bc35..6429f02 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -145,7 +145,7 @@ emby_plugins/video_subtitle/install.sh --help `.github/workflows/release.yml` 负责 tag 发布,不是普通 CI。修改发布流程时要同时关注 Go、Python `video_subtitle` 和 Emby 插件三类产物。 - tag 触发规则保持 `v*`,避免普通分支 push 意外创建 Release;`pull_request` 只能做 dry-run,不能创建 Release。 -- Go 测试放在 `.github/workflows/go-test.yml`,在 `Run Go tests` step 上用 `continue-on-error: true` 做提醒,不要阻塞 release workflow。 +- Go 测试放在 `.github/workflows/go-test.yml`,Python 单元测试放在 `.github/workflows/python-test.yml`,在测试 step 上用 `continue-on-error: true` 做提醒,不要阻塞 release workflow。 - Go 二进制包只放稳定 CLI 工具:`renameV1`、`check_keywords`、`retry_exec`、`codex_hook_notify`、`file_share`。 - `video_subtitle` 只能按源码包发布,不能宣传成免依赖二进制;它仍依赖 Python、ffmpeg、TOS、ASR 和 LLM 配置。 - Emby 插件包只放 `LifeTools.Emby.VideoSubtitle.Emby.dll` 和文档,不要把 `MediaBrowser.*`、`Emby.*` 或核心库 DLL 打进插件发布包。 diff --git a/docs/release.md b/docs/release.md index 2c7463c..77a925b 100644 --- a/docs/release.md +++ b/docs/release.md @@ -1,6 +1,6 @@ # 发布说明 -本仓库通过 GitHub Actions 在推送 `v*` tag 时自动构建发布包,并把 zip 上传到 GitHub Release。PR 会执行发布包打包 dry-run,但不会创建 Release。Go 测试在单独 workflow 里运行,失败只作为提醒,不阻塞发布包流程。 +本仓库通过 GitHub Actions 在推送 `v*` tag 时自动构建发布包,并把 zip 上传到 GitHub Release。PR 会执行发布包打包 dry-run,但不会创建 Release。Go 和 Python 单元测试在单独 workflow 里运行,失败只作为提醒,不阻塞发布包流程。 ## 触发方式 @@ -27,6 +27,7 @@ on: paths: - '.github/workflows/release.yml' - '.github/workflows/go-test.yml' + - '.github/workflows/python-test.yml' - 'docs/release.md' - 'README.MD' - 'AGENTS.md' @@ -41,7 +42,7 @@ on: - 'v*' ``` -`pull_request` 在 release workflow 中只做 Python、Emby 插件测试和打包 dry-run;只有 tag push 才执行 `gh release create` 或 `gh release upload`。Go 测试由 `.github/workflows/go-test.yml` 单独执行,并在 `Run Go tests` step 上配置 `continue-on-error: true`。 +`pull_request` 在 release workflow 中只做 Python 编译检查、Emby 插件测试和打包 dry-run;只有 tag push 才执行 `gh release create` 或 `gh release upload`。Go 测试由 `.github/workflows/go-test.yml` 单独执行,Python 单元测试由 `.github/workflows/python-test.yml` 单独执行,两者都在测试 step 上配置 `continue-on-error: true`。 ## 发布包 @@ -85,19 +86,19 @@ LifeTools.Emby.VideoSubtitle.Emby.dll 发布前 release workflow 会运行: ```bash -python3 -m unittest video_subtitle/video_subtitle_test.py python3 -m py_compile video_subtitle/video_subtitle.py video_subtitle/video_subtitle_test.py video_subtitle/lib/*.py dotnet test emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release dotnet build emby_plugins/video_subtitle/LifeTools.Emby.VideoSubtitle.sln --configuration Release ``` -Go 测试提示 workflow 会运行: +测试提示 workflow 会运行: ```bash go test ./... +python3 -m unittest video_subtitle/video_subtitle_test.py ``` -该 workflow 不阻塞 release workflow。 +这些 workflow 不阻塞 release workflow。 ## 权限 From 48ec9f1eeceea932afa28b174b6d25c3872eaab9 Mon Sep 17 00:00:00 2001 From: chaoqun Date: Sun, 28 Jun 2026 21:50:02 +0800 Subject: [PATCH 4/4] ci: make advisory tests non-blocking Change-Id: I5f4d48997a8e82c5c730bfc6aaeaa3741c599c5d --- .github/workflows/go-test.yml | 20 +++++++++++++++----- .github/workflows/python-test.yml | 31 +++++++++++++++++++++++++------ .github/workflows/release.yml | 3 ++- AGENTS.md | 2 +- docs/release.md | 28 +++++++++++++++++++++++----- 5 files changed, 66 insertions(+), 18 deletions(-) diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index afaef4f..4d6f10d 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -33,13 +33,23 @@ jobs: go-version: '1.21.x' cache: true - - name: Run Go tests - id: go-test - continue-on-error: true - run: go test ./... + - name: Run Go tests as reminder + id: go_test + shell: bash + run: | + set +e + go test ./... 2>&1 | tee go-test.log + status="${PIPESTATUS[0]}" + if [ "$status" -ne 0 ]; then + echo "failed=true" >> "$GITHUB_OUTPUT" + echo "::warning::go test ./... failed with exit code $status. This workflow is advisory and does not block release packaging." + else + echo "failed=false" >> "$GITHUB_OUTPUT" + fi + exit 0 - name: Write reminder summary - if: steps.go-test.outcome == 'failure' + if: steps.go_test.outputs.failed == 'true' run: | echo '## Go test reminder' >> "$GITHUB_STEP_SUMMARY" echo '' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 1690d43..f2d85a5 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -20,6 +20,7 @@ jobs: name: Python test reminder runs-on: ubuntu-latest env: + PYTHON_VERSION: '3.12.x' PYTHONDONTWRITEBYTECODE: '1' steps: - name: Checkout @@ -28,15 +29,33 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: ${{ env.PYTHON_VERSION }} - - name: Run video_subtitle tests - id: python-test - continue-on-error: true - run: python3 -m unittest video_subtitle/video_subtitle_test.py + - name: Run video_subtitle tests as reminder + id: python_test + shell: bash + run: | + set +e + python3 -m pip install -r video_subtitle/requirements.txt + install_status="$?" + if [ "$install_status" -ne 0 ]; then + echo "failed=true" >> "$GITHUB_OUTPUT" + echo "::warning::python3 -m pip install -r video_subtitle/requirements.txt failed with exit code $install_status. Python tests were skipped. This workflow is advisory and does not block release packaging." + exit 0 + fi + + python3 -m unittest video_subtitle/video_subtitle_test.py 2>&1 | tee python-test.log + status="${PIPESTATUS[0]}" + if [ "$status" -ne 0 ]; then + echo "failed=true" >> "$GITHUB_OUTPUT" + echo "::warning::python3 -m unittest video_subtitle/video_subtitle_test.py failed with exit code $status. This workflow is advisory and does not block release packaging." + else + echo "failed=false" >> "$GITHUB_OUTPUT" + fi + exit 0 - name: Write reminder summary - if: steps.python-test.outcome == 'failure' + if: steps.python_test.outputs.failed == 'true' run: | echo '## Python test reminder' >> "$GITHUB_STEP_SUMMARY" echo '' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 113cb67..71eb868 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,7 @@ jobs: runs-on: ubuntu-latest env: GO_VERSION: '1.21.x' + PYTHON_VERSION: '3.12.x' DOTNET_VERSION: '8.0.x' PYTHONDONTWRITEBYTECODE: '1' steps: @@ -43,7 +44,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: ${{ env.PYTHON_VERSION }} - name: Setup .NET uses: actions/setup-dotnet@v4 diff --git a/AGENTS.md b/AGENTS.md index 6429f02..4cd55bc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -145,7 +145,7 @@ emby_plugins/video_subtitle/install.sh --help `.github/workflows/release.yml` 负责 tag 发布,不是普通 CI。修改发布流程时要同时关注 Go、Python `video_subtitle` 和 Emby 插件三类产物。 - tag 触发规则保持 `v*`,避免普通分支 push 意外创建 Release;`pull_request` 只能做 dry-run,不能创建 Release。 -- Go 测试放在 `.github/workflows/go-test.yml`,Python 单元测试放在 `.github/workflows/python-test.yml`,在测试 step 上用 `continue-on-error: true` 做提醒,不要阻塞 release workflow。 +- Go 测试放在 `.github/workflows/go-test.yml`,Python 单元测试放在 `.github/workflows/python-test.yml`,测试失败只能写 GitHub warning 和 summary,不能让 reminder workflow 或 release workflow 失败。 - Go 二进制包只放稳定 CLI 工具:`renameV1`、`check_keywords`、`retry_exec`、`codex_hook_notify`、`file_share`。 - `video_subtitle` 只能按源码包发布,不能宣传成免依赖二进制;它仍依赖 Python、ffmpeg、TOS、ASR 和 LLM 配置。 - Emby 插件包只放 `LifeTools.Emby.VideoSubtitle.Emby.dll` 和文档,不要把 `MediaBrowser.*`、`Emby.*` 或核心库 DLL 打进插件发布包。 diff --git a/docs/release.md b/docs/release.md index 77a925b..fe8211b 100644 --- a/docs/release.md +++ b/docs/release.md @@ -4,12 +4,12 @@ ## 触发方式 -从最新 `master` 创建 tag 并推送: +从最新 `master` 创建 tag 并推送。只有推送匹配 `v*` 的 tag 才会创建或更新 GitHub Release,PR 上的 release workflow 只做 dry-run: ```bash -git checkout master +git switch master git pull --ff-only origin master -git tag v0.0.3 +git tag -a v0.0.3 -m "life_tools v0.0.3" git push origin v0.0.3 ``` @@ -42,7 +42,25 @@ on: - 'v*' ``` -`pull_request` 在 release workflow 中只做 Python 编译检查、Emby 插件测试和打包 dry-run;只有 tag push 才执行 `gh release create` 或 `gh release upload`。Go 测试由 `.github/workflows/go-test.yml` 单独执行,Python 单元测试由 `.github/workflows/python-test.yml` 单独执行,两者都在测试 step 上配置 `continue-on-error: true`。 +`pull_request` 在 release workflow 中只做 Python 编译检查、Emby 插件测试和打包 dry-run;只有 tag push 才执行 `gh release create` 或 `gh release upload`。Go 测试由 `.github/workflows/go-test.yml` 单独执行,Python 单元测试由 `.github/workflows/python-test.yml` 单独执行。测试失败时 reminder workflow 只写 GitHub warning 和 summary,本身仍返回成功,不阻塞发布包流程。 + +## 发布操作流程 + +1. 先把发布相关 PR 合并到 `master`。 +2. 在本地同步最新 `master`,创建新的 `v*` tag,并推送到远端。不要复用已经发布过的 tag;新版本用新 tag。 +3. 打开 GitHub Actions 的 `Release` workflow,确认 tag 触发的 `Build release assets` job 成功。 +4. 打开 GitHub 仓库的 Releases 页面,进入对应 tag,例如 `v0.0.3`,下载需要的 zip。 + +也可以用 GitHub CLI 下载产物: + +```bash +gh release view v0.0.3 --web +gh release download v0.0.3 --dir /tmp/life_tools_v0.0.3 +cd /tmp/life_tools_v0.0.3 +sha256sum -c checksums.txt +``` + +如果 tag push 后没有出现 Release,先检查 tag 名是否以 `v` 开头,再检查 Actions 里的 `Release` workflow 日志。 ## 发布包 @@ -98,7 +116,7 @@ go test ./... python3 -m unittest video_subtitle/video_subtitle_test.py ``` -这些 workflow 不阻塞 release workflow。 +这些 workflow 失败时只写 GitHub warning 和 summary,不阻塞 release workflow,也不阻止 tag 发布资产。 ## 权限