Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated Travis/Github releases #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions PLATFORMS
Original file line number Diff line number Diff line change
@@ -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
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="https://i.imgur.com/UWhSoQj.png" width="450" alt="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.**
Expand Down Expand Up @@ -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).
27 changes: 27 additions & 0 deletions build-cross.sh
Original file line number Diff line number Diff line change
@@ -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