Skip to content

Commit

Permalink
Update Project.swift and GitHub Actions workflow for versioning and b…
Browse files Browse the repository at this point in the history
…uild number management

- Added appVersion and buildVersion constants in Project.swift for better version control.
- Updated MARKETING_VERSION and CURRENT_PROJECT_VERSION to use these constants, enhancing clarity.
- Modified GitHub Actions workflow to generate a timestamp-based build number and replace the placeholder in Project.swift.
- These changes improve the versioning process and streamline the CI/CD pipeline for automated builds.
  • Loading branch information
ygsgdbd committed Dec 22, 2024
1 parent e4cfea7 commit 3cab19c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ jobs:
run: |
brew install tuist
- name: Set Build Number
- name: Generate Xcode Project
run: |
# 生成基于时间戳的构建号(格式:YYYYMMDDHHmm)
BUILD_NUMBER=$(date "+%Y%m%d%H%M")
# 替换 Project.swift 中的占位符,使用 # 作为分隔符
sed -i '' "s#@BUILD_NUMBER@#$BUILD_NUMBER#g" Project.swift
# 替换 Project.swift 中的占位符
sed -i '' "s/@BUILD_NUMBER@/$BUILD_NUMBER/g" Project.swift
echo "Build number set to: $BUILD_NUMBER"
- name: Generate Xcode Project
run: |
tuist generate --no-open
- name: Build App
Expand Down
16 changes: 11 additions & 5 deletions Project.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import ProjectDescription

// MARK: - Version
let appVersion = "0.1.0" // 应用版本号
let buildVersion = "@BUILD_NUMBER@" // 构建版本号占位符,会被 GitHub Actions 替换

let project = Project(
name: "VastWords",
options: .options(
Expand All @@ -14,11 +18,11 @@ let project = Project(
],
settings: .settings(
base: [
"SWIFT_VERSION": "5.9",
"DEVELOPMENT_LANGUAGE": "zh-Hans",
"SWIFT_EMIT_LOC_STRINGS": "YES",
"MARKETING_VERSION": "0.1.0",
"CURRENT_PROJECT_VERSION": "@BUILD_NUMBER@"
"SWIFT_VERSION": SettingValue(stringLiteral: "5.9"),
"DEVELOPMENT_LANGUAGE": SettingValue(stringLiteral: "zh-Hans"),
"SWIFT_EMIT_LOC_STRINGS": SettingValue(stringLiteral: "YES"),
"MARKETING_VERSION": SettingValue(stringLiteral: appVersion),
"CURRENT_PROJECT_VERSION": SettingValue(stringLiteral: buildVersion)
],
configurations: [
.debug(name: "Debug"),
Expand All @@ -40,6 +44,8 @@ let project = Project(
"NSHumanReadableCopyright": "Copyright © 2024 ygsgdbd. All rights reserved.",
"LSApplicationCategoryType": "public.app-category.utilities",
"LSMinimumSystemVersion": "13.0",
"CFBundleShortVersionString": .string(appVersion), // 市场版本号
"CFBundleVersion": .string(buildVersion), // 构建版本号
// 添加开机启动所需权限
"NSAppleEventsUsageDescription": "需要此权限以管理开机启动设置。",
"com.apple.security.automation.apple-events": true
Expand Down

0 comments on commit 3cab19c

Please sign in to comment.