Skip to content

Commit be138d3

Browse files
ci: better ruby caching, move tauri versioning logic to fastlane
1 parent 33e2857 commit be138d3

2 files changed

Lines changed: 75 additions & 3 deletions

File tree

.github/workflows/build-ios-app.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ on:
1919
jobs:
2020
build:
2121
runs-on: macos-latest
22+
env:
23+
BUNDLE_FROZEN: "true"
2224
steps:
2325
- name: Checkout repository
2426
uses: actions/checkout@v4
@@ -52,9 +54,6 @@ jobs:
5254
- name: Install npm dependencies
5355
run: npm ci
5456

55-
- name: Initialize iOS project
56-
run: cd src-tauri && npx tauri ios init
57-
5857
- name: Build and upload to TestFlight
5958
run: bundle exec fastlane beta
6059
env:

fastlane/Fastfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,61 @@ end
4343

4444
CI_KEYCHAIN_NAME = "fastlane_ci"
4545
CI_KEYCHAIN_PASSWORD = "fastlane_ci_password"
46+
IOS_INFO_PLIST = "#{ROOT_DIR}/src-tauri/gen/apple/lunch_iOS/Info.plist"
47+
48+
# Get the app version from Cargo.toml
49+
def get_app_version
50+
cargo_toml = File.read("#{ROOT_DIR}/src-tauri/Cargo.toml")
51+
if cargo_toml =~ /^version\s*=\s*"([^"]+)"/
52+
$1
53+
else
54+
"1.0.0"
55+
end
56+
end
57+
58+
# Update iOS build number to be unique for TestFlight
59+
def update_ios_build_number
60+
key = api_key
61+
return unless key
62+
63+
app_version = get_app_version
64+
UI.message("App version from Cargo.toml: #{app_version}")
65+
66+
# Get latest build number from TestFlight for this version
67+
begin
68+
latest_build = latest_testflight_build_number(
69+
api_key: key,
70+
app_identifier: APP_IDENTIFIER,
71+
version: app_version
72+
)
73+
UI.message("Latest TestFlight build number for v#{app_version}: #{latest_build}")
74+
rescue => e
75+
UI.message("No existing builds found for v#{app_version}, starting at 1")
76+
latest_build = 0
77+
end
78+
79+
new_build = latest_build + 1
80+
UI.message("New build number: #{new_build}")
81+
82+
# Update Info.plist with new version and build number
83+
if File.exist?(IOS_INFO_PLIST)
84+
set_info_plist_value(
85+
path: IOS_INFO_PLIST,
86+
key: "CFBundleShortVersionString",
87+
value: app_version
88+
)
89+
set_info_plist_value(
90+
path: IOS_INFO_PLIST,
91+
key: "CFBundleVersion",
92+
value: new_build.to_s
93+
)
94+
UI.success("Updated iOS Info.plist: v#{app_version} (#{new_build})")
95+
else
96+
UI.important("iOS Info.plist not found at #{IOS_INFO_PLIST} - will be created by tauri ios init")
97+
end
98+
99+
new_build
100+
end
46101

47102
# Setup temporary keychain for CI environments
48103
def setup_ci_keychain
@@ -90,6 +145,15 @@ platform :ios do
90145
keychain_password: ENV['CI'] ? CI_KEYCHAIN_PASSWORD : nil
91146
)
92147

148+
# Initialize iOS project if needed (creates Info.plist)
149+
unless File.exist?(XCODEPROJ)
150+
UI.message("Initializing iOS project...")
151+
sh("cd #{ROOT_DIR}/src-tauri && npx tauri ios init")
152+
end
153+
154+
# Update build number to be unique for TestFlight
155+
update_ios_build_number
156+
93157
# Configure Xcode project signing before Tauri build
94158
update_code_signing_settings(
95159
use_automatic_signing: false,
@@ -155,6 +219,15 @@ platform :ios do
155219
keychain_password: ENV['CI'] ? CI_KEYCHAIN_PASSWORD : nil
156220
)
157221

222+
# Initialize iOS project if needed (creates Info.plist)
223+
unless File.exist?(XCODEPROJ)
224+
UI.message("Initializing iOS project...")
225+
sh("cd #{ROOT_DIR}/src-tauri && npx tauri ios init")
226+
end
227+
228+
# Update build number to be unique for App Store
229+
update_ios_build_number
230+
158231
# Configure Xcode project signing before Tauri build
159232
update_code_signing_settings(
160233
use_automatic_signing: false,

0 commit comments

Comments
 (0)