Automated deployment is a crucial part of modern app development, enabling developers to release updates quickly and reliably. Fastlane is a powerful tool that simplifies this process, especially when integrated into an Expo CI/CD setup. This guide walks you through the steps to set up Fastlane for automated deployment in your Expo project.

Prerequisites

  • Node.js and npm installed on your machine
  • Expo CLI installed globally
  • An Expo account and project set up
  • Fastlane installed on your machine
  • Access to your app store credentials (Apple Developer account, Google Play Console)

Setting Up Fastlane in Your Project

Navigate to your project directory and initialize Fastlane for Android and iOS. Run the following commands:

cd your-project-directory
fastlane init

Select the appropriate options for your app when prompted. This process creates a fastlane directory with configuration files.

Configuring Fastlane for Expo

Modify the Fastfile to include lanes for building and deploying your app. Below is an example configuration for Android:

lane :deploy_android do
  sh "expo build:android --no-wait"
  # Add commands to upload APK/AAB to Google Play
  supply(
    track: 'production',
    apk: 'path/to/your.apk'
  )
end

Similarly, configure the iOS lane:

lane :deploy_ios do
  sh "expo build:ios --no-wait"
  # Add commands to upload IPA to App Store Connect
  pilot
end

Integrating with CI/CD

Set up your CI/CD pipeline (e.g., GitHub Actions, GitLab CI, CircleCI) to run Fastlane commands automatically. Example GitHub Actions step:

- name: Deploy Android
  run: fastlane deploy_android
- name: Deploy iOS
  run: fastlane deploy_ios

Secure Your Credentials

Use environment variables or secret management tools provided by your CI/CD platform to store sensitive information like API keys and credentials. Reference these in your Fastfile or environment configuration.

Testing and Deployment

Before automating fully, test each lane locally by running:

fastlane deploy_android
fastlane deploy_ios

Once confirmed, trigger the lanes through your CI/CD pipeline for automated deployment.

Conclusion

Integrating Fastlane into your Expo CI/CD setup streamlines the deployment process, reduces manual errors, and accelerates release cycles. Proper configuration and secure management of credentials are key to a smooth automation workflow. Start automating today to enhance your app deployment pipeline.