Skip to content

Instantly share code, notes, and snippets.

@jasonacox
Last active August 17, 2020 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonacox/32c892b09b3244698ee611ddf453fad6 to your computer and use it in GitHub Desktop.
Save jasonacox/32c892b09b3244698ee611ddf453fad6 to your computer and use it in GitHub Desktop.
Travis-CI for Xcode Mac, iOS and tvOS Development using AWS S3 for Build Storage

Travis-CI for Xcode with S3

This gist explains to set up your repo to have Travis CI build your Xcode projects for Mac, iOS and tvOS development. The binaries built from one stage will not persist between stages so you will need to store any build artifacts in S3 and import them between stages.

Setup

There are a few things that you will need to do in order to use S3 with a Mac build node:

Create S3 Bucket

  • Create a IAM user with permission to access S3 bucket - example:
{
  "Version": "2012-10-17",
  "Statement": [
      {
          "Effect": "Allow",
          "Action": [
              "s3:AbortMultipartUpload",
              "s3:DeleteObject",
              "s3:GetObject",
              "s3:GetObjectAcl",
              "s3:PutObject",
              "s3:PutObjectAcl"
          ],
          "Resource": "arn:aws:s3:::jasonacox.com.travis-build-stage-storage/*"
      }
  ]
}

Configure Travis CI

The following examples uses a osx host targetted for Xcode 11.6 Objective C development.

  • Configure Travis CI:

    • In the Travis CI portal settings for your project add these Environment Variables with your AWS IAM user details:
      • AWS_ACCESS_KEY_ID
      • AWS_SECRET_ACCESS_KEY
  • Create the .travis.yml file:

    • In the .travis.yml file, use python3 to install the AWS CLI
    • Add the python3 bin path to the global user PATH
    • Use the aws s3 commands to move files to/from S3
os: osx
osx_image: xcode11.6
language: objective-c

env:
  global:
    - PATH=/Users/travis/Library/Python/3.8/bin:$PATH   # for AWS

before_install:
  # set up awscli packages
  - python3 -m pip install pyopenssl
  - python3 -m pip install --user awscli
  - aws s3 ls jasonacox.com.travis-build-stage-storage

stages:
  - one
  - two

jobs:
  include:
    - stage: one
      script:
        - cd one;./build.sh 
        - cd ..
        - echo "Uploading one libraries..."
        - tar -zcf "one.tgz" one/include one/lib 
        - aws s3 cp "one.tgz" s3://jasonacox.com.travis-build-stage-storage/
        - aws s3 ls jasonacox.com.travis-build-stage-storage
        
    - stage: two
      script: 
        - echo "Fetching one libraries..."
        - aws s3 cp s3://jasonacox.com.travis-build-stage-storage/one.tgz .
        - tar -zxf one.tgz
        - cd two;./build.sh
        - cd ..
        - echo "Uploading two libraries..."
        - tar -zcf "two.tgz" two/lib two/include
        - aws s3 cp "two.tgz" s3://jasonacox.com.travis-build-stage-storage/
        - aws s3 ls jasonacox.com.travis-build-stage-storage
        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment