Maintaining a Homebrew Tap for Swift Projects

brew install mxcl/made/swift-sh

Why Should I Do This?

How To Make a Tap

  1. Tag a release for your project ✻
  2. Create a new repository on GitHub, name it homebrew-tap
  3. Add a file called your-project.rb, adapting the following:
class ProjectName < Formula
desc "Describe your project"
homepage ""
url ""
def install
system "swift", "build",
"--configuration", "release",
bin.install '.build/release/your-project'
class ProjectName < Formula
desc "…"
homepage ""
url ""
sha256 "INSERT-SHA256-HERE" def install
# …

Automating Formula Updates

os: osx
language: swift
osx_image: xcode10.2
provider: script
all_branches: true
condition: $TRAVIS_BRANCH =~ ^v?\d+\.\d+\.\d+$
- PROJ=$(basename $TRAVIS_REPO_SLUG)
- URL="$TRAVIS_SLUG/archive/$TRAVIS_TAG.tar.gz"
- ORIGIN="https://$$USER/homebrew-tap.git"
# grab the tap
- brew tap $USER/homebrew-tap
- cd /usr/local/Homebrew/Library/Taps/$USER/homebrew-tap

# update the formula URL
- sed -E -i '' 's~^ url ".+"~ url "'$URL\"~ ./swift-sh.rb
- brew fetch $PROJ || true
# ^^ fails because SHA is wrong, hence || true

# figure out the sha
- SHA256=$(shasum --algorithm 256 $(brew --cache --build-from-source $PROJ) | awk '{print $1}')

# update the formula SHA
- sed -E -i '' 's/^ sha256 ".+"/ sha256 "'$SHA256\"/ $PROJ.rb
# commit to the tap
- git remote set-url origin "$ORIGIN"
- git add $PROJ.rb
- git config "Travis"
- git config ""
- git commit -m "$PROJ $TRAVIS_TAG"
- git push origin master

Automatic Bottling

Optional Extras

Add Travis for Your Tap

An Idea

  1. Scan GitHub periodically for new Package.swift which build binaries
  2. Create formula for those repos (via a template obv.)
  3. Periodically scan for new releases for those repos and update the formula




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The 12 Factor Data Architecture - enabling a modern event driven data fabric

Kubernetes, Strimzi, Amazon MSK and Kafka-Proxy: A recipe for automation

A beginners guide to Ruby on Rails!

Vocaloid and UTAU

Resiliency Patterns with Ninja — CNCF Roadmap

What new features to build

Hacking the Tenda AC10–1200 Router Part 4: sscanf buffer overflow

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Max Howell

Max Howell

More from Medium

Guide to manage secrets in SwiftUI app

New configuration file

Integrate a complex Swift Package into your iOS app

How to embed a UIKit Alert with Text Field in SwiftUI

An iPhone that displays an Alert with Text Field on a wooden table.

How To Create Localizable And Use For Swift