Last active
October 18, 2016 21:45
-
-
Save richardszalay/b0546b4ec49ae2be118a21fb883e32f7 to your computer and use it in GitHub Desktop.
Creating a Build-Once Deployment Pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/fastlane/fastlane/issues/488 | |
export LANG=en_US.UTF-8 | |
export LANGUAGE=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
# If not using rvm (which will set this for you) | |
export GEM_HOME=~/.gems | |
export PATH=$PATH:~/.gems/bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default_platform :ios | |
platform :ios do | |
desc "Run unit tests" | |
lane :test do | |
begin | |
scan( | |
scheme: "MyApp", | |
device: "iPhone 5 (9.1)", | |
output_types: "junit" | |
) | |
ensure | |
#rename it so CI can find it | |
sh "mv test_output/report.junit test_output/report.xml" | |
end | |
end | |
desc "Build an unsigned IPA artifact" | |
lane :build do | |
test | |
gym( | |
output_directory: "./fastlane/build", | |
scheme: "MyApp", | |
configuration: "Release", | |
use_legacy_build_api: true, | |
xcargs: "CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=''" | |
) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'fastlane', '~> 1.100.0' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle install | |
bundle exec fastlane ios build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Probably best set by your build server | |
export MATCH_PASSWORD=WWWW | |
export FL_HOCKEY_API_TOKEN=XXXX | |
export DELIVER_USERNAME=YYYY | |
export DELIVER_PASSWORD=ZZZZ | |
bundle install | |
bundle exec fastlane ios release_appstore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spare_keys' | |
default_platform :ios | |
platform :ios do | |
CERTIFICATES_REPOSITORY = "[email protected]:path/to/certificates-repository.git" | |
QA_APP_IDENTIFIER = "com.richardszalay.demo.qa" | |
APPSTORE_APP_IDENTIFIER = "com.richardszalay.demo" | |
desc "Updates distribution signing identities and provisioning profiles" | |
lane :update_certs do |options| | |
match( | |
type: "adhoc", | |
git_url: CERTIFICATES_REPOSITORY, | |
app_identifier: QA_APP_IDENTIFIER, | |
readonly: false | |
) | |
match( | |
type: "appstore", | |
git_url: CERTIFICATES_REPOSITORY, | |
app_identifier: APPSTORE_APP_IDENTIFIER, | |
readonly: false | |
) | |
end | |
desc "Releases a build to HockeyApp. Requires that MATCH_PASSWORD and FL_HOCKEY_API_TOKEN are set." | |
lane :release_hockey do |options| | |
release( | |
ipa: options[:ipa], | |
app_identifier: QA_APP_IDENTIFIER, | |
match_type: "adhoc", | |
demo_environment_value: "QA!" | |
) | |
end | |
desc "Releases a build to iTunes. Requires that MATCH_PASSWORD, FL_HOCKEY_API_TOKEN, DELIVER_USERNAME, and DELIVER_PASSWORD are set." | |
lane :release_appstore do |options| | |
release( | |
ipa: options[:ipa], | |
app_identifier: APPSTORE_APP_IDENTIFIER, | |
match_type: "appstore", | |
demo_environment_value: "AppStore!" | |
) | |
end | |
private_lane :release do |options| | |
is_appstore_release = (options[:match_type] == "app_store") | |
act( | |
ipa: options[:ipa], | |
plist_values: { | |
":DemoEnvironmentValue" => options[:demo_environment_value] | |
} | |
) | |
SpareKeys.temp_keychain(true) { |temp_keychain_path, keychain_password| | |
match( | |
type: options[:match_type], | |
git_url: CERTIFICATES_REPOSITORY, | |
app_identifier: options[:app_identifier], | |
keychain_name: temp_keychain_path, | |
readonly: true | |
) | |
`security set-key-partition-list -S apple-tool:,apple: -k "#{keychain_password}" #{temp_keychain_path}` if requires_key_partition_list | |
resign( | |
ipa: options[:ipa], | |
provisioning_profile: match_result_provisioning_profile(options[:app_identifier], options[:match_type]) | |
) | |
} | |
# We always release to hockey for the symbolised crash logs | |
hockey( | |
ipa: options[:ipa], | |
upload_dsym_only: is_appstore_release | |
) | |
deliver( | |
ipa: options[:ipa], | |
skip_screenshots: true, | |
skip_metadata: true, | |
submit_for_review: false, | |
automatic_release: false | |
) if is_appstore_release | |
end | |
def match_result_provisioning_profile(app_identifier, match_type) | |
sigh_profile_key = "sigh_#{app_identifier}_#{match_type}" | |
return { | |
app_identifier => File.join(FastlaneCore::ProvisioningProfile.profiles_path, "#{ENV[sigh_profile_key]}.mobileprovision") | |
} | |
end | |
def requires_key_partition_list() | |
osVersion = `sysctl -n kern.osrelease` | |
majorOsVersion = Integer(osVersion.split('.')[0]) | |
return majorOsVersion >= 16 # Sierra | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'fastlane', '~> 1.100.0' | |
gem 'spare_keys', '~> 1.1.1' | |
# This is automatically added by `fastlane add_plugin act` | |
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') | |
eval(File.read(plugins_path), binding) if File.exist?(plugins_path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Probably best set by your build server | |
export MATCH_PASSWORD=WWWW | |
export FL_HOCKEY_API_TOKEN=XXXX | |
bundle install | |
bundle exec fastlane ios release_appstore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment