Skip to content

Commit 9374cb5

Browse files
author
dompling
committed
fix
1 parent 6017c51 commit 9374cb5

File tree

1 file changed

+66
-13
lines changed

1 file changed

+66
-13
lines changed

.github/workflows/build-release.yml

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ name: Build and Release TrollScript
33
on:
44
workflow_dispatch: # 手动触发
55

6-
env:
7-
XCODE_VERSION: '16.2'
8-
96
jobs:
107
build:
11-
runs-on: macos-latest
12-
8+
runs-on: macos-15
139
steps:
1410
# 1. 拉取当前 Release 仓库
1511
- name: Checkout Release Repository
@@ -26,19 +22,76 @@ jobs:
2622
token: ${{ secrets.GH_TOKEN }}
2723
path: TrollScript-Private
2824
fetch-depth: 0
29-
30-
# 3. 设置 Xcode 环境
31-
- name: Select Xcode Version
25+
26+
- name: Setup Xcode
27+
uses: maxim-lobanov/setup-xcode@v1
28+
with:
29+
xcode-version: '16.0'
30+
31+
- name: Show Xcode version
3232
run: |
33-
sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer
3433
xcodebuild -version
35-
36-
- name: Install Dependencies
34+
xcode-select -p
35+
36+
- name: Cache Swift Package Manager
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
build/SourcePackages
41+
~/Library/Caches/org.swift.swiftpm
42+
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
43+
restore-keys: |
44+
${{ runner.os }}-spm-
45+
46+
- name: Install ldid (iOS signing tool)
3747
run: |
3848
brew install ldid
39-
brew install make
49+
ldid -h || true
50+
echo "ldid installed successfully"
51+
52+
# 4. 从私有仓库 tag 更新版本号
53+
- name: Update version from tag
54+
working-directory: TrollScript-Private
55+
run: |
56+
INFO_PLIST="TrollScript/Info.plist"
57+
58+
# 获取最新 tag
59+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
60+
61+
if [ -n "$LATEST_TAG" ]; then
62+
# 从 tag 提取版本号,去掉 v 前缀
63+
VERSION="${LATEST_TAG#v}"
64+
echo "✅ 从 tag 提取版本号: $VERSION"
65+
else
66+
# 尝试获取当前 commit 的 tag
67+
CURRENT_TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
68+
if [ -n "$CURRENT_TAG" ]; then
69+
VERSION="${CURRENT_TAG#v}"
70+
echo "✅ 从当前 commit tag 提取版本号: $VERSION"
71+
else
72+
# 没有 tag,保持 Info.plist 中的版本不变
73+
echo "⚠️ 无 tag,保持原版本号不变"
74+
exit 0
75+
fi
76+
fi
77+
78+
# 生成构建号(使用时间戳)
79+
BUILD_NUMBER=$(date +'%Y%m%d%H%M')
80+
81+
# 更新 Info.plist
82+
echo "📝 更新 Info.plist:"
83+
echo " CFBundleShortVersionString: $VERSION"
84+
echo " CFBundleVersion: $BUILD_NUMBER"
85+
86+
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" "$INFO_PLIST"
87+
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "$INFO_PLIST"
88+
89+
# 验证更新
90+
echo "✅ 更新后的版本信息:"
91+
/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$INFO_PLIST"
92+
/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$INFO_PLIST"
4093
41-
# 4. 进入私有仓库目录,运行 build-tipa.sh
94+
# 5. 进入私有仓库目录,运行 build-tipa.sh
4295
- name: Build TrollScript
4396
working-directory: TrollScript-Private
4497
run: |

0 commit comments

Comments
 (0)