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.
There are a few things that you will need to do in order to use S3 with a Mac build node:
- 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/*"
}
]
}
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
- In the Travis CI portal settings for your project add these Environment Variables with your AWS IAM user details:
-
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