ci: fix iOS signing, use same keychain name
Using different temporary keychains does not work if we do not set `default_keychain=true`, because `codesign` then can't find the cert: ``` error: No signing certificate "iOS Distribution" found: No "iOS Distribution" signing certificate matching team ID ``` But if we set `default_keychain=true` then we cause a race condition when the keychain is deleted by a parallel job while another is using it as its default. For this reason we have to use a static keychain name and keep it between builds. I tried disabling `default_keychain=true` in #11378 but it worked only because the default user keychain already had the cert. Signed-off-by: Jakub Sokołowski <jakub@status.im> Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
dbabcc223e
commit
0b8c673094
|
@ -1,4 +1,4 @@
|
|||
library 'status-react-jenkins@v1.2.6'
|
||||
library 'status-react-jenkins@v1.2.5'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
library 'status-react-jenkins@v1.2.6'
|
||||
library 'status-react-jenkins@v1.2.5'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
library 'status-react-jenkins@v1.2.6'
|
||||
library 'status-react-jenkins@v1.2.5'
|
||||
|
||||
pipeline {
|
||||
agent { label 'macos-xcode-11.5' }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
library 'status-react-jenkins@v1.2.6'
|
||||
library 'status-react-jenkins@v1.2.5'
|
||||
|
||||
pipeline {
|
||||
agent { label params.AGENT_LABEL }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
library 'status-react-jenkins@v1.2.6'
|
||||
library 'status-react-jenkins@v1.2.5'
|
||||
|
||||
pipeline {
|
||||
agent { label 'macos' }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
library 'status-react-jenkins@v1.2.6'
|
||||
library 'status-react-jenkins@v1.2.5'
|
||||
|
||||
pipeline {
|
||||
agent { label 'linux' }
|
||||
|
|
|
@ -69,36 +69,30 @@ def upload_to_saucelabs(file)
|
|||
end
|
||||
end
|
||||
|
||||
# Helper which acts like a Python context manager
|
||||
def with(ctx)
|
||||
yield ctx.setup
|
||||
ensure
|
||||
ctx.teardown
|
||||
end
|
||||
|
||||
# Creates temporary keychain for build duration
|
||||
# Creates and unlocks a keychain into which Fastlane match imports signing keys and certs.
|
||||
class Keychain
|
||||
attr_accessor :name, :path, :pass
|
||||
attr_accessor :name, :pass
|
||||
|
||||
def initialize(name)
|
||||
# We use epoch time to void clashes with CI builds
|
||||
@name = "#{name}_#{Time.now.to_f}.keychain-db"
|
||||
@path = "~/Library/Keychains/#{@name}"
|
||||
@pass = rand().to_s
|
||||
# Local devs will not have KEYCHAIN_PASSWORD set, and will be prompted for password.
|
||||
return "login.keychain-db" unless ENV['KEYCHAIN_PASSWORD']
|
||||
# We user the same keychain every time because we need to set a default.
|
||||
@name = "#{name}.keychain-db"
|
||||
@pass = ENV['KEYCHAIN_PASSWORD']
|
||||
Fastlane::Actions::CreateKeychainAction.run(
|
||||
name: @name,
|
||||
password: @pass,
|
||||
unlock: true,
|
||||
# Fastlane can't find the signing cert without setting a default.
|
||||
default_keychain: true,
|
||||
# Deleting the keychain would cause race condition for parallel jobs.
|
||||
require_create: false,
|
||||
# Lock it up after 25 minutes just in case we don't delete it.
|
||||
timeout: 1500,
|
||||
# Setting a default can cause a race condition with parallel jobs.
|
||||
default_keychain: false,
|
||||
lock_when_sleeps: true,
|
||||
lock_after_timeout: true,
|
||||
timeout: 1500
|
||||
)
|
||||
end
|
||||
|
||||
# for use in with()
|
||||
def setup; self end
|
||||
def teardown; Fastlane::Actions::DeleteKeychainAction.run(name: @name) end
|
||||
end
|
||||
|
||||
# builds an ios app with ad-hoc configuration and put it
|
||||
|
@ -115,7 +109,8 @@ def build_ios_adhoc(readonly: false, pr_build: false)
|
|||
scheme = pr_build ? 'StatusImPR' : 'StatusIm'
|
||||
app_id = pr_build ? 'im.status.ethereum.pr' : 'im.status.ethereum'
|
||||
|
||||
with Keychain.new('adhoc') do |kc|
|
||||
kc = Keychain.new('fastlane')
|
||||
|
||||
match(
|
||||
type: 'adhoc',
|
||||
readonly: readonly,
|
||||
|
@ -141,7 +136,6 @@ def build_ios_adhoc(readonly: false, pr_build: false)
|
|||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# builds an ios app with e2e configuration and put it
|
||||
|
@ -151,7 +145,8 @@ def build_ios_e2e
|
|||
showsdks_output = sh('xcodebuild', '-showsdks')
|
||||
simulator_sdk = showsdks_output.scan(/iphonesimulator\d\d?\.\d\d?/).first
|
||||
|
||||
with Keychain.new('adhoc') do |kc|
|
||||
kc = Keychain.new('fastlane')
|
||||
|
||||
match(
|
||||
type: 'adhoc',
|
||||
readonly: true,
|
||||
|
@ -181,7 +176,6 @@ def build_ios_e2e
|
|||
# ...and we don't need an .ipa file for them, because we use .app directly
|
||||
skip_package_ipa: true
|
||||
)
|
||||
end
|
||||
|
||||
zip(
|
||||
path: 'status-ios/Build/Products/Release-iphonesimulator/StatusIm.app',
|
||||
|
@ -231,7 +225,8 @@ platform :ios do
|
|||
|
||||
desc '`fastlane ios release` builds a release & uploads it to TestFlight'
|
||||
lane :release do
|
||||
with Keychain.new('adhoc') do |kc|
|
||||
kc = Keychain.new('fastlane')
|
||||
|
||||
match(
|
||||
type: 'appstore',
|
||||
readonly: true,
|
||||
|
@ -254,7 +249,6 @@ platform :ios do
|
|||
"ITSAppUsesNonExemptEncryption": false
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
upload_to_testflight(
|
||||
ipa: 'status-ios/StatusIm.ipa',
|
||||
|
|
Loading…
Reference in New Issue