Add TestFlight release automation

This commit is contained in:
2026-07-27 16:52:14 -07:00
parent 584d63bfe7
commit fef3404e96
11 changed files with 556 additions and 4 deletions

5
.env.example Normal file
View File

@@ -0,0 +1,5 @@
APP_STORE_CONNECT_KEY_ID=
APP_STORE_CONNECT_ISSUER_ID=
APP_STORE_CONNECT_KEY_CONTENT=
MATCH_PASSWORD=
MATCH_GIT_BASIC_AUTHORIZATION=

View File

@@ -0,0 +1,48 @@
name: TestFlight
on:
push:
tags:
- "release/v*.*.*"
jobs:
release:
name: Build and upload
runs-on: macos-arm64
timeout-minutes: 90
defaults:
run:
shell: bash
steps:
- name: Check out the release tag
uses: actions/checkout@v4
- name: Verify the Apple build toolchain
run: |
export PATH="/Users/runner/hostedtoolcache/Ruby/3.3.11/arm64/bin:${PATH}"
ruby --version
bundle --version
xcodebuild -version
- name: Install Fastlane
run: |
export PATH="/Users/runner/hostedtoolcache/Ruby/3.3.11/arm64/bin:${PATH}"
bundle config set --local path "$HOME/.bundle/xion-control-panel"
bundle install --jobs 4 --retry 3
- name: Build and upload to TestFlight
env:
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_KEY_CONTENT: ${{ secrets.APP_STORE_CONNECT_KEY_CONTENT }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
RELEASE_TAG: ${{ github.ref_name }}
GITEA_BUILD_NUMBER: ${{ github.run_number }}
FASTLANE_SKIP_UPDATE_CHECK: "1"
FASTLANE_HIDE_CHANGELOG: "1"
FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: "120"
run: |
export PATH="/Users/runner/hostedtoolcache/Ruby/3.3.11/arm64/bin:${PATH}"
bundle exec fastlane ios release

12
.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
.DS_Store
.env
.env.*
!.env.example
.bundle/
build/
vendor/bundle/
fastlane/Preview.html
fastlane/report.xml
fastlane/screenshots/
fastlane/test_output/

3
Gemfile Normal file
View File

@@ -0,0 +1,3 @@
source "https://rubygems.org"
gem "fastlane", "2.237.0"

245
Gemfile.lock Normal file
View File

@@ -0,0 +1,245 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.8)
abbrev (0.1.2)
addressable (2.9.0)
public_suffix (>= 2.0.2, < 8.0)
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.4.0)
aws-partitions (1.1274.0)
aws-sdk-core (3.254.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
base64
bigdecimal
jmespath (~> 1, >= 1.6.1)
logger
aws-sdk-kms (1.130.0)
aws-sdk-core (~> 3, >= 3.254.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.228.1)
aws-sdk-core (~> 3, >= 3.254.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.12.1)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.1.2)
claide (1.1.0)
colored (1.2)
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
csv (3.3.6)
declarative (0.0.20)
digest-crc (0.7.0)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20240107)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (1.6.0)
logger
faraday (1.10.6)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.8)
faraday (>= 0.8.0)
http-cookie (>= 1.0.0)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.1)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.2.0)
multipart-post (~> 2.0)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.4)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.4.1)
fastlane (2.237.0)
CFPropertyList (>= 2.3, < 5.0.0)
abbrev (~> 0.1)
addressable (>= 2.9.0, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.197)
babosa (>= 1.0.3, < 2.0.0)
base64 (~> 0.2)
benchmark (>= 0.1.0)
bundler (>= 2.4.0, < 5.0.0)
colored (~> 1.2)
commander (~> 4.6)
csv (~> 3.3)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
excon (>= 0.71.0, < 2.0.0)
faraday (~> 1.0)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
fastlane-sirp (>= 1.1.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-env (>= 1.6.0, < 2.3.0)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
http-cookie (~> 1.0.5)
json (< 3.0.0)
jwt (>= 2.10.3, < 4)
logger (>= 1.6, < 2.0)
mini_magick (>= 4.9.4, < 5.0.0)
multi_json (~> 1.12)
multipart-post (>= 2.0.0, < 3.0.0)
mutex_m (~> 0.3)
naturally (~> 2.2)
nkf (~> 0.2)
optparse (>= 0.1.1, < 1.0.0)
ostruct (>= 0.1.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.5)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 3)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.4.1)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-sirp (1.1.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.106.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-core (0.18.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 1.9)
httpclient (>= 2.8.3, < 3.a)
mini_mime (~> 1.0)
mutex_m
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
google-apis-iamcredentials_v1 (0.28.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-playcustomapp_v1 (0.18.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-storage_v1 (0.65.0)
google-apis-core (>= 0.15.0, < 2.a)
google-cloud-core (1.9.0)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.2.2)
base64 (~> 0.2)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.7.0)
google-cloud-storage (1.62.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (>= 0.18, < 2)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (>= 0.42)
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
mini_mime (~> 1.0)
google-logging-utils (0.2.0)
googleauth (1.17.2)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.2)
google-logging-utils (~> 0.1)
jwt (>= 1.4, < 4.0)
os (>= 0.9, < 2.0)
pstore (~> 0.1)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.9.0)
mutex_m
jmespath (1.6.2)
json (2.21.1)
jwt (3.2.0)
base64
logger (1.7.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
multi_json (1.21.1)
multipart-post (2.4.1)
mutex_m (0.3.0)
nanaimo (0.4.0)
naturally (2.3.0)
nkf (0.3.0)
optparse (0.8.1)
os (1.1.4)
ostruct (0.6.3)
plist (3.7.2)
pstore (0.2.1)
public_suffix (7.0.5)
rake (13.4.2)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.8.0)
rexml (3.4.4)
rouge (3.28.0)
ruby2_keywords (0.0.5)
rubyzip (2.4.1)
security (0.1.5)
signet (0.22.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 4.0)
simctl (1.6.10)
CFPropertyList
naturally
terminal-notifier (2.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
trailblazer-option (0.1.2)
tty-cursor (0.7.1)
tty-screen (0.8.2)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.28.1)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
base64
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
nkf
rexml (>= 3.3.6, < 4.0)
xcpretty (0.4.1)
rouge (~> 3.28.0)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
PLATFORMS
arm64-darwin-23
ruby
DEPENDENCIES
fastlane (= 2.237.0)
BUNDLED WITH
2.5.23

View File

@@ -18,7 +18,7 @@ For a Simulator launch from the command line:
```sh ```sh
SIMCTL_CHILD_HOME_ASSISTANT_ACCESS_TOKEN='token' \ SIMCTL_CHILD_HOME_ASSISTANT_ACCESS_TOKEN='token' \
xcrun simctl launch booted com.zanneth.XIONControlPanel xcrun simctl launch booted net.buzzert.XaibatsuControlPanel
``` ```
The client disconnects cleanly when the app resigns active, reconnects and The client disconnects cleanly when the app resigns active, reconnects and
@@ -40,3 +40,24 @@ xcodebuild -project XIONControlPanel.xcodeproj \
-only-testing:XIONControlPanelTests/HomeAssistantIntegrationTests \ -only-testing:XIONControlPanelTests/HomeAssistantIntegrationTests \
test test
``` ```
TestFlight releases
--------------------------------------------------------------------------------
Gitea Actions publishes tags named `release/vX.X.X` to TestFlight. The semantic
version from the tag and the Gitea `GITHUB_RUN_NUMBER` are written into the
app's Info.plist before it is archived. For example:
```sh
git tag -a release/v2.0.0 -m 'Release 2.0.0'
git push origin release/v2.0.0
```
The workflow uses the `macos-arm64` runner and Fastlane Match. It expects these
repository Actions secrets:
- `APP_STORE_CONNECT_KEY_ID`
- `APP_STORE_CONNECT_ISSUER_ID`
- `APP_STORE_CONNECT_KEY_CONTENT`
- `MATCH_PASSWORD`
- `MATCH_GIT_BASIC_AUTHORIZATION`

View File

@@ -585,8 +585,8 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Distribution";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 3; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = DQQH5H6GBD; DEVELOPMENT_TEAM = DQQH5H6GBD;
INFOPLIST_FILE = "$(SRCROOT)/XIONControlPanel/SupportingFiles/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/XIONControlPanel/SupportingFiles/Info.plist";
@@ -596,7 +596,7 @@
PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.XaibatsuControlPanel; PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.XaibatsuControlPanel;
PRODUCT_NAME = XION; PRODUCT_NAME = XION;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "match AppStore net.buzzert.XaibatsuControlPanel";
SWIFT_OBJC_BRIDGING_HEADER = "XIONControlPanel/SupportingFiles/XIONControlPanel-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "XIONControlPanel/SupportingFiles/XIONControlPanel-Bridging-Header.h";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";

2
fastlane/Appfile Normal file
View File

@@ -0,0 +1,2 @@
app_identifier("net.buzzert.XaibatsuControlPanel")
team_id("DQQH5H6GBD")

170
fastlane/Fastfile Normal file
View File

@@ -0,0 +1,170 @@
require "shellwords"
default_platform(:ios)
APP_IDENTIFIER = "net.buzzert.XaibatsuControlPanel"
TEAM_ID = "DQQH5H6GBD"
ROOT_DIR = File.expand_path("..", __dir__)
PROJECT = File.join(ROOT_DIR, "XIONControlPanel.xcodeproj")
SCHEME = "XIONControlPanel"
INFO_PLIST = "XIONControlPanel/SupportingFiles/Info.plist"
ARCHIVE_PATH = File.join(ROOT_DIR, "build/XaibatsuControlPanel.xcarchive")
IPA_PATH = File.join(ROOT_DIR, "build/XaibatsuControlPanel.ipa")
PROFILE_NAME = "match AppStore #{APP_IDENTIFIER}"
CI_KEYCHAIN_NAME = "xaibatsu_control_panel_ci_keychain"
CI_KEYCHAIN_PASSWORD = "xaibatsu-control-panel-ci-keychain-password"
CI_KEYCHAIN_DB_PATH = File.expand_path("~/Library/Keychains/#{CI_KEYCHAIN_NAME}-db")
def present?(value)
!value.to_s.strip.empty?
end
def ci?
present?(ENV["CI"])
end
def read_plist_value(path, key)
Fastlane::Actions.sh(
"/usr/bin/plutil -extract #{key.shellescape} raw #{path.shellescape}",
log: false
).strip
end
def app_store_connect_key
app_store_connect_api_key(
key_id: ENV.fetch("APP_STORE_CONNECT_KEY_ID"),
issuer_id: ENV.fetch("APP_STORE_CONNECT_ISSUER_ID"),
key_content: ENV.fetch("APP_STORE_CONNECT_KEY_CONTENT"),
is_key_content_base64: true,
duration: 1_200,
in_house: false
)
end
def release_metadata
tag = ENV["RELEASE_TAG"] || ENV["GITHUB_REF_NAME"]
match = tag&.match(%r{\Arelease/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\z})
UI.user_error!("Expected a release tag in the form release/vX.X.X; got #{tag.inspect}") unless match
build_number = ENV["GITEA_BUILD_NUMBER"] || ENV["GITHUB_RUN_NUMBER"]
unless build_number&.match?(/\A[1-9]\d*\z/)
UI.user_error!("The Gitea run number must be a positive integer; got #{build_number.inspect}")
end
{
version: "#{match[1]}.#{match[2]}.#{match[3]}",
build_number: build_number
}
end
platform :ios do
# Keep this app's unlocked signing identity first in the shared runner's
# keychain search list. Other projects use the same distribution identity,
# and their locked keychains can otherwise shadow this one.
private_lane :prepare_ci_keychain do
next unless ci?
delete_keychain(name: CI_KEYCHAIN_NAME) if File.file?(CI_KEYCHAIN_DB_PATH)
create_keychain(
name: CI_KEYCHAIN_NAME,
password: CI_KEYCHAIN_PASSWORD,
unlock: true,
timeout: 3_600,
add_to_search_list: false
)
other_keychains = sh("security list-keychains -d user", log: false)
.scan(/"([^"]+)"/)
.flatten
.reject { |path| path.include?(CI_KEYCHAIN_NAME) }
sh("security list-keychains -d user -s #{([CI_KEYCHAIN_DB_PATH] + other_keychains).shelljoin}")
ENV["MATCH_KEYCHAIN_NAME"] = CI_KEYCHAIN_NAME
ENV["MATCH_KEYCHAIN_PASSWORD"] = CI_KEYCHAIN_PASSWORD
end
desc "Create or renew the App Store provisioning profile in the Match repository"
lane :prepare_signing do
match(
type: "appstore",
app_identifier: APP_IDENTIFIER,
team_id: TEAM_ID,
api_key: app_store_connect_key,
readonly: false
)
end
desc "Build a release tag and upload it to TestFlight"
lane :release do |options|
metadata = release_metadata
api_key = app_store_connect_key
prepare_ci_keychain
match(
type: "appstore",
app_identifier: APP_IDENTIFIER,
team_id: TEAM_ID,
api_key: api_key,
readonly: true
)
update_info_plist(
plist_path: INFO_PLIST,
block: proc do |plist|
plist["CFBundleShortVersionString"] = metadata[:version]
plist["CFBundleVersion"] = metadata[:build_number]
end
)
stamped_version = get_info_plist_value(path: INFO_PLIST, key: "CFBundleShortVersionString").to_s
stamped_build = get_info_plist_value(path: INFO_PLIST, key: "CFBundleVersion").to_s
UI.user_error!("Failed to stamp the release version") unless stamped_version == metadata[:version]
UI.user_error!("Failed to stamp the Gitea build number") unless stamped_build == metadata[:build_number]
build_app(
project: PROJECT,
scheme: SCHEME,
configuration: "Release",
clean: true,
archive_path: ARCHIVE_PATH,
output_directory: File.dirname(IPA_PATH),
output_name: File.basename(IPA_PATH),
export_method: "app-store",
export_options: {
signingStyle: "manual",
provisioningProfiles: {
APP_IDENTIFIER => PROFILE_NAME
},
manageAppVersionAndBuildNumber: false
}
)
archived_plist = File.join(
ARCHIVE_PATH,
"Products",
"Applications",
"XION.app",
"Info.plist"
)
archived_version = read_plist_value(archived_plist, "CFBundleShortVersionString")
archived_build = read_plist_value(archived_plist, "CFBundleVersion")
UI.user_error!("Archived version does not match the release tag") unless archived_version == metadata[:version]
UI.user_error!("Archived build does not match Gitea") unless archived_build == metadata[:build_number]
if options[:skip_upload]
UI.important("Skipping the TestFlight upload for local validation")
else
upload_to_testflight(
api_key: api_key,
app_identifier: APP_IDENTIFIER,
ipa: IPA_PATH,
skip_waiting_for_build_processing: true,
uses_non_exempt_encryption: false
)
end
ensure
delete_keychain(name: CI_KEYCHAIN_NAME) if ci? && File.file?(CI_KEYCHAIN_DB_PATH)
end
end

6
fastlane/Matchfile Normal file
View File

@@ -0,0 +1,6 @@
git_url("https://code.buzzert.dev/buzzert/fastlane-match.git")
storage_mode("git")
type("appstore")
app_identifier(["net.buzzert.XaibatsuControlPanel"])
team_id("DQQH5H6GBD")

40
fastlane/README.md Normal file
View File

@@ -0,0 +1,40 @@
fastlane documentation
----
# Installation
Make sure you have the latest version of the Xcode command line tools installed:
```sh
xcode-select --install
```
For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
# Available Actions
## iOS
### ios prepare_signing
```sh
[bundle exec] fastlane ios prepare_signing
```
Create or renew the App Store provisioning profile in the Match repository
### ios release
```sh
[bundle exec] fastlane ios release
```
Build a release tag and upload it to TestFlight
----
This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).