Last active
February 5, 2018 22:28
-
-
Save snowtema/6d80c983d01da0f613ace8564ef2c55f to your computer and use it in GitHub Desktop.
Continuous Integration for iOS development with Bitrise CI + Fastlane + Slack
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
--- | |
format_version: '4' | |
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | |
project_type: ios | |
trigger_map: | |
- push_branch: develop | |
workflow: Develop | |
- push_branch: master | |
workflow: Release | |
workflows: | |
Develop: | |
steps: | |
- [email protected]: | |
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}' | |
- git-clone: {} | |
- [email protected]: | |
title: Do anything with Script step | |
- [email protected]: | |
inputs: | |
- lane: ios dev | |
Release: | |
steps: | |
- [email protected]: | |
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}' | |
- git-clone: {} | |
- [email protected]: | |
title: Do anything with Script step | |
- [email protected]: | |
inputs: | |
- lane: ios release | |
app: | |
envs: | |
- opts: | |
is_expand: false | |
BITRISE_PROJECT_PATH: {PROJECT_NAME}.xcworkspace | |
- opts: | |
is_expand: false | |
BITRISE_SCHEME: {PROJECT_SCHEME} | |
- CERT_GIT_URL: {GIT_URL_TO_CERT_STORE} | |
opts: | |
is_expand: false | |
- CRASHLYTICS_API_TOKEN: {CRASHLYTICS_API_TOKEN} | |
opts: | |
is_expand: false | |
- CRASHLYTICS_BUILD_SECRET: {CRASHLYTICS_BUILD_SECRET} | |
opts: | |
is_expand: false | |
- APPLE_ID_USERNAME: {ITUNES_USERNAME} # iTunesConnect username (email), f.e. [email protected] | |
opts: | |
is_expand: false | |
- APPLE_APP_ID: com.appzavr.test_app | |
opts: | |
is_expand: false | |
- opts: | |
is_expand: false | |
SLACK_URL: {SLACK_URL} | |
- opts: | |
is_expand: false | |
FASTLANE_TEAM_ID: {APPLE_TEAM_ID} # Apple developer team ID, f.e F237Q28E | |
- PROJECT_NAME: {PROJECT_NAME} |
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
# fastlane_version "2.63.0" # Better to use new version | |
default_platform :ios | |
platform :ios do | |
before_all do | |
update_fastlane | |
if !is_ci | |
# ensure_git_status_clean | |
end | |
cocoapods(use_bundle_exec: !is_ci) | |
end | |
after_all do | |
end | |
error do |lane, exception| | |
if is_ci | |
slack( | |
message: "'#{exception.message}'. Fastlane '#{lane}' errored", | |
success: false | |
) | |
end | |
end | |
# Public lane | |
lane :dev do | |
fabric(scheme: ENV['BITRISE_SCHEME']) | |
end | |
lane :_testflight do | |
itc_testflight(scheme: ENV['BITRISE_SCHEME']) | |
end | |
lane :release do | |
itc(scheme: ENV['BITRISE_SCHEME']) | |
end | |
# Private lane | |
private_lane :fabric do |options| | |
increment_build_number_in_plist( | |
build_number: ENV['BITRISE_BUILD_NUMBER'] | |
) | |
scheme = options[:scheme] | |
project_name = ENV['PROJECT_NAME'] | |
match( | |
type: "adhoc", | |
git_url: ENV['CERT_GIT_URL'], | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
force: true | |
) | |
cert( | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'] | |
) | |
sigh( | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'], | |
skip_install: true, | |
adhoc: true, | |
# development: true | |
) | |
build(configuration: "Beta", method: "ad-hoc") | |
environment = scheme.upcase | |
crashlytics( | |
ipa_path: "../#{project_name}.ipa", | |
notes: "Running on #{environment}", | |
groups: ["Appzavr-iOS"] | |
) | |
rocket | |
post_to_slack(scheme: scheme, destination: "Crashlytics") | |
if !is_ci | |
clean_build_artifacts | |
commit_version | |
push_to_git_remote | |
end | |
end | |
private_lane :itc_testflight do |options| | |
scheme = options[:scheme] | |
project_name = ENV['PROJECT_NAME'] | |
match( | |
type: "appstore", | |
git_url: ENV['CERT_GIT_URL'], | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
force: true | |
) | |
cert( | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'] | |
) | |
sigh( | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'], | |
skip_install: true, | |
development: false, | |
) | |
build(configuration: "Release", method: "app-store") | |
pilot( | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'], | |
ipa: "../#{project_name}.ipa", | |
skip_submission: true, | |
skip_waiting_for_build_processing: true | |
) | |
rocket | |
post_to_slack(scheme: scheme, destination: "TestFlight") | |
clean_build_artifacts | |
commit_version | |
end | |
private_lane :itc do |options| | |
# ensure_git_branch(branch: 'master') | |
scheme = options[:scheme] | |
project_name = ENV['PROJECT_NAME'] | |
match( | |
type: "appstore", | |
git_url: ENV['CERT_GIT_URL'], | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
force: true | |
) | |
cert( | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'] | |
) | |
sigh( | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'], | |
skip_install: true, | |
development: false, | |
) | |
build(configuration: "Release", method: "app-store") | |
deliver( | |
app_identifier: ENV['APPLE_APP_ID'], | |
username: ENV['APPLE_ID_USERNAME'], | |
team_id: ENV['FASTLANE_TEAM_ID'], | |
force: true | |
) | |
rocket | |
post_to_slack(scheme: scheme, destination: "iTunes Connect") | |
if !is_ci | |
clean_build_artifacts | |
commit_version | |
add_tag_and_push | |
end | |
end | |
# Util lane | |
private_lane :build do |options| | |
configuration = options[:configuration] | |
method = options[:method] | |
project_name = ENV['PROJECT_NAME'] | |
gym( | |
scheme: ENV['BITRISE_SCHEME'], | |
configuration: "#{configuration}", | |
workspace: ENV['BITRISE_PROJECT_PATH'], | |
output_directory: "../", | |
output_name: "#{project_name}.ipa", | |
export_method: "#{method}", | |
export_xcargs: "-allowProvisioningUpdates" | |
) | |
end | |
private_lane :post_to_slack do |options| | |
scheme = options[:scheme] | |
project_name = ENV['PROJECT_NAME'] | |
version = get_version_number_from_plist | |
build = get_build_number_from_plist | |
environment = scheme.upcase | |
destination = options[:destination] | |
slack( | |
message: "New :ios: *#{version}* (#{build}) running `#{environment}` has been submitted to *#{destination}* :rocket:", | |
) | |
end | |
private_lane :commit_version do | |
project_name = ENV['PROJECT_NAME'] | |
version = get_version_number_from_plist | |
build = get_build_number_from_plist | |
commit_version_bump( | |
message: "Build v.#{version}(#{build})", | |
force: true | |
) | |
end | |
private_lane :add_tag_and_push do | |
project_name = ENV['PROJECT_NAME'] | |
version = get_version_number_from_plist | |
add_git_tag(tag: version) | |
push_git_tags | |
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 "cocoapods" | |
gem "fastlane" | |
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') | |
eval_gemfile(plugins_path) 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
# Autogenerated by fastlane | |
# | |
# Ensure this file is checked in to source control! | |
gem 'fastlane-plugin-versioning' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment