Skip to content

Commit

Permalink
Fix #8: auto build binaries on push to master
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Weibel committed Nov 17, 2017
1 parent 8145494 commit 725874c
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bin/
vendor/
*.coverprofile
rokka_darwin_amd64
rokka_linux_amd64
rokka_windows_amd64.exe
32 changes: 23 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,27 @@ before_install:
- go get -u golang.org/x/tools/cmd/goimports
- go get github.com/mattn/goveralls
- go get github.com/go-playground/overalls
- go get github.com/mitchellh/gox

script:
# linting
- goimports -d ./
- go tool vet ./
# testing
- go test -v ./...
# coveralls.io (see https://github.com/golang/go/issues/6909 why the use of overalls)
- overalls -project=github.com/rokka-io/rokka-go -covermode=count
- goveralls -coverprofile=overalls.coverprofile -service=travis-ci
script: ./.travis/test.sh

stages:
- script: ./.travis/test.sh
- name: deploy
if: branch = master

jobs:
include:
- stage: deploy
script: ./.travis/deploy.sh
go: 1.9
deploy:
provider: releases
api_key:
secure: DB4mN/YKS7e/yYfqgZ5e2vocvMW/WfZofj1PtJu2imF+HEp+XC6KjhIKZYcp9Qgopl2uF2WhFCWc4Yf1fItAE4jQA41aF8poarPK1bRpvl4HoooIL6ONlAoAG9DnTyV3R2gNIRIJZD8T++Ue5kosWFD9o9BjQDiSkWO4ZJ16IjeAY+iCT/36WaIyYpNAPqF6JJqmNX4SJ+h8jor4IS33dv9eO54iMrHIMvXf9sxqS0yEnNJJHZbY1vhdJ6IfAmqysH5jz775WKq6b1AD50pPAn+kwrnYHhh1naG9smKqwbbJ1lhEJBjNHHpwwPWo/Z4bqkEKy2pocrYfRYNMHvAX2lNcw+EnA/08dQKYx7FlMld4gpCrcAp7U+iQQKiBV76jQr4o4HMKdDhNQflzeWlPOp5xZs3fJ47jefJjef/OnDy5S3/9FANkGS0x3my0/5D1bklpWmqS+EodzoxkSE42ZMgPJF6uaTiHYiKtuePxr1j6WMXkTPCRIPU7HbsscGv9O/Y5IRXqb0reC8AZ5FLO3U5mV7tHAwJfCZAh83OsCyfRZS7ebHzvjTXhB+2KUiBunfJthXCvP26q+h8kyd7KVrvRTQwu485WBBdgc7H/FL2SUPUMT/zHUQuA84hSxOu0Ns6PvR7HkG9/MXCXvZiRSMLeFFrunG+09A7eLW89c8I=
file:
- rokka_darwin_amd64
- rokka_linux_amd64
- rokka_windows_amd64.exe
on:
repo: rokka-io/rokka-go
9 changes: 9 additions & 0 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

set -e

DATE=`date -u '+%Y-%m-%d'`
GIT_SHA=`git rev-parse --short HEAD`
VERSION="$DATE.$GIT_SHA"

gox -os="linux darwin windows" -arch="amd64" -ldflags "-X main.cliVersion=${VERSION}" ./cmd/rokka
14 changes: 14 additions & 0 deletions .travis/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -e

# linting
goimports -d ./
go tool vet ./

# testing
go test -v ./...

# coveralls.io (see https://github.com/golang/go/issues/6909 why the use of overalls)
overalls -project=github.com/rokka-io/rokka-go -covermode=count
goveralls -coverprofile=overalls.coverprofile -service=travis-ci
21 changes: 17 additions & 4 deletions cmd/rokka/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ import (
"github.com/rokka-io/rokka-go/rokka"
)

var apiKey string
var apiAddress string
var verbose bool
var logger cli.Log
var (
// auto-set during build of CLI
cliVersion string = "unversioned"

apiKey string
apiAddress string
verbose bool
version bool

logger cli.Log
)

func init() {
logger = cli.Log{}

flag.StringVar(&apiKey, "apiKey", "", "Optional API key")
flag.StringVar(&apiAddress, "apiAddress", "", "Optional API address")
flag.BoolVar(&verbose, "verbose", false, "Show verbose HTTP request/responses")
flag.BoolVar(&version, "version", false, "Print current version")

flag.Usage = func() {
logger.Errorf("Usage: %s <command>\n\n", os.Args[0])
Expand All @@ -33,6 +41,11 @@ func init() {
func main() {
flag.Parse()

if version {
logger.Printf("Version: %s\n", cliVersion)
os.Exit(0)
}

args := flag.Args()

if len(args) == 0 {
Expand Down

0 comments on commit 725874c

Please sign in to comment.