|
1 | 1 | name: Package Check |
2 | 2 |
|
3 | | -# 每次 commit(push 改动打包相关文件)模拟完整打包:构建 + 冒烟验 PKG + 上传 artifact。 |
4 | | -# 不发版、不打 tag。尽早发现打包问题(PKG 损坏、CI 环境差异)。 |
5 | | -# 代码 lint/format 检查见 check.yml(轻量),本 workflow 只管打包。 |
6 | | - |
7 | 3 | on: |
8 | | - push: |
| 4 | + workflow_run: |
| 5 | + workflows: [Check] |
| 6 | + types: [completed] |
9 | 7 | branches: [main, master] |
10 | | - paths: |
11 | | - - 'aao/**' |
12 | | - - 'custom/**' |
13 | | - - 'resource/**' |
14 | | - - 'examples/**' |
15 | | - - 'aao.spec' |
16 | | - - 'pyproject.toml' |
17 | | - - 'uv.lock' |
18 | | - - 'package.json' |
19 | | - - 'pnpm-lock.yaml' |
20 | | - - 'logo.png' |
21 | | - - '.github/workflows/package-check.yml' |
22 | 8 | workflow_dispatch: |
23 | 9 |
|
24 | 10 | concurrency: |
25 | 11 | group: package-check-${{ github.ref }} |
26 | 12 | cancel-in-progress: true |
27 | 13 |
|
28 | 14 | jobs: |
29 | | - package-check: |
30 | | - runs-on: windows-latest |
| 15 | + paths-filter: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + packaging: ${{ steps.filter.outputs.packaging }} |
31 | 19 | steps: |
32 | 20 | - uses: actions/checkout@v6 |
33 | 21 | with: |
34 | | - submodules: true # 拉取 MaaCommonAssets(OCR 模型来源) |
35 | | - - uses: actions/setup-python@v6 |
36 | | - with: |
37 | | - python-version: '3.13' |
38 | | - - uses: astral-sh/setup-uv@v8.1.0 |
39 | | - - uses: pnpm/action-setup@v6 |
40 | | - - uses: actions/setup-node@v6 |
41 | | - with: |
42 | | - node-version: 24 |
43 | | - cache: pnpm |
44 | | - - run: pnpm install --frozen-lockfile |
45 | | - - run: uv sync |
46 | | - - run: pnpm check |
47 | | - - run: pnpm check:py |
48 | | - - name: Disable Windows Defender realtime monitoring |
49 | | - shell: powershell |
50 | | - run: | |
51 | | - Set-MpPreference -DisableRealtimeMonitoring $true -ErrorAction SilentlyContinue |
52 | | - Add-MpPreference -ExclusionPath "$env:GITHUB_WORKSPACE" -ErrorAction SilentlyContinue |
53 | | - Write-Host "Defender realtime monitoring disabled for build" |
54 | | - - name: Configure OCR model |
55 | | - run: uv run python tools/configure.py |
56 | | - - name: Convert logo.png to ico |
57 | | - shell: bash |
58 | | - run: uv run python -c "from PIL import Image; Image.open('logo.png').save('logo.ico', format='ICO', sizes=[(256,256),(128,128),(64,64),(48,48),(32,32),(16,16)])" |
59 | | - - name: Build (PyInstaller) |
60 | | - run: uv run pyinstaller aao.spec --noconfirm |
61 | | - - name: Smoke test packaged exe |
| 22 | + fetch-depth: 2 |
| 23 | + ref: ${{ github.event.workflow_run.head_sha || github.sha }} |
| 24 | + - id: filter |
62 | 25 | shell: bash |
63 | 26 | run: | |
64 | | - export QT_QPA_PLATFORM=offscreen |
65 | | - timeout 20 ./dist/aao.app/aao.app.exe --no-api > smoke.log 2>&1 || true |
66 | | - if grep -q "Could not load PyInstaller" smoke.log; then |
67 | | - echo "[ERR] packaged exe failed to load PKG archive" |
68 | | - cat smoke.log |
69 | | - exit 1 |
| 27 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 28 | + echo "packaging=true" >> "$GITHUB_OUTPUT" |
| 29 | + elif git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '^(aao/|custom/|resource/|examples/|aao\.spec|pyproject\.toml|uv\.lock|package\.json|pnpm-lock\.yaml|logo\.png|\.github/workflows/(package-check|_build)\.yml)'; then |
| 30 | + echo "packaging=true" >> "$GITHUB_OUTPUT" |
| 31 | + else |
| 32 | + echo "packaging=false" >> "$GITHUB_OUTPUT" |
| 33 | + echo "No packaging files changed, skipping build" |
70 | 34 | fi |
71 | | - echo "[OK] packaged exe loads PKG archive" |
72 | | - head -5 smoke.log |
73 | | - - name: Download AFA (ArknightsFrameAssistant) |
74 | | - shell: bash |
75 | | - run: | |
76 | | - mkdir -p dist/aao.app/afa |
77 | | - repo="CloudTracey/arknights-frame-assistant" |
78 | | - tag="$(curl -fsSL "https://api.github.com/repos/$repo/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')" |
79 | | - echo "AFA latest tag: $tag" |
80 | | - curl -fsSL "https://github.com/$repo/releases/download/$tag/AFA.exe" -o dist/aao.app/afa/AFA.exe |
81 | | - curl -fsSL "https://raw.githubusercontent.com/$repo/$tag/LICENSE" -o dist/aao.app/afa/LICENSE || echo "[WARN] AFA LICENSE 未取到" |
82 | | - - name: Sync game data |
83 | | - run: uv run python -m aao.resources.syncer |
84 | | - - name: Stage external resources |
85 | | - shell: bash |
86 | | - run: | |
87 | | - cp -r resource data examples dist/aao.app/ |
88 | | - cp logo.png dist/aao.app/ |
89 | | - rm -rf dist/aao.app/config dist/aao.app/debug |
90 | | - - name: Package |
91 | | - shell: bash |
92 | | - run: | |
93 | | - archive="ArknightsAutoOperator-check-${GITHUB_SHA::7}.zip" |
94 | | - ( cd dist/aao.app && 7z a "../../$archive" . ) |
95 | | - - uses: actions/upload-artifact@v7 |
96 | | - with: |
97 | | - name: check-build |
98 | | - path: | |
99 | | - *.zip |
100 | | - dist/aao.app |
| 35 | +
|
| 36 | + build: |
| 37 | + needs: paths-filter |
| 38 | + if: ${{ needs.paths-filter.outputs.packaging == 'true' && (github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch') }} |
| 39 | + uses: ./.github/workflows/_build.yml |
| 40 | + with: |
| 41 | + artifact_name: check-build |
| 42 | + archive_prefix: ArknightsAutoOperator-check-${{ github.event.workflow_run.head_sha || github.sha }} |
0 commit comments