I have setup a simple go repository and configured TravisCI in the following way
language: go
go:
- 1.8.x
- master
gobuild_args: -ldflags "-X main.Version=${TRAVIS_TAG} -X main.buildTime=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.commitId=${TRAVIS_COMMIT}"
env:
- GOOS=linux GOARCH=amd64
- GOOS=windows GOARCH=amd64
after_success:
- ./build.sh
matrix:
allow_failures:
- go: master
This will essentially create 4 different builds in TravisCI. This is great for building a cross compilation project where I can build windows and linux binaries separately.
What I have been struggling to do is to create 1 single release in Github from all the binaries generated across those builds?
TravisCI documentation says they support releases but it is very vague on how to handle such a scenario.
Has anybody attempted this?
Since you're using Golang, take a look at ghr.
I've used it with CircleCI -- and it's as simple as:
ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME v1.0.$CIRCLE_BUILD_NUM $CIRCLE_ARTIFACTS/ || true
Where...
$GITHUB_TOKEN
is the github token used to publish files. You'll need repo read access and user access I believe.
$CIRCLE_PROJECT_USERNAME
is the github user
$CIRCLE_PROJECT_REPONAME
is your repository name on Github
$CIRCLE_BUILD_NUM
is the build number given by CircleCI (I like to use it as the point release to match up release version with build version)
$CIRCLE_ARTIFACTS
is the build artifacts path on CircleCI
the || true
at the end make sure that even if creating the release and uploading the files fails, I don't fail the entire build.