Skip to content

Instantly share code, notes, and snippets.

@richardszalay
Last active October 18, 2016 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardszalay/b0546b4ec49ae2be118a21fb883e32f7 to your computer and use it in GitHub Desktop.
Save richardszalay/b0546b4ec49ae2be118a21fb883e32f7 to your computer and use it in GitHub Desktop.
Creating a Build-Once Deployment Pipeline
# 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
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
source 'https://rubygems.org'
gem 'fastlane', '~> 1.100.0'
bundle install
bundle exec fastlane ios build
# 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
require 'spare_keys'
default_platform :ios
platform :ios do
CERTIFICATES_REPOSITORY = "git@server.com: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
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)
# 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