Skip to content

Instantly share code, notes, and snippets.

@colinta
Created April 5, 2017 19:29
Show Gist options
  • Save colinta/45dde5b65aaed96532949c2b622644c0 to your computer and use it in GitHub Desktop.
Save colinta/45dde5b65aaed96532949c2b622644c0 to your computer and use it in GitHub Desktop.
require './generate_release_notes'
fastlane_version "1.111.0"
generated_fastfile_id "9dadcd46-3eaf-4291-8129-b3f6f4f4e1ff"
default_platform :ios
before_all do
extract_from_env(
defaults: {
"CERTS_OUTPUT_PATH" => "./certs",
"PROFILE_PATH" => "./fastlane/profiles",
"BUILD_OUTPUT_DIRECTORY" => "./Build",
"BUILD_OUTPUT_NAME" => "Ello.ipa",
"IPA_PATH" => "./Build/Ello.ipa",
"GYM_OUTPUT_DIRECTORY" => "./Build",
"GYM_OUTPUT_NAME" => "Ello.ipa",
"XCODE_PROJECT" => "Ello.xcodeproj",
},
)
end
desc "Download certificates and provisioning profiles"
desc "handy to run if you're having issues with certs & profiles."
lane :setup do
sh "cert -o ./certs"
sh "sigh -a co.ello.ElloDev --adhoc -o ./fastlane/profiles"
sh "sigh -a co.ello.Ello -o ./fastlane/profiles"
end
desc 'Makes sure that Fastlane is setup and working by posting a message to Slack'
lane :dry_run do
post_to_slack(message: "Successful Fastlane dry run :fallen_leaf:")
end
desc 'Generates release notes'
lane :release_notes do
extract_from_env(
required: {"GITHUB_API_TOKEN" => "Github access token"}
)
Dir.chdir '..' do
generator = GenerateReleaseNotes.new('ello/ello-ios', 'bin/previous-sha.yml', ENV['GITHUB_API_TOKEN'])
generator.create_release_notes
end
end
desc 'Submit a build to testflight'
lane :beta do
generate_keys
increment_build_and_version
compile
testflight
release_notes
post_to_slack(scheme: ":ello:", destination: ":airplane:")
end
desc 'Submit a build to the app store'
lane :store do
increment_build_and_version
compile
deliver(
skip_screenshots: true,
skip_metadata: true,
submit_for_review: false,
automatic_release: false,
force: true
)
release_notes
refresh_dsyms
post_to_slack(scheme: ":ello:", destination: ":apple:")
end
desc 'Downloads dSyms from Apple, and uploads them to Crashlytics'
desc ' Options:'
desc ' version:x.y.z (defaults to ENV[VERSION_NUMBER])'
desc ' build:1234 (defaults to latest build number)'
lane :refresh_dsyms do |opts|
download_version = opts[:version] || version_number
download_build = opts[:build] || build_number
UI.message("Uploading version #{download_version} (#{download_build})")
extract_from_env(
required: {
"CRASHLYTICS_API_TOKEN" => "Your Crashlytics Api Token",
"CRASHLYTICS_BUILD_SECRET" => "Your Crashlytics Build Secret",
},
)
download_dsyms(version: download_version, build_number: download_build)
upload_symbols_to_crashlytics
clean_build_artifacts
end
######################### PRIVATE LANES #########################
private_lane :generate_keys do
`bundle exec rake generate:keys`
end
private_lane :compile do
gym(
scheme: "Ello",
configuration: "Release",
sdk: "iphoneos",
clean: true
)
end
private_lane :extract_from_env do |options|
required_env_error = false
if required_env = options[:required]
required_env.each do |key, value|
if !ENV[key] || ENV[key] == ""
UI.error "ENV[#{key.inspect}] should be set to #{value.inspect}"
required_env_error = true
end
end
end
if defaults_env = options[:defaults]
defaults_env.each do |key, value|
if !ENV[key] || ENV[key] == ""
UI.message "ENV[#{key.inspect}] default value is #{value.inspect}"
ENV[key] = value
end
end
end
if required_env_error
abort
end
end
def build_number
`/bin/bash -c "git rev-list HEAD | wc -l | tr -d ' '"`.strip
end
def version_number
ENV["VERSION_NUMBER"]
end
private_lane :increment_build_and_version do
extract_from_env(
required: {
"VERSION_NUMBER" => "current version number"
},
)
increment_version_number version_number: version_number
increment_build_number build_number: build_number
end
private_lane :post_to_slack do |options|
if !ENV['SLACK_URL']
UI.error "SLACK_URL is missing, slack integration is disabled"
else
if options[:message]
message = options[:message]
else
scheme = options[:scheme]
version = get_version_number(xcodeproj: ENV["XCODE_PROJECT"])
build = get_build_number(xcodeproj: ENV["XCODE_PROJECT"])
destination = options[:destination]
message = "<!here|here>: New :iphone: #{scheme} *#{version}* (#{build}) has been submitted to *#{destination}* :rocket:"
end
slack(
message: message,
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment