diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..07cf848 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +# ci.yml — PR 门禁:build + test(窗口 v8-1a,施工方案-v0.8.0 §四) +# +# 两条故意约束(不要"修"掉): +# 1) 故意不设 TTS_FIXTURE_DIR / TTS_EXTRACTED_DIR:13 个依赖真实夹具的用例 +# (archive-cachekey 5 + archive-ttsmod 7 + pack-unpack 1)在 CI 上继续 skip, +# CI 基线固定为 2024 passed / 82 skipped。自制夹具由 v8-2 窗口引入,且仅用于本地。 +# 2) npm test 连跑 3 次:防御 Windows 下 git 子进程清理慢导致的 EBUSY 偶发 +# (见 vitest.config.ts 头注与项目记忆 workflow-vitest-loop-pitfall)。 +name: CI + +on: + pull_request: + +env: + CI: true + +jobs: + build-test: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + + # package.json 无 packageManager 字段,corepack 对 npm 无效; + # 显式装 npm 11.9.0(Node 24.19.0 捆绑版本),保证 npm ci 行为可复现。 + - name: Pin npm + run: npm install -g npm@11.9.0 + + - name: Install + run: npm ci + + - name: Build + run: npm run build + + - name: Test (3 consecutive runs, EBUSY guard) + shell: bash + run: | + set -e + for i in 1 2 3; do + echo "=== npm test run $i/3 ===" + npm test + done + + # 防御性占位:当前 `vitest run` 不产出 .test-report/report.json + # (vitest.config.ts 未配置 reporter/outputFile),此步骤今日必跳过; + # 未来若加 reporter 即自动生效。失败时上传便于排查。 + - name: Upload test report on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: test-report + path: .test-report/report.json + if-no-files-found: ignore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e178c99 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,69 @@ +# release.yml — tag 触发发布链路(窗口 v8-1a,施工方案-v0.8.0 §四) +# +# 本窗口(v8-1a)只验证链路:build → test 3 连跑 → npm publish --dry-run。 +# 真实发布段在文件尾部整段注释中,由 v8-0 窗口启用(去掉 --dry-run)。 +# 红线 16:v0.7.0 必须成为第一个走本 workflow 的 npm 版本,不允许手动先发。 +# +# 与 ci.yml 相同的故意约束: +# - 不设 TTS_FIXTURE_DIR / TTS_EXTRACTED_DIR(CI 基线 2024 passed / 82 skipped) +# - npm test 连跑 3 次防 Windows EBUSY +name: Release + +on: + push: + tags: + - 'v*' + +env: + CI: true + +permissions: + id-token: write # npm provenance + contents: read + +jobs: + publish: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: 'https://registry.npmjs.org' + + # package.json 无 packageManager 字段,corepack 对 npm 无效; + # 显式装 npm 11.9.0(Node 24.19.0 捆绑版本),保证 publish 行为可复现。 + - name: Pin npm + run: npm install -g npm@11.9.0 + + - name: Install + run: npm ci + + - name: Build + run: npm run build + + - name: Test (3 consecutive runs, EBUSY guard) + shell: bash + run: | + set -e + for i in 1 2 3; do + echo "=== npm test run $i/3 ===" + npm test + done + + # v8-1a:dry-run 验证链路(打包 + provenance 签名全流程,但不真发)。 + # dry-run 不需要 NODE_AUTH_TOKEN,但保留环境变量使 v8-0 启用时零改动。 + - name: npm publish (dry-run) + run: npm publish --dry-run --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + # ===================================================================== + # v8-0 窗口将启用下方注释段(去掉 --dry-run),替换上面的 dry-run 步骤: + # + # - name: npm publish (real) + # run: npm publish --provenance --access public + # env: + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + # ===================================================================== diff --git a/README.md b/README.md index 78c21fb..3f86cb6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # tts-toolkit +[![CI](https://github.com/Smirk1921/tts-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/Smirk1921/tts-toolkit/actions/workflows/ci.yml) + > **English** — A comprehensive toolchain for Tabletop Simulator mod creators: pack > workspace, atlas slicing/stitching, git-based version control, hub daemon, MCP > integration, Lua test runner, and Steam Workshop publishing.