Skip to content

.2059806565729300:abd25200c78e13b5c371069c1916e8f8_69e3499ab13256d09ece8088.69e3a0ebb13256d09ece8264.69e3a0eb7afba9383018b937:Trae CN.T(2026/4/18 23:19:07)#1272

Closed
Wpc-121 wants to merge 2 commits intoActivityWatch:masterfrom
Wpc-121:mod_ver_02
Closed

.2059806565729300:abd25200c78e13b5c371069c1916e8f8_69e3499ab13256d09ece8088.69e3a0ebb13256d09ece8264.69e3a0eb7afba9383018b937:Trae CN.T(2026/4/18 23:19:07)#1272
Wpc-121 wants to merge 2 commits intoActivityWatch:masterfrom
Wpc-121:mod_ver_02

Conversation

@Wpc-121
Copy link
Copy Markdown
Contributor

@Wpc-121 Wpc-121 commented Apr 18, 2026

统一版本管理逻辑并添加版本一致性检查

重构版本管理脚本,引入 TAG_VERSION 和 DISPLAY_VERSION 概念

添加版本一致性检查确保所有构建产物使用相同版本号

更新所有相关构建脚本以使用新的版本管理方式

Wpc-121 added 2 commits April 18, 2026 23:17
重构版本号获取脚本,统一处理不同CI环境和本地环境的版本号获取
添加版本信息输出功能,便于调试和验证构建版本
修改相关脚本以使用新的版本号获取方式
重构版本管理脚本,引入 TAG_VERSION 和 DISPLAY_VERSION 概念
添加版本一致性检查确保所有构建产物使用相同版本号
更新所有相关构建脚本以使用新的版本管理方式
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 18, 2026

Greptile Summary

This PR refactors version management across all build scripts by introducing a single-source-of-truth getversion.sh with TAG_VERSION (with v prefix) and DISPLAY_VERSION (without v prefix), and adds a post-build version consistency check in package-all.sh.

  • P1 – Consistency check always fails for Tauri builds: In verify_version_consistency, the regex activitywatch-([^-]+)- is evaluated before the tauri-specific pattern for both zip and installer files. It always matches first and captures \"tauri\" as the version string, causing the check to report \"tauri\" != \"0.14.0\" and exit with EXIT_VERSION_MISMATCH on every Tauri build. The tauri-specific elif branch is unreachable (lines 69–74 and 99–104 of package-all.sh).

Confidence Score: 4/5

Not safe to merge as-is — the new consistency check will break every Tauri CI build due to the regex ordering bug.

Two P1 findings in verify_version_consistency (zip and installer regex) will cause false version mismatch failures on every Tauri build, blocking release packaging in CI. The rest of the refactor is sound.

scripts/package/package-all.sh (lines 69–74 and 99–104 in verify_version_consistency)

Important Files Changed

Filename Overview
scripts/package/getversion.sh Rewrites version script as the single source of truth; supports --tag, --display, --env, --json modes; fallback logic is correct and well-documented.
scripts/package/package-all.sh Adds version consistency check and loads version from authority; the regex for extracting version from Tauri zip/installer filenames is wrong (captures "tauri" instead of the version number), causing verify_version_consistency to always fail for Tauri builds.
scripts/package/build_app_tauri.sh Replaces hardcoded VERSION="0.1.0" with dynamic version via getversion.sh --env; uses DISPLAY_VERSION in Info.plist correctly.
scripts/package/package-deb.sh Switches from manual v-prefix stripping to getversion.sh --env; DISPLAY_VERSION used for deb package name and destination filename, removing the old v-prefix inconsistency.
.github/workflows/build.yml New Determine and output version step exports TAG_VERSION and DISPLAY_VERSION to GITHUB_ENV; calls getversion.sh twice (redundant git operations) but functionally correct.
.github/workflows/build-tauri.yml Same version-export step added as build.yml; same double-invocation of getversion.sh; otherwise correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[CI Workflow: Determine version] --> B[getversion.sh]
    B --> C{Version source}
    C -->|GITHUB_REF_NAME starts with v| D[Use CI tag]
    C -->|TRAVIS_TAG or APPVEYOR tag| D
    C -->|git describe exact match| D
    C -->|fallback| E[latest_tag.dev-commit]
    D --> F[TAG_VERSION = v0.14.0 / DISPLAY_VERSION = 0.14.0]
    E --> F
    F --> G[package-all.sh]
    G --> H[build_zip: zip filename uses DISPLAY_VERSION]
    G --> I[build_setup: installer uses DISPLAY_VERSION]
    G --> J[verify_version_consistency]
    J --> K{Tauri zip regex check}
    K -->|non-tauri| L[OK: version extracted correctly]
    K -->|tauri build| M[BUG: captures tauri not version]
    F --> N[build_app_tauri.sh: Info.plist uses DISPLAY_VERSION]
    F --> O[package-deb.sh: deb name uses DISPLAY_VERSION]
Loading

Reviews (1): Last reviewed commit: "refactor(version): 统一版本管理逻辑并添加版本一致性检查" | Re-trigger Greptile

Comment on lines +69 to +75
if [[ "$zip_file" =~ activitywatch-([^-]+)- ]]; then
zip_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $zip_version"
elif [[ "$zip_file" =~ activitywatch-tauri-([^-]+)- ]]; then
zip_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $zip_version"
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Tauri zip version regex always captures "tauri", not the version

For a Tauri zip named activitywatch-tauri-0.14.0-linux-x86_64.zip, the first pattern activitywatch-([^-]+)- matches immediately and captures "tauri" as zip_version. The elif branch for tauri is therefore unreachable. The check then compares "tauri" != "0.14.0" and marks the consistency check as failed on every Tauri build. The tauri-specific regex must be tested first.

Suggested change
if [[ "$zip_file" =~ activitywatch-([^-]+)- ]]; then
zip_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $zip_version"
elif [[ "$zip_file" =~ activitywatch-tauri-([^-]+)- ]]; then
zip_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $zip_version"
fi
if [[ "$zip_file" =~ activitywatch-tauri-([^-]+)- ]]; then
zip_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $zip_version"
elif [[ "$zip_file" =~ activitywatch-([^-]+)- ]]; then
zip_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $zip_version"
fi

Comment on lines +99 to +105
if [[ "$installer_file" =~ activitywatch-([^-]+)- ]]; then
installer_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $installer_version"
elif [[ "$installer_file" =~ activitywatch-tauri-([^-]+)- ]]; then
installer_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $installer_version"
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Same regex ordering bug in installer version extraction

Identical issue as the zip check above: activitywatch-([^-]+)- always matches a Tauri installer filename first and captures "tauri", so installer_version is set to "tauri" instead of the actual version number. The consistency check will spuriously fail for every Windows Tauri installer build.

Suggested change
if [[ "$installer_file" =~ activitywatch-([^-]+)- ]]; then
installer_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $installer_version"
elif [[ "$installer_file" =~ activitywatch-tauri-([^-]+)- ]]; then
installer_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $installer_version"
fi
if [[ "$installer_file" =~ activitywatch-tauri-([^-]+)- ]]; then
installer_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $installer_version"
elif [[ "$installer_file" =~ activitywatch-([^-]+)- ]]; then
installer_version="${BASH_REMATCH[1]}"
log_info " Extracted version: $installer_version"
fi

Comment on lines +62 to +63
TAG_VERSION=$(bash scripts/package/getversion.sh --tag)
DISPLAY_VERSION=$(bash scripts/package/getversion.sh --display)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 getversion.sh is invoked twice, doubling git operations

getversion.sh --tag and getversion.sh --display each run git describe independently, which is redundant. Using --env mode (as done in the shell scripts) and eval would fetch version information in a single call and is already the pattern established elsewhere in this PR.

Suggested change
TAG_VERSION=$(bash scripts/package/getversion.sh --tag)
DISPLAY_VERSION=$(bash scripts/package/getversion.sh --display)
eval "$(bash scripts/package/getversion.sh --env)"

Comment on lines +60 to +61
TAG_VERSION=$(bash scripts/package/getversion.sh --tag)
DISPLAY_VERSION=$(bash scripts/package/getversion.sh --display)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Same double invocation as build.yml

getversion.sh is called twice in this step as well. Using --env mode with eval matches the pattern in the shell scripts and avoids running git describe twice.

Suggested change
TAG_VERSION=$(bash scripts/package/getversion.sh --tag)
DISPLAY_VERSION=$(bash scripts/package/getversion.sh --display)
eval "$(bash scripts/package/getversion.sh --env)"

@ErikBjare ErikBjare closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants