Skip to content

Commit c0446f2

Browse files
committed
fix(ci): 注入 tag 版本号到 __init__.py,修复打包版本号不随 tag 更新
打包 exe 内部 __version__ 一直停留在 0.1.0,与 git tag(已到 v0.8.0)脱节, 导致关于页/更新检查自报旧版本,且 updater 误报“有新版本”。 _build.yml 增加可选 version 入参,release.yml 传 github.ref_name; 打包前 sed 注入到 aao/__init__.py(去 v 前缀),package-check 留空不注入。
1 parent 0a23ea1 commit c0446f2

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/_build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
archive_prefix:
1010
required: true
1111
type: string
12+
version:
13+
description: 注入到 aao/__init__.py 的版本号(带或不带 v 前缀;留空则不注入)
14+
required: false
15+
type: string
16+
default: ''
1217

1318
jobs:
1419
build:
@@ -32,6 +37,16 @@ jobs:
3237
cache: pnpm
3338
- run: pnpm install --frozen-lockfile
3439
- run: uv sync
40+
- name: Inject version from tag
41+
if: ${{ inputs.version != '' }}
42+
shell: bash
43+
env:
44+
VERSION: ${{ inputs.version }}
45+
run: |
46+
v="${VERSION#v}" # 去掉 v 前缀,与 about_page 显示 v{__version__} / updater 比较一致
47+
sed -i "s/__version__ = \".*\"/__version__ = \"$v\"/" aao/__init__.py
48+
echo "[OK] injected __version__ = $v"
49+
grep "__version__" aao/__init__.py
3550
- run: pnpm check && pnpm check:py
3651
- name: Disable Windows Defender realtime monitoring
3752
shell: powershell

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
with:
1313
artifact_name: win-x64
1414
archive_prefix: ArknightsAutoOperator-win-x64-${{ github.ref_name }}
15+
version: ${{ github.ref_name }}
1516

1617
git_cliff:
1718
name: Generate release notes

0 commit comments

Comments
 (0)