Skip to content

Commit f9ff358

Browse files
committed
version handling fix
1 parent b60eb5a commit f9ff358

5 files changed

Lines changed: 33 additions & 26 deletions

File tree

.github/workflows/build-linux.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,7 @@ jobs:
155155
run: |
156156
set -euo pipefail
157157
source .venv-linux/bin/activate
158-
# Derive a package-manager-safe version. On a tag push github.ref_name
159-
# is `vX.Y.Z` -> `X.Y.Z`; on a PR it is `<num>/merge` (and on dispatch a
160-
# branch name), neither of which is a valid deb/rpm version, so use a
161-
# placeholder for non-tag builds.
162-
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
163-
PKG_VERSION="${GITHUB_REF_NAME#v}"
164-
else
165-
PKG_VERSION="0.0.0"
166-
fi
167-
PKG_VERSION="$PKG_VERSION" python scripts/standalone/build.py --platform linux
168-
env:
169-
GITHUB_REF_NAME: ${{ github.ref_name }}
170-
GITHUB_REF_TYPE: ${{ github.ref_type }}
158+
python scripts/standalone/build.py --platform linux
171159
172160
- name: Upload .deb as a workflow artifact
173161
uses: actions/upload-artifact@v4

.github/workflows/build-windows.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,7 @@ jobs:
111111

112112
- name: Build the bundle
113113
shell: powershell
114-
run: |
115-
if ($env:GITHUB_REF_TYPE -eq "tag") {
116-
$ver = $env:GITHUB_REF_NAME -replace '^v', ''
117-
} else {
118-
$ver = "0.0.0"
119-
}
120-
$env:PKG_VERSION = $ver
121-
.venv-windows\Scripts\python scripts\standalone\build.py --platform windows
122-
env:
123-
GITHUB_REF_NAME: ${{ github.ref_name }}
124-
GITHUB_REF_TYPE: ${{ github.ref_type }}
114+
run: .venv-windows\Scripts\python scripts\standalone\build.py --platform windows
125115

126116
- name: Upload zip as a workflow artifact
127117
uses: actions/upload-artifact@v4

AudioMuse-AI.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ cfg = _cfg.PLATFORMS[target]
1818
arch = _cfg.normalize_arch(platform.machine(), target)
1919
USE_PGSERVER = _cfg.use_pgserver(cfg["use_pgserver"], arch)
2020

21+
_app_ver = _cfg.read_app_version(ROOT)
22+
if cfg["bundle"]:
23+
cfg["bundle"]["info_plist"]["CFBundleShortVersionString"] = _app_ver or "0.0.0"
24+
2125
datas = [
2226
(os.path.join(ROOT, "templates"), "templates"),
2327
(os.path.join(ROOT, "static"), "static"),

scripts/standalone/build.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def main():
5656
target = args.platform
5757
cfg = config.PLATFORMS[target]
5858
arch = args.arch or config.normalize_arch(_platform.machine(), target)
59-
version = sanitize_version(os.environ.get("PKG_VERSION"))
59+
60+
version = sanitize_version(config.read_app_version(ROOT))
61+
6062
use_pgserver = config.use_pgserver(cfg["use_pgserver"], arch)
6163

6264
dist_dir = ROOT / "dist"

scripts/standalone/config.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1+
import ast
2+
import os
13
import sys
24

5+
6+
def read_app_version(root):
7+
"""Return APP_VERSION from the app's config.py (leading 'v' stripped).
8+
9+
Parsed statically with ast -- config.py is never imported or executed, so
10+
there are no import side effects and no dependency on __file__ or the
11+
environment. build.py (deb/rpm version + banner) and the shared spec (macOS
12+
CFBundleShortVersionString) both call this, so every platform stamps the same
13+
manually-maintained version from config.py and no CI/tag value is used.
14+
"""
15+
path = os.path.join(str(root), "config.py")
16+
with open(path, encoding="utf-8") as fh:
17+
tree = ast.parse(fh.read(), filename=path)
18+
for node in tree.body:
19+
if isinstance(node, ast.Assign) and isinstance(node.value, ast.Constant):
20+
for target in node.targets:
21+
if isinstance(target, ast.Name) and target.id == "APP_VERSION":
22+
value = str(node.value.value)
23+
return value[1:] if value.startswith("v") else value
24+
return "0.0.0"
25+
26+
327
PLATFORMS = {
428
"windows": {
529
"launcher": "windows/launcher.py",
@@ -38,7 +62,6 @@
3862
"NSHighResolutionCapable": True,
3963
"CFBundleName": "AudioMuse-AI",
4064
"CFBundleDisplayName": "AudioMuse-AI",
41-
"CFBundleShortVersionString": "1.0.0",
4265
},
4366
},
4467
},

0 commit comments

Comments
 (0)