Skip to content

ci: Release build 自动从 git tag 读取版本号#2

Merged
PrintNow merged 1 commit into
mainfrom
agent/release-version-from-git-tag
May 11, 2026
Merged

ci: Release build 自动从 git tag 读取版本号#2
PrintNow merged 1 commit into
mainfrom
agent/release-version-from-git-tag

Conversation

@PrintNow
Copy link
Copy Markdown
Owner

问题

project.pbxprojMARKETING_VERSION 写死为 1.3.0,即使推了 v1.5.0 的 tag,打出来的包版本号仍是旧值。

方案

xcodebuild 命令行通过 build settings 覆盖机制注入版本号,无需修改 Xcode 工程文件:

```bash
VERSION="${GITHUB_REF_NAME#v}" # v1.5.0 → 1.5.0
xcodebuild ...
MARKETING_VERSION="$VERSION"
CURRENT_PROJECT_VERSION="$VERSION"
```

命令行传入的 build settings 优先级高于 pbxproj,因此 CFBundleShortVersionStringCFBundleVersion 均与 tag 对齐。

变更

  • .github/workflows/release.yml:Build 步骤解出 tag 版本号并通过命令行参数传给 xcodebuild。
  • project.pbxproj:Release 配置里写死的 1.3.0 改为占位值 1.0,消除歧义。

影响范围

  • 本地 Debug build:不受影响,版本号仍为 pbxproj 默认值。
  • Release CI:仅 tag push 时触发,版本号自动与 tag 对齐。

- xcodebuild 命令行注入 MARKETING_VERSION 和 CURRENT_PROJECT_VERSION,
  来源为触发 tag(去掉 v 前缀),优先级高于 pbxproj 硬编码值
- 将 pbxproj Release 配置中写死的 1.3.0 改为占位值 1.0,
  避免本地 Xcode 显示版本与最新 tag 不符
- 本地 Debug build 不受影响
@PrintNow PrintNow marked this pull request as ready for review May 11, 2026 14:33
@PrintNow PrintNow merged commit 9600afd into main May 11, 2026
@PrintNow PrintNow deleted the agent/release-version-from-git-tag branch May 11, 2026 14:33
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.

1 participant