Skip to content

Instantly share code, notes, and snippets.

@joshstrange
Last active November 4, 2024 05:45
Show Gist options
  • Save joshstrange/a3da9901cc84ae7f5d0b1b40dd110e0f to your computer and use it in GitHub Desktop.
Save joshstrange/a3da9901cc84ae7f5d0b1b40dd110e0f to your computer and use it in GitHub Desktop.
Fastfile for iOS/Android
# Customise this file, documentation can be found here:
# https://docs.fastlane.tools/actions/
# All available actions: https://docs.fastlane.tools/actions
# 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
fastlane_version "2.61.0"
default_platform :ios
ENV['app_identifier'] = '*REPLACE ME* Your App ID, ex: com.example.myApp'
ENV['app_name_sanitized'] = '*REPLACE ME* Your App Name, ex: My App'
lane :clean do
sh "cd .. && rm -rf node_modules && rm -rf platforms/ios && rm -rf platforms/android && rm -rf plugins"
end
lane :prepare do
# Yes, prepare is in there twice, I've seen where it will only install 1 os when you run prepare
# but running it again will add the other. This is a safe operation so if it does add both the
# second run will not hurt anything
sh "npm install && cordova prepare && cordova prepare"
end
platform :ios do
before_all do
ENV['ios_path'] = 'platforms/ios/'
ENV['ios_project_path'] = "#{ENV['ios_path']}#{ENV['app_name_sanitized']}.xcodeproj"
ENV['ios_workspace_path'] = "#{ENV['ios_path']}#{ENV['app_name_sanitized']}.xcworkspace"
ENV['FASTLANE_SESSION'] = '*REPLACE ME* YOU CAN GET THIS BY RUNNING: fastlane spaceauth -u [email protected]'
ENV['FASTLANE_USER'] ="*REPLACE ME* Your iTunesConnect user"
ENV['MATCH_PASSWORD'] ="*REPLACE ME* Your Match password"
end
desc 'Unlock keychain'
lane :unlock do
# *REPLACE ME* Replace yourPassword with the password for your Mac's user your are building with
sh 'security unlock-keychain -p yourPassword'
end
desc 'Build ionic app for iOS'
lane :build do
prepare
cocoapods(
clean: true,
podfile: "#{ENV['ios_path']}Podfile"
)
sh "cd .. && ionic cordova build ios -prod --no-telemetry"
end
desc "Switch to automatic code signing"
lane :auto do
enable_automatic_code_signing(path: ENV['ios_project_path'])
end
desc "Switch to manual code signing"
lane :manual do
disable_automatic_code_signing(path: ENV['ios_project_path'])
end
desc "Submit a new Beta Build to Apple TestFlight"
lane :beta do
unlock
build
manual
match(type: "appstore", app_identifier: ENV['app_identifier'], readonly: true) # more information: https://codesigning.guide
update_project_provisioning(
xcodeproj: ENV['ios_project_path'],
profile: ENV["sigh_#{ENV['app_identifier']}_appstore_profile-path"],
build_configuration: "Release"
)
gym(
scheme: ENV['app_name_sanitized'],
workspace: ENV['ios_workspace_path'],
export_method: 'app-store',
clean: true,
codesigning_identity: "iPhone Distribution: *REPLACE ME* Put your Company Name here (Or whatever the Common Name is for the cert Match created for you)"
)
auto
hipchat(
message: "Uploading #{ENV['app_name_sanitized']} to TestFlight"
)
pilot(
skip_waiting_for_build_processing: true
)
hipchat(
message: "Uploaded #{ENV['app_name_sanitized']} to TestFlight"
)
# sh "your_script.sh"
# You can also use other beta testing services here (run `fastlane actions`)
end
after_all do |lane|
# This block is called, only if the executed lane was successful
# slack(
# message: "Successfully deployed new App Update."
# )
end
error do |lane, exception|
end
end
platform :android do
before_all do
end
desc 'Build ionic app for Android'
lane :build do
prepare
sh "cd .. && ionic cordova build android -prod --no-telemetry --release"
end
desc "Submit a new Alpha Build to Play Alpha"
lane :alpha do
hipchat(
message: "Building Android #{ENV['app_name_sanitized']}"
)
build
hipchat(
message: "Uploading #{ENV['app_name_sanitized']} to Google Play Alpha"
)
supply(
package_name: ENV['app_identifier'],
track: 'alpha',
apk: 'platforms/android/build/outputs/apk/android-release.apk',
skip_upload_images: true,
skip_upload_metadata: true,
skip_upload_screenshots: true,
json_key: 'play-credentials.json'
)
hipchat(
message: "Uploaded #{ENV['app_name_sanitized']} to Google Play Alpha"
)
end
after_all do |lane|
# This block is called, only if the executed lane was successful
# slack(
# message: "Successfully deployed new App Update."
# )
end
error do |lane, exception|
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment