Created
September 21, 2016 08:10
-
-
Save mcany/b207c18c5ea26f6d1d81d074888f2e1a to your computer and use it in GitHub Desktop.
This file contains 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
# Customise this file, documentation can be found here: | |
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs | |
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md | |
# can also be listed using the `fastlane actions` command | |
# Change the syntax highlighting to Ruby | |
# All lines starting with a # are ignored when running `fastlane` | |
# If you want to automatically update fastlane if a new version is available: | |
# update_fastlane | |
# This is the minimum version number required. | |
# Update this, if you use features of a newer version | |
require 'active_support/time' | |
fastlane_version "1.103.0" | |
default_platform :ios | |
platform :ios do | |
before_all do | |
#ensure_git_status_clean | |
clean_build_artifacts | |
clear_derived_data | |
FileUtils::mkdir_p '../build' | |
sh "git log --pretty=format:'+ %s' -n 14 | grep -v 'Merge\\|release\\|Update circle\\|Update build' > ../build/change.log" | |
ENV['KEYCHAIN_NAME'] = "name-keychain" | |
end | |
######### | |
# LANES # | |
######### | |
desc "Install certificates and provisioning profiles" | |
lane :appStoreCertificates do | |
match( | |
type: "appstore", | |
app_identifier: "<APP_SCHEME>" | |
) | |
# match( | |
# type: "appstore", | |
# app_identifier: "<APP_SCHEME>.Sandbox" | |
# ) | |
match( | |
type: "appstore", | |
app_identifier: "<APP_SCHEME>.watchkitapp" | |
) | |
match( | |
type: "appstore", | |
app_identifier: "<APP_SCHEME>.watchkitapp.watchkitextension" | |
) | |
end | |
def import_certificates | |
return unless Helper.is_ci? # As in my local machine I don't need to import the certificates, only run if it's in the CI | |
create_keychain( | |
name: ENV["KEYCHAIN_NAME"], | |
default_keychain: true, | |
unlock: true, | |
timeout: 3600, | |
lock_when_sleeps: true, | |
password: SecureRandom.base64 | |
) | |
import_certificate( | |
certificate_path: "fastlane/certificates/distribution.p12", | |
certificate_password: ENV['CERT_PASSWORD'], | |
keychain_name: ENV["KEYCHAIN_NAME"] | |
) | |
import_certificate( | |
certificate_path: "fastlane/certificates/ios_distribution.cer", | |
keychain_name: ENV["KEYCHAIN_NAME"] | |
) | |
end | |
desc "Increment the version and build number" | |
lane :version_bump_project do |options| | |
# Set build number to current date and time | |
build_number = Time.now.in_time_zone("Europe/Istanbul").strftime("%Y%m%d%H%M") #Time.new.strftime("%Y%m%d%H%M") | |
ENV["BUILD_NUMBER"] = build_number | |
increment_build_number build_number: build_number | |
# Set version number conforming the bump type | |
if options[:bump_type] | |
increment_version_number bump_type: options[:bump_type] | |
end | |
end | |
desc "Submit a new Beta Build to Fabric with e-mail notifications" | |
lane :beta do |options| | |
# Bump | |
version_bump_project bump_type: options[:bump] | |
# Beta badge app icon | |
badge(dark: true) | |
# Certificates | |
import_certificates | |
#cert | |
sigh(adhoc: true) | |
#match(type: "development") | |
ENV["PROFILE_UDID"] = lane_context[SharedValues::SIGH_UDID] # use the UDID of the newly created provisioning profile | |
puts "Using profile #{ENV["PROFILE_UDID"]}" | |
# Build | |
gym( | |
scheme: "<APP_SCHEME> Sandbox", | |
configuration: "Adhoc", | |
suppress_xcode_output: false, | |
clean: true, | |
include_symbols: true, | |
output_directory: "./build/" | |
) | |
# Upload | |
crashlytics( | |
api_token: '44df048f814d9bac88bd3b8c0957a8051a6be1a0', | |
build_secret: '89001c58cdefc41552a2857bae345346418c416e252a81830a08ab4ed16cd822', | |
notes: "Build at " + ENV["BUILD_NUMBER"], | |
notes_path: 'build/change.log', | |
groups: "all", | |
notifications: true | |
) | |
# Submit to iTunes Connect | |
pilot( | |
skip_submission: true, | |
skip_waiting_for_build_processing: true | |
) | |
clean_build_artifacts | |
end | |
desc "Submit a new Beta Build to Apple TestFlight" | |
desc "This will also make sure the profile is up to date" | |
lane :betaTestflight do |options| | |
# Bump | |
#version_bump_project bump_type: options[:bump] | |
# Provisioning Profile | |
#import_certificates | |
sigh | |
ENV["PROFILE_UDID"] = lane_context[SharedValues::SIGH_UDID] | |
puts "Using profile #{ENV["PROFILE_UDID"]}" | |
## TestFlight Test Version | |
# Build | |
gym( | |
scheme: "<APP_SCHEME> Sandbox", | |
configuration: "Adhoc", | |
clean: true, | |
include_symbols: true, | |
output_directory: "./build/" | |
) | |
# Submit to iTunes Connect | |
pilot( | |
skip_submission: true, | |
skip_waiting_for_build_processing: true | |
) | |
clean_build_artifacts | |
end | |
desc "Deploy a new version to the App Store" | |
lane :release do |options| | |
identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) | |
# Bump | |
#version_bump_project bump_type: options[:bump] | |
# Provisioning Profile | |
#import_certificates | |
#cert | |
#sigh | |
appStoreCertificates | |
#ENV["PROFILE_UDID"] = lane_context[SharedValues::SIGH_UDID] | |
#puts "AppStore UDID: #{ENV["PROFILE_UDID"]}" | |
# Build | |
gym( | |
scheme: "<APP_SCHEME>", | |
export_method: "app-store", | |
suppress_xcode_output: false, | |
) | |
# Submit to iTunes Connect | |
pilot( | |
skip_submission: true, | |
skip_waiting_for_build_processing: true | |
) # Skip the distribution of the app to all beta testers | |
clean_build_artifacts | |
end | |
desc "Deploy a new version to the App Store" | |
lane :localRelease do |options| | |
# Bump | |
version_bump_project bump_type: options[:bump] | |
# Provisioning Profile | |
import_certificates | |
#sigh | |
#ENV["PROFILE_UDID"] = lane_context[SharedValues::SIGH_UDID] | |
# Build | |
gym( | |
scheme: "<APP_SCHEME>", | |
export_method: "app-store", | |
suppress_xcode_output: false, | |
) | |
# Submit to iTunes Connect | |
pilot( | |
skip_submission: true, | |
skip_waiting_for_build_processing: false | |
) # Skip the distribution of the app to all beta testers | |
clean_build_artifacts | |
end | |
after_all do |lane| | |
# This block is called, only if the executed lane was successful | |
notify "Fastlane succeeded '#{lane}'" unless Helper.is_ci? #if I'm running it locally, show a terminal OS X notification | |
# Success | |
build_number = ENV["BUILD_NUMBER"] | |
if build_number | |
#slack(message: "<APP_SCHEME> iOS: build " + build_number + " is ready.") | |
end | |
end | |
error do |lane, exception| | |
notify "Fastlane failed '#{lane}'" unless Helper.is_ci? #if I'm running it locally, show a terminal OS X notification | |
# slack( | |
# message: "<APP_SCHEME> iOS: " + exception.message, | |
# success: false | |
# ) | |
end | |
end | |
# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md | |
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md | |
# fastlane reports which actions are used | |
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment