Skip to content

Instantly share code, notes, and snippets.

@colebrumley
Last active January 16, 2017 02:37
Show Gist options
  • Save colebrumley/a1542e792389c9a56aa0 to your computer and use it in GitHub Desktop.
Save colebrumley/a1542e792389c9a56aa0 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -xe
cd $HOME
# Remove the build cache and get Glide
rm -Rf $GOPATH/src/*
go get github.com/Masterminds/glide
mkdir -p $HOME/.go_workspace/src/github.com/$CIRCLE_PROJECT_USERNAME/
cd $HOME/.go_workspace/src/github.com/$CIRCLE_PROJECT_USERNAME
mv $HOME/$CIRCLE_PROJECT_REPONAME .
cd $CIRCLE_PROJECT_REPONAME/
# Switch glide to the appropriate branch
if [[ "$CIRCLE_BRANCH" != "master" ]]; then
sed -i "s/version: master/version: ${CIRCLE_BRANCH}/g" glide.yaml
fi
# Get the deps
glide up
@colebrumley
Copy link
Author

Quick setup script for Go 1.5+ Vendoring and Glide on CircleCI

Things can get confusing with CircleCI and go vendor packages. This script aims to set up your repo to build with vendoring enabled. You will need to add cd $HOME/.go_workspace/src/github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME before your build steps (so that you're in the working project working dir). Then you should be able to go build as normal.

Lines 14-16 are a workaround I use to make sure that my private dependency repos build with the same branch name as the build repo. Feel free to comment out if you don'e need this. In most cases it'll be ignored anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment