Emerge is easy to integrate with a repository already using Travis CI. First make sure your GitHub account is connected and you’ve read our Fastlane documentation.

Environment Variables

Follow our steps on obtaining an API key and copy it into your Travis CI environment variables.

1692

Travis Config

In your .travis.yml file configure your build to trigger a fastlane action

language: swift
osx_image: xcode13.1
script:
- bundle exec fastlane app_size

Fastlane Action

The Fastlane action will upload either a release build or development build to Emerge depending on the branch used to trigger the build.

When a build is triggered by a pull request, Travis merges the master branch into your PR branch. We can access the SHA of the merge commit's parent to obtain a base_build_id that gets passed to the Emerge action.

When a build is triggered from the master branch we upload a master build type with the current git SHA as the build_id.

Here’s an example Fastfile that brings it all together:

fastlane_require 'git'

default_platform(:ios)

g = Git.open('..')

platform :ios do
  lane :app_size do
  	build_app(
  		project: "MyProject.xcodeproj",
  		configuration: "Release",
  		scheme: "MyScheme",
  		archive_path: "MyArchive.xcarchive")
    zip(
      path: "MyArchive.xcarchive",
      output_path: "MyArchive.xcarchive.zip"
    )
    branch = ENV["TRAVIS_BRANCH"]
    if ENV["TRAVIS_PULL_REQUEST"] != "false"
      baseBuildId = g.log[0].parent.sha
      emerge(
        file_path: "MyArchive.xcarchive.zip",
        build_type: "pull_request",
        repo_name: "mycompany/myrepo",
        pr_number: ENV["TRAVIS_PULL_REQUEST"],
        sha: g.log[0].parents[1].sha,
        base_sha: g.log[0].parent.sha)
    elsif branch.eql? "master"
      emerge(
        file_path: "MyArchive.xcarchive.zip", 
        build_type: "master",
        repo_name: "mycompany/myrepo",
        sha: g.log[0].sha)
    end
  end
end