Skip to content

Commit

Permalink
ci: Testflight should connect to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnlauzon committed Apr 25, 2024
1 parent 8905bac commit 3bf03e9
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: iOS binary build & upload

on:
push:
branches: ["main", "dev"]
branches: ["dev"]
pull_request:
branches: ["main", "dev"]
branches: ["dev"]

jobs:
deploy:
Expand Down Expand Up @@ -58,6 +58,7 @@ jobs:
working-directory: ios
run: bundle exec fastlane ios build_upload_testflight
env:
NODE_ENV: development
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
ASC_KEY: ${{ secrets.ASC_PRIVATE_KEY }}
Expand Down
159 changes: 82 additions & 77 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fastlane_require "dotenv"
Dotenv.load ".env.secret"

platform :ios do
# To ensure the generated XCode files match
if is_ci
xcode_select("/Applications/Xcode_15.3.app")
end
Expand All @@ -34,110 +35,114 @@ platform :ios do

desc "Bump build number based on most recent TestFlight build number"
lane :fetch_and_increment_build_number do
#fetch read your app identifier defined in your Appfile
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
#fetch read your app identifier defined in your Appfile
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]

current_version = get_version_number(
target: "OneBoulder"
)
latest_build_number = latest_testflight_build_number(
api_key: api_key,
version: current_version,
app_identifier: app_identifier
)
increment_build_number(
build_number: (latest_build_number + 1),
)
end
current_version = get_version_number(
target: "OneBoulder"
)
latest_build_number = latest_testflight_build_number(
api_key: api_key,
version: current_version,
app_identifier: app_identifier
)
new_build = increment_build_number(
build_number: (latest_build_number + 1),
)
end

desc "Installs signing certificate in the keychain and downloads provisioning profiles from App Store Connect"
lane :prepare_signing do |options|
team_id = CredentialsManager::AppfileConfig.try_fetch_value(:team_id)
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
desc "Installs signing certificate in the keychain and downloads provisioning profiles from App Store Connect"
lane :prepare_signing do |options|
team_id = CredentialsManager::AppfileConfig.try_fetch_value(:team_id)
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]

keychain_name = "signing"
keychain_password = "temp"
keychain_name = "signing"
keychain_password = "temp"

delete_keychain(
name: keychain_name
) if File.exist? File.expand_path("~/Library/Keychains/#{keychain_name}-db")
delete_keychain(
name: keychain_name
) if File.exist? File.expand_path("~/Library/Keychains/#{keychain_name}-db")

create_keychain(
name: keychain_name,
password: keychain_password,
default_keychain: true,
unlock: true,
timeout: 3600
)
create_keychain(
name: keychain_name,
password: keychain_password,
default_keychain: true,
unlock: true,
timeout: 3600
)

import_certificate(
certificate_path: ENV["SIGNING_KEY_FILE_PATH"],
certificate_password: ENV["SIGNING_KEY_PASSWORD"],
keychain_name: keychain_name,
keychain_password: keychain_password,
)
import_certificate(
certificate_path: ENV["SIGNING_KEY_FILE_PATH"],
certificate_password: ENV["SIGNING_KEY_PASSWORD"],
keychain_name: keychain_name,
keychain_password: keychain_password,
)

# fetches and installs provisioning profiles from ASC
sigh(
adhoc: options[:adhoc],
api_key: api_key,
readonly: true
)
end
# fetches and installs provisioning profiles from ASC
sigh(
adhoc: options[:adhoc],
api_key: api_key,
readonly: true
)
end

desc "Build the iOS app for release"
lane :build_release do |options|
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)

profile_name = "one.oneboulder.oneboulder AppStore"
output_name = "OneBoulder-iOS" # specify the name of the .ipa file to generate
export_method = "app-store" # specify the export method
profile_name = "one.oneboulder.oneboulder AppStore"
output_name = "OneBoulder-iOS" # specify the name of the .ipa file to generate
export_method = "app-store" # specify the export method

# turn off automatic signing during build so correct code signing identity is guaranteed to be used
update_code_signing_settings(
use_automatic_signing: false,
targets: ["OneBoulder"], # specify which targets to update code signing settings for
code_sign_identity: "Apple Distribution", # replace with name of code signing identity if different
bundle_identifier: app_identifier,
profile_name: profile_name,
build_configurations: ["Release"] # only toggle code signing settings for Release configurations
)
# turn off automatic signing during build so correct code signing identity is guaranteed to be used
update_code_signing_settings(
use_automatic_signing: false,
targets: ["OneBoulder"], # specify which targets to update code signing settings for
code_sign_identity: "Apple Distribution", # replace with name of code signing identity if different
bundle_identifier: app_identifier,
profile_name: profile_name,
build_configurations: ["Release"] # only toggle code signing settings for Release configurations
)

# build the app
gym(
scheme: "OneBoulder", # replace with name of your project's scheme
output_name: output_name,
configuration: "Release",
export_options: {
method: export_method,
provisioningProfiles: {
app_identifier => profile_name
}
}
)
# build the app
gym(
scheme: "OneBoulder", # replace with name of your project's scheme
output_name: output_name,
configuration: "Release",
export_options: {
method: export_method,
provisioningProfiles: {
app_identifier => profile_name
}
}
)
end

desc "Upload to TestFlight / ASC"
lane :upload_release do
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]

deliver(
api_key: api_key,
skip_screenshots: true,
deliver(
api_key: api_key,
skip_screenshots: true,
skip_metadata: true,
skip_app_version_update: true,
force: true, # skips verification of HTML preview file (since this will be run from a CI machine)
run_precheck_before_submit: false # not supported through ASC API yet
)
skip_app_version_update: true,
force: true, # skips verification of HTML preview file (since this will be run from a CI machine)
run_precheck_before_submit: false # not supported through ASC API yet
)
end

desc "Build and upload to TestFlight"
lane :build_upload_testflight do
ENV['ENVFILE'] = '.env.development'

load_asc_api_key
prepare_signing
fetch_and_increment_build_number
build_release
upload_release

UI.message "Uploaded new build #{lane_context[SharedValues:BUILD_NUMBER]}"
end
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"pod": "cd ios && pod install && cd ..",
"build:android": "cd android && ./gradlew app:assembleRelease && cd ..",
"build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'",
"testflight": "cd ios && NODE_ENV=development bundle exec fastlane beta --env development && cd .."
"testflight": "cd ios && NODE_ENV=development bundle exec fastlane ios build_upload_testflight && cd .."
},
"dependencies": {
"@invertase/react-native-apple-authentication": "^2.3.0",
Expand Down

0 comments on commit 3bf03e9

Please sign in to comment.