Last active
April 13, 2016 16:30
-
-
Save wedgybo/76ab4f1eec33a0bc4d8d to your computer and use it in GitHub Desktop.
Fastlane configuration
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 | |
before_all do | |
# ENV["SLACK_URL"] = "https://hooks.slack.com/services/..." | |
# cocoapods | |
# increment_build_number | |
# xctool :test # run the tests of your app | |
end | |
desc "TODO: Work out why the fastlane tools for creating a keychain did not work" | |
private_lane :setup_cert do | |
create_keychain( | |
name: "mallzee.keychain", | |
default_keychain: true, | |
unlock: true, | |
timeout: 3600 | |
) | |
import_certificate keychain_name: "mallzee.keychain", certificate_path: "fastlane/certs/AppleWWDRCA.cer" | |
import_certificate keychain_name: "mallzee.keychain", certificate_path: "fastlane/certs/dist.cer" | |
import_certificate keychain_name: "mallzee.keychain", certificate_path: "fastlane/certs/dist.p12", certificate_password: ENV['CERT_PASSWORD'] | |
import_certificate keychain_name: "mallzee.keychain", certificate_path: "fastlane/certs/dev.cer" | |
import_certificate keychain_name: "mallzee.keychain", certificate_path: "fastlane/certs/dev.p12", certificate_password: ENV['CERT_PASSWORD'] | |
end | |
private_lane :build do |options| | |
get_build_number | |
build_number = lane_context[SharedValues::BUILD_NUMBER].to_i + ENV['TRAVIS_BUILD_NUMBER'].to_i | |
puts "Build ##{build_number} | #{options[:app_identifier]}" | |
puts "Building branch #{ENV['TRAVIS_BRANCH']} #{ENV['CI']}".green | |
# If we're in the CI environment. Update build numbers and rewrite the app name and ID | |
# to match the type of build we're working on. Don't do this on a local build | |
if ENV['CI'] | |
increment_build_number(build_number: build_number) | |
update_info_plist( | |
xcodeproj: "Mallzee.xcodeproj", | |
plist_path: "Mallzee/Info.plist", | |
app_identifier: options[:app_identifier], | |
display_name: options[:app_name] | |
) | |
bundle_id = get_info_plist_value(key: "CFBundleIdentifier", path: "Mallzee/Info.plist") | |
puts "Bundle ID #{bundle_id}".blue | |
end | |
sigh( | |
development: !options[:release], | |
app_identifier: options[:app_identifier] | |
) # Distribution Profile | |
# use the UDID of the newly created provisioning profile | |
ENV["PROFILE_UDID"] = lane_context[SharedValues::SIGH_UDID] | |
ENV["PRODUCT_BUNDLE_IDENTIFIER"] = options[:app_identifier] | |
ENV["PRODUCT_NAME"] = options[:app_name] | |
# Update the projects bundle identifier as changing the plist doesn't cut it | |
# when you are doing it automagically | |
sh "sed -i -e 's/PRODUCT_BUNDLE_IDENTIFIER = com.mallzee.mallzee.*/PRODUCT_BUNDLE_IDENTIFIER = #{ENV['PRODUCT_BUNDLE_IDENTIFIER']};/g' #{ENV['TRAVIS_BUILD_DIR']}/Mallzee.xcodeproj/project.pbxproj" | |
sh "sed -i -e 's/PRODUCT_NAME = Mallzee.*/PRODUCT_NAME = #{ENV['PRODUCT_NAME']};/g' #{ENV['TRAVIS_BUILD_DIR']}/Mallzee.xcodeproj/project.pbxproj" | |
gym(scheme: "Mallzee", clean: true) # Build your app - more options available | |
end | |
private_lane :notify_hockey do | |
hockey_title = lane_context[SharedValues::HOCKEY_BUILD_INFORMATION] | |
hockey_link = lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK] | |
hipchat( | |
message: "[#{hockey_title[:title]}] New build available - #{hockey_link}", | |
message_format: "text", # or "text", defaults to "html" | |
channel: "saloon", | |
success: true | |
) | |
end | |
desc "Runs all the tests" | |
lane :test do | |
# snapshot | |
puts "Running test suite".green | |
xctool :test | |
end | |
desc "Builds a development version of the app" | |
lane :dev do | |
build(release: false, app_identifier: "com.mallzee.mallzee.dev", app_name: "Mallzee:DEV") | |
hockey( | |
release_type: "2", | |
notes_type: "2", | |
# notes: "release_notes", | |
notify: "0" | |
) | |
notify_hockey | |
end | |
desc "Builds a feature branch that is pushed to the main repository" | |
lane :feature do | |
build( | |
release: false, | |
app_identifier: "com.mallzee.mallzee.feature.#{ENV['TRAVIS_BRANCH']}", | |
app_name: "Mallzee:#{ENV['TRAVIS_BRANCH']}" | |
) | |
hockey( | |
release_type: "2", | |
notes_type: "2", | |
# notes: "release_notes", | |
teams: "45883", | |
notify: "0" | |
) | |
notify_hockey | |
end | |
desc "Submit a new Beta Build to Apple TestFlight" | |
desc "This will also make sure the profile is up to date" | |
lane :beta do | |
#snapshot | |
build( | |
release: false, | |
app_identifier: "com.mallzee.mallzee.beta", | |
app_name: "Mallzee:BETA" | |
) | |
hockey( | |
release_type: "0", | |
notes_type: "2", | |
# notes: "release_notes", | |
notify: "0" | |
) | |
# Let everyone know about the latest hockey build | |
notify_hockey | |
# Build this beta again for testflight | |
deploy_beta | |
# sh "your_script.sh" | |
# You can also use other beta testing services here | |
end | |
desc "Deploy a new version to TestFlight" | |
lane :deploy_beta do |options| | |
build( | |
release: true, | |
app_identifier: "com.mallzee.mallzee", | |
app_name: "Mallzee" | |
) | |
pilot(skip_submission: true) | |
hipchat( | |
message: "Beta build of Mallzee has been submitted to TestFlight", | |
message_format: "text", # or "text", defaults to "html" | |
channel: "saloon", | |
success: true | |
) | |
end | |
desc "Deploy a new version to the App Store" | |
desc "** Full Markdown** Support: `code`" | |
lane :deploy do | |
#snapshot | |
#sigh | |
build( | |
release: true, | |
app_identifier: "com.mallzee.mallzee", | |
app_name: "Mallzee" | |
) | |
hockey( | |
release_type: "1", | |
notes_type: "2", | |
# notes: "release_notes", | |
notify: "0" | |
) | |
notify_hockey | |
deliver(skip_deploy: true, force: true) | |
# frameit | |
end | |
# You can define as many lanes as you want | |
desc "Clean up the environment afterward" | |
private_lane :clean do | |
puts "Cleaning up".green | |
end | |
after_all do |lane| | |
# This block is called, only if the executed lane was successful | |
# slack( | |
# message: "Successfully deployed new App Update." | |
# ) | |
hockeyTitle = lane_context[SharedValues::HOCKEY_BUILD_INFORMATION] | |
hockeyLink = lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK] | |
clean | |
end | |
error do |lane, exception| | |
# slack( | |
# message: exception.message, | |
# success: false | |
# ) | |
hipchat( | |
message: exception.message, | |
message_format: "text", # or "text", defaults to "html" | |
channel: "saloon", | |
success: false | |
) | |
clean | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment