GitHub Action with Fastlane Plugin

GitHub Action with TestApp.io Fastlane Plugin allows you to build and upload both Android & iOS apps to TestApp.io to notify your testers for testing and feedback.

Configuration

Key Description Env Var(s) Default
api_token You can get it from https://portal.testapp.io/settings/api-credentials TESTAPPIO_API_TOKEN
app_id You can get it from your app page at https://portal.testapp.io/apps TESTAPPIO_APP_ID
release It can be either both or Android or iOS TESTAPPIO_RELEASE
apk Path to the Android APK file TESTAPPIO_ANDROID_PATH
ipa Path to the iOS IPA file TESTAPPIO_IOS_PATH
release_notes Manually add the release notes to be displayed for the testers TESTAPPIO_RELEASE_NOTES
git_release_notes Collect release notes from the latest git commit message to be displayed for the testers: true or false TESTAPPIO_GIT_RELEASE_NOTES true
git_commit_id Include the last commit ID in the release notes (works with both release notes options): true or false TESTAPPIO_GIT_COMMIT_ID false
notify Send notifications to your team members about this release: true or false TESTAPPIO_NOTIFY false

Check TA-CLI for more info

iOS

We will demonstrate with our sample iOS project, testappio-ios-sample-app to show how Github Action + Fastlane + TestApp plugin works.

Configure iOS project for Fastlane

  1. Install Fastlane

The below command works for most cases. If not, please read this - Setup Fastlane

bundle install fastlane
  1. Init Fastlane

In the iOS project folder

bundle exec fastlane init

And follow the wizard; it will create ./fastlane/Appfile with your Apple ID and team.

  1. Init Match

Fastlane match is a tool for generating all necessary certificates, provisioning profiles and storing them in a Git repository encrypted.

Create a private empty GitHub repository for storing certificates and provisioning profiles.

bundle exec fastlane match init

Follow the instruction, give the new empty git repository when asked, and it will create the Matchfile.

💡
This Git repository will be used to store your certificates and profiles.
  1. Generate the certificate and provision profile
bundle exec fastlane match adhoc

Following the instruction, it will generate certificates/profiles and store them in the Git repository specified in the previous step.

💡
Note: Provide a matching password for encrypting the certificates and profiles in the Git repository.
  1. Select provisioning profiles in Xcode

The newly created certificates and profiles should now be possible to select inside our project. Open up Xcode and go to Signing & Capabilities.

⚠️
Note: Don't choose Automatically Manage Signing
  1. Using testappio plugin for Fastlane
bundle exec fastlane add_plugin testappio
  1. Create a Repository level Secret MATCH_PASSWORD this is the one you specified while generating the Certificates and Profiles.

How to configure **secret** for GitHub actions

Go to GitHub repository Settings Page, to Secrets, and then Actions; click on New repository secret to configure a new secret.

Then, you can refer to it in your GitHub workflow as ${{ secret.app_id }}

  1. Create a Repository level Secret FASTLANE_PASSWORD this is the password of your Apple ID.

  2. Create a Repository level Secret MATCH_GIT_BASIC_AUTHORIZATION for accessing the Certification/Profile repository.

Navigate to Tokens to generate a Personal Access Token, MATCH_GIT_BASIC_AUTHORIZATION can be generated below

echo -n your_github_username:your_personal_access_token | base64
  1. Create Repository level Secrets TESTAPPIO_API_TOKEN and TESTAPPIO_APP_ID

Run the pipeline

  1. Finally, create the lane

Create: ./fastlane/Fastfile and copy the below content:

default_platform(:ios)

platform :ios do

  desc "Build the adhoc and upload to TestApp.io"
  lane :development do
    match(type: "adhoc")
    gym(export_method: "ad-hoc")
    upload_to_testappio(
      release_notes: "My release notes here..."
    )
  end
  
end

More info on the Fastlane plugin: https://help.testapp.io/fastlane-plugin/#testappio-actions

You may already have your lane in place; copy the upload_to_testappio action and put it into your pipeline after the IPA export.

  1. The GitHub Workflow:

Create: .github/workflows/ios.yml file under your project root folder. E.g.

name: Build & upload IPA to TestApp.io

on:
  workflow_dispatch:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  ios:
    name: Build and upload to TestApp.io
    runs-on: macos-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.7.2'
      - uses: maierj/fastlane-action@v2.2.0
        env:
          MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
          FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
          TESTAPPIO_API_TOKEN: ${{ secrets.TESTAPPIO_API_TOKEN }}
          TESTAPPIO_APP_ID: ${{ secrets.TESTAPPIO_APP_ID }}
          MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
        with:
          lane: 'ios development'
          verbose: true

  1. Commit and push the change to trigger the GitHub Action.

Android

We will demonstrate with our sample Android project testappio-android-sample, how GitHub Action + Fastlane + TestApp plugin works.

  1. Create Repository level Secrets TESTAPPIO_API_TOKEN and TESTAPPIO_APP_ID

2. Create .github/workflows/main.yml file

name: Build & upload APK to TestApp.io

on:
  workflow_dispatch:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  ios:
    name: Build and upload to TestApp.io
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.7.2'
      - uses: maierj/fastlane-action@v2.2.0
        env:
          TESTAPPIO_API_TOKEN: ${{ secrets.TESTAPPIO_API_TOKEN }}
          TESTAPPIO_APP_ID: ${{ secrets.TESTAPPIO_APP_ID }}
        with:
          lane: 'android development'
          verbose: true

3. Create fastlane/Fastfile file

default_platform(:android)

platform :android do

  desc "Submit a new Build to TestApp.io"
  lane :development do

    increment_version_code

    gradle(task: "clean assembleDebug")
  
    upload_to_testappio(
      release_notes: "My release notes here..."
    )
  end
end

4. Commit and push the change to trigger the GitHub Action.

Feedback & Support

Developers built TestApp.io to solve the pain of app distribution for mobile app development teams.

Join our community for feedback and support.

Happy releasing 🎉