Files

77 lines
2.1 KiB
Plaintext
Raw Permalink Normal View History

2026-07-27 19:38:00 -07:00
require "open3"
def read_plist_value(path, key)
value, _error, status = Open3.capture3(
"/usr/bin/plutil",
"-extract",
key,
"raw",
path
)
UI.user_error!("Unable to read #{key} from the archived app") unless status.success?
value.strip
end
2026-07-27 16:52:14 -07:00
default_platform(:ios)
platform :ios do
desc "Build a release tag and upload it to TestFlight"
2026-07-27 17:04:10 -07:00
lane :beta do
setup_ci
2026-07-27 16:52:14 -07:00
2026-07-27 17:04:10 -07:00
match(type: "appstore")
2026-07-27 16:52:14 -07:00
2026-07-27 17:04:10 -07:00
tag = ENV.fetch("GITHUB_REF_NAME")
version = tag[%r{\Arelease/v(\d+\.\d+\.\d+)\z}, 1]
UI.user_error!("Expected a tag in the form release/vX.X.X; got #{tag.inspect}") unless version
build_number = ENV.fetch("GITHUB_RUN_NUMBER")
UI.user_error!("GITHUB_RUN_NUMBER must be a positive integer") unless build_number.match?(/\A[1-9]\d*\z/)
2026-07-27 16:52:14 -07:00
home_assistant_access_token = ENV["HOME_ASSISTANT_ACCESS_TOKEN"]&.strip
if home_assistant_access_token.to_s.empty?
UI.user_error!("HOME_ASSISTANT_ACCESS_TOKEN must be configured for release builds")
end
2026-07-27 16:52:14 -07:00
update_info_plist(
2026-07-27 17:04:10 -07:00
plist_path: "XIONControlPanel/SupportingFiles/Info.plist",
2026-07-27 16:52:14 -07:00
block: proc do |plist|
2026-07-27 17:04:10 -07:00
plist["CFBundleShortVersionString"] = version
plist["CFBundleVersion"] = build_number
plist["HomeAssistantAccessToken"] = home_assistant_access_token
2026-07-27 16:52:14 -07:00
end
)
2026-07-27 17:04:10 -07:00
api_key = app_store_connect_api_key(
key_id: ENV.fetch("ASC_KEY_ID"),
issuer_id: ENV.fetch("ASC_ISSUER_ID"),
key_content: ENV.fetch("ASC_KEY"),
2026-07-27 17:04:10 -07:00
is_key_content_base64: true
2026-07-27 16:52:14 -07:00
)
2026-07-27 17:04:10 -07:00
build_app(scheme: "XIONControlPanel")
2026-07-27 16:52:14 -07:00
archived_plist = File.join(
lane_context[SharedValues::XCODEBUILD_ARCHIVE],
"Products",
"Applications",
"XION.app",
"Info.plist"
)
2026-07-27 19:38:00 -07:00
archived_access_token = read_plist_value(
archived_plist,
"HomeAssistantAccessToken"
)
unless archived_access_token == home_assistant_access_token
UI.user_error!("The archived app does not contain the configured Home Assistant access token")
end
2026-07-27 17:04:10 -07:00
upload_to_testflight(
api_key: api_key,
skip_waiting_for_build_processing: true,
uses_non_exempt_encryption: false
)
2026-07-27 16:52:14 -07:00
end
end