ci: Release build 自动从 git tag 读取版本号#2
Merged
Conversation
- xcodebuild 命令行注入 MARKETING_VERSION 和 CURRENT_PROJECT_VERSION, 来源为触发 tag(去掉 v 前缀),优先级高于 pbxproj 硬编码值 - 将 pbxproj Release 配置中写死的 1.3.0 改为占位值 1.0, 避免本地 Xcode 显示版本与最新 tag 不符 - 本地 Debug build 不受影响
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
project.pbxproj里MARKETING_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,因此
CFBundleShortVersionString和CFBundleVersion均与 tag 对齐。变更
.github/workflows/release.yml:Build 步骤解出 tag 版本号并通过命令行参数传给 xcodebuild。project.pbxproj:Release 配置里写死的1.3.0改为占位值1.0,消除歧义。影响范围