.2059806565729300:ea2bd6200ad210607021cd167237f62b_69e3499ab13256d09ece8088.69e3996bb13256d09ece81a4.69e3996a7afba9383018b935:Trae CN.T(2026/4/18 22:47:07)#1271
Conversation
重构版本号获取脚本,统一处理不同CI环境和本地环境的版本号获取 添加版本信息输出功能,便于调试和验证构建版本 修改相关脚本以使用新的版本号获取方式
Greptile SummaryThis PR refactors Confidence Score: 5/5Safe to merge; all findings are P2 style suggestions with no correctness or data-integrity impact. The refactoring is logically sound, set -e edge cases are handled with proper fallbacks, and the GITHUB_REF_NAME guard (v* prefix check) is correct. Only minor style issues remain. scripts/package/package-deb.sh and scripts/package/package-all.sh for the double getversion.sh invocation pattern. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[getversion.sh called] --> B{GITHUB_REF_NAME set\nand starts with v?}
B -- Yes --> C[Use GITHUB_REF_NAME]
B -- No --> D{TRAVIS_TAG set?}
D -- Yes --> E[Use TRAVIS_TAG]
D -- No --> F{APPVEYOR_REPO_TAG_NAME set?}
F -- Yes --> G[Use APPVEYOR tag]
F -- No --> H[git describe --exact-match]
H -- Found --> I[Use exact tag]
H -- Not found --> J[git describe latest + .dev-HASH]
J --> K[version string]
C --> K
E --> K
G --> K
I --> K
K --> L{--strip-v flag?}
L -- Yes --> M[sed remove leading v]
L -- No --> N[Output as-is]
M --> O[echo version]
N --> O
Reviews (1): Last reviewed commit: "refactor(scripts): 统一版本号获取逻辑并添加版本信息输出" | Re-trigger Greptile |
| VERSION_NUM="$("$SCRIPT_DIR/getversion.sh" --strip-v)" | ||
| echo "Version (with v): $VERSION" |
There was a problem hiding this comment.
Double invocation of
getversion.sh
getversion.sh is called twice here (once for VERSION, once for VERSION_NUM), spawning two subshells and two git describe calls. The stripped form can be derived from the first result directly.
| VERSION_NUM="$("$SCRIPT_DIR/getversion.sh" --strip-v)" | |
| echo "Version (with v): $VERSION" | |
| VERSION="$("$SCRIPT_DIR/getversion.sh")" | |
| VERSION_NUM="$(echo "$VERSION" | sed -e 's/^v//')" |
The same pattern also appears in both workflow files (lines 62-63 in build.yml and equivalently in build-tauri.yml) and in package-all.sh (via get_version + get_version_no_prefix), so this is a widespread pattern in the PR.
| exit 1 | ||
| fi | ||
|
|
||
| # Windows installer version should not include 'v' prefix, see: https://github.com/microsoft/winget-pkgs/pull/17564 | ||
| version_no_prefix="$(echo $version | sed -e 's/^v//')" | ||
| if [[ $TAURI_BUILD == "true" ]]; then | ||
| env AW_VERSION=$version_no_prefix "$innosetupdir/iscc.exe" scripts/package/aw-tauri.iss |
There was a problem hiding this comment.
Removed context comment for Windows installer
v-prefix requirement
The deleted line explained why the v prefix must be stripped for the Windows installer:
# Windows installer version should not include 'v' prefix, see: https://github.com/microsoft/winget-pkgs/pull/17564
This is a non-obvious requirement and the link to the winget-pkgs PR was valuable context for future maintainers. Consider restoring it near the build_setup function or the version_no_prefix assignment at the top of the file.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
- Replace hardcoded VERSION="0.1.0" in build_app_tauri.sh with dynamic getversion.sh call - Refactor getversion.sh to support multiple CI environments (GitHub Actions, Travis, AppVeyor) and add --strip-v flag - Use SCRIPT_DIR for robust relative path resolution in package scripts - Replace manual sed-based v-prefix stripping with --strip-v flag - Add verbose version logging in CI workflows for easier debugging Salvaged from ActivityWatch#1271 by @caoweiping.
重构版本号获取脚本,统一处理不同CI环境和本地环境的版本号获取
添加版本信息输出功能,便于调试和验证构建版本
修改相关脚本以使用新的版本号获取方式