Skip to main content

One post tagged with "travis-ci"

View All Tags

· 3 min read
zach wick

This set of steps is the result of a weekend poking at how to get Travis-CI and GitHub configured to provide a CI pipeline for Swift packages. It is mostly for future reference for when I next start another Swift project.


  1. Create a new directory and navigate to it
mkdir Hello
cd Hello
  1. Every package must have a manifest file called Package.swift in its root directory. You can create a minimal package named Hello using:
swift package init
  1. Build your library with:
swift build
  1. Run your tests with:
swift test
  1. Initialize your package as a git repo
git init
  1. Create a new repository in your GitHub account

  2. Commit your local changes

git add *
git add .gitignore
git commit -sm "Initial Commit"
  1. Add your GitHub repo as a remote repo
git remote add origin
git push -u origin master
  1. Navigate to and connect it to your GitHub account

  2. Activate your new repo in Travis-CI (

  3. Create .travis.yml and populate it as below:

if: tag IS blank
- master
- SWIFT_BRANCH=swift-5.0.1-release
- stage: Linux test
os: linux
language: generic
dist: xenial
sudo: required
- sudo apt-get install clang libcurl3 libcurl4-openssl-dev libpython2.7 libpython2.7-dev
libicu-dev libstdc++6
- curl$SWIFT_BRANCH/ubuntu1604/$SWIFT_VERSION/$SWIFT_VERSION-ubuntu16.04.tar.gz
> $SWIFT_VERSION-ubuntu16.04.tar.gz
- tar xzf $SWIFT_VERSION-ubuntu16.04.tar.gz
- export PATH="$(pwd)/$SWIFT_VERSION-ubuntu16.04/usr/bin:$PATH"
- swift package update
- swift test
- stage: OSX test
os: osx
osx_image: xcode10.2
language: swift
sudo: required
- sudo installer -pkg $SWIFT_VERSION-osx.pkg -target /
- export PATH="/Library/Developer/Toolchains/$SWIFT_VERSION.xctoolchain/usr/bin:$PATH"
- swift package update
- swift test
- stage: Set tag
- git config --global ""
- git config --global "Travis CI"
- git push --quiet https://$ --tag > /dev/null 2>&1
  1. Commit .travis.yml and push to GitHub

  2. Create a Personal Access Token in your GitHub account

  3. Install the Travis CLI tools by either

brew install travis


gem install travis -v 1.8.9 --no-rdoc --no-ri
  1. Set up and configure the travis CLI tool
travis login --auto
travis branches

The first command authenticates your CLI tool with your Travis-CI account using your local GitHub credentials. The second command ensures that the travis CLI tool is using your Swift project as its current project.

  1. Use the Travis CLI to add your GitHub Personal Access Token as an encrypted environment variable
echo GH_TOKEN=<YOUR TOKEN> | travis encrypt --add
  1. Add a Travis-CI build status badge to your project's README file by following the steps at

Now, everytime that you want to push a new version of your Swift project if all of your tests pass, you simply need to bump the version defined as PACKAGE_VERSION, in .travis.yml and them commit and push your changes.