diff --git a/.travis.yml b/.travis.yml index 4f2ee4d..6036e35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,20 @@ language: go +if: NOT tag = master-auto +before_deploy: + - cat PLATFORMS | xargs -L 1 -P 15 ./build-cross.sh + - git remote add gh https://${GITHUB_API_KEY}@github.com/${TRAVIS_REPO_SLUG}.git + - git fetch gh --tags + - git tag -f master-auto + - git push gh --tags -f + - git remote rm gh +deploy: + provider: releases + api_key: $GITHUB_API_KEY + file_glob: true + file: "builds/*" + skip_cleanup: true + prerelease: true + overwrite: true + target_commitish: $TRAVIS_COMMIT + on: + branch: master diff --git a/PLATFORMS b/PLATFORMS new file mode 100644 index 0000000..acf3e9f --- /dev/null +++ b/PLATFORMS @@ -0,0 +1,13 @@ +freebsd_386 +freebsd_amd64 +freebsd_arm7 +linux_386 +linux_amd64 +linux_arm64 +linux_arm7 +mac_amd64 +openbsd_386 +openbsd_amd64 +solaris_amd64 +windows_386 +windows_amd64 \ No newline at end of file diff --git a/README.md b/README.md index b96e489..316e6e4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Checkup -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/sourcegraph/checkup) [![Sourcegraph](https://sourcegraph.com/github.com/sourcegraph/checkup/-/badge.svg)](https://sourcegraph.com/github.com/sourcegraph/checkup?badge) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/sourcegraph/checkup) [![Sourcegraph](https://sourcegraph.com/github.com/sourcegraph/checkup/-/badge.svg)](https://sourcegraph.com/github.com/sourcegraph/checkup?badge) [![TravisCI](https://api.travis-ci.org/sourcegraph/checkup.svg?branch=master)](https://travis-ci.org/sourcegraph/checkup/) **Checkup is distributed, lock-free, self-hosted health checks and status pages, written in Go.** @@ -484,3 +484,37 @@ docker run --net=host --rm \ ``` This will create a checkup binary in the root project folder. + +### Building with the Cross-Compiler + +Alternative operating systems and architectures can be built using the [build-cross.sh](./build-cross.sh) script which will output binaries to `./builds/`. The build target can be passed in an `[OS]_[ARCH]` format: + +```sh +./build-cross.sh linux_amd64 +./build-cross.sh freebsd_386 + +ls -al builds/ +# checkup_freebsd_386 +# checkup_linux_amd64 +``` + +Multiple platforms can be built in parallel by sending the contents of [PLATFORMS](./PLATFORMS) to the [build-cross.sh](./build-cross.sh) script: + +```sh +# -P 15 : run a max of 15 processes simultaneously +cat PLATFORMS | xargs -L 1 -P 15 ./build-cross.sh + +ls -al builds/ +# checkup_freebsd_386 +# checkup_freebsd_amd64 +# checkup_linux_386 +# checkup_linux_amd64 +# checkup_linux_arm64 +# checkup_openbsd_386 +# checkup_openbsd_amd64 +# checkup_solaris_amd64 +``` + +### Builds via Travis CI + +Automated builds happen in [Travis CI](https://travis-ci.org/sourcegraph/checkup/) each time `master` branch is updated. See the latest prerelease at [sourcegraph/checkup/releases](https://github.com/sourcegraph/checkup/releases). diff --git a/build-cross.sh b/build-cross.sh new file mode 100755 index 0000000..e8c7e9b --- /dev/null +++ b/build-cross.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Cross-compiles the project for several platforms. +# Outputs to ./builds/ +# +# Single-run usage: +# ./build-cross.sh linux_amd64 +# +# Parallel usage: +# cat PLATFORMS | xargs -L 1 -P 8 ./build-cross.sh + +if [ -z "$1" ]; then + echo "Error: Specify a platform" + exit 1 +fi + +echo Building platform \"$1\" ... + +mkdir -p ./builds/ +pushd ./cmd/checkup/ > /dev/null 2>&1 + +OS=$(echo $1 | cut -d'_' -f1) +ARCH=$(echo $1 | cut -d'_' -f2) +GOOS=$OS GOARCH=$ARCH go build -v -ldflags '-s' -o "../../builds/checkup_$1" > /dev/null 2>&1 + +echo Completed platform \"$1\" +popd > /dev/null 2>&1