Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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 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.outputs.failed == 'true'
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"
62 changes: 62 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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:
PYTHON_VERSION: '3.12.x'
PYTHONDONTWRITEBYTECODE: '1'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- 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.outputs.failed == 'true'
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"
162 changes: 162 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Release

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'
- '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.21.x'
PYTHON_VERSION: '3.12.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: ${{ env.PYTHON_VERSION }}

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Compile video_subtitle Python files
run: |
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
13 changes: 13 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ 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 测试放在 `.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 打进插件发布包。
- 修改发布包内容时同步更新 `docs/release.md` 和 README 的发布入口。
- 发布 workflow 需要 `permissions: contents: write`,不要扩大到无关权限。

## 文档规则

- README 已经是中文,新增仓库文档优先中文。
Expand Down
4 changes: 4 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading