-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
87 lines (77 loc) · 4.31 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
language: go
go:
- 1.14.x
install: skip
os:
- linux
services:
- docker
env:
global:
- GO111MODULE=on
- CGO_ENABLED=0
cache:
directories:
- $HOME/.cache/go-build
- $HOME/gopath/pkg/mod
script: skip
jobs:
include:
- stage: test
name: Run Tests
script:
- go test -v ./...
- export LDFLAGS="-X github.com/echocat/goxr/runtime.version=TEST${TRAVIS_BRANCH}TEST -X github.com/echocat/goxr/runtime.revision=TEST${TRAVIS_COMMIT}TEST -X github.com/echocat/goxr/runtime.built=`date -u +%Y-%m-%dT%H:%M:%SZ`"
- export LDNFLAG="-X github.com/echocat/goxr/runtime.name=TESTgoxrTEST"
- GOOS=linux GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-linux-amd64 ./main
- dist/goxr-linux-amd64 --version
- export LDNFLAG="-X github.com/echocat/goxr/runtime.name=TESTgoxr-serverTEST"
- GOOS=linux GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-server-linux-amd64 ./server/main
- dist/goxr-server-linux-amd64 --version
- docker build -f Dockerfile -t echocat/goxr:alpine-$TRAVIS_BRANCH .
- sh .docker/test-image.sh echocat/goxr:alpine-$TRAVIS_BRANCH
- docker build -f Dockerfile.ubuntu -t echocat/goxr:ubuntu-$TRAVIS_BRANCH .
- sh .docker/test-image.sh echocat/goxr:ubuntu-$TRAVIS_BRANCH
- stage: release
name: Release
if: tag =~ ^v\d+\.\d+\.\d+|snapshot-.+$
before_script:
- mkdir -p dist
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
script:
- export LDFLAGS="-X github.com/echocat/goxr/runtime.version=${TRAVIS_BRANCH} -X github.com/echocat/goxr/runtime.revision=${TRAVIS_COMMIT} -X github.com/echocat/goxr/runtime.built=`date -u +%Y-%m-%dT%H:%M:%SZ`"
- export LDNFLAG="-X github.com/echocat/goxr/runtime.name=goxr"
- GOOS=linux GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-linux-amd64 ./main
- GOOS=linux GOARCH=386 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-linux-386 ./main
- GOOS=darwin GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-darwin-amd64 ./main
- GOOS=darwin GOARCH=386 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-darwin-386 ./main
- GOOS=windows GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-windows-amd64.exe ./main
- GOOS=windows GOARCH=386 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-windows-386.exe ./main
- export LDNFLAG="-X github.com/echocat/goxr/runtime.name=goxr-server"
- GOOS=linux GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-server-linux-amd64 ./server/main
- GOOS=linux GOARCH=386 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-server-linux-386 ./server/main
- GOOS=darwin GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-server-darwin-amd64 ./server/main
- GOOS=darwin GOARCH=386 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-server-darwin-386 ./server/main
- GOOS=windows GOARCH=amd64 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-server-windows-amd64.exe ./server/main
- GOOS=windows GOARCH=386 go build -ldflags "$LDNFLAG $LDFLAGS" -o dist/goxr-server-windows-386.exe ./server/main
- docker build -t echocat/goxr:alpine-$TRAVIS_BRANCH .
- docker build -t echocat/goxr:ubuntu-$TRAVIS_BRANCH .
- docker tag echocat/goxr:alpine-$TRAVIS_BRANCH echocat/goxr:latest
- docker tag echocat/goxr:alpine-$TRAVIS_BRANCH echocat/goxr:$TRAVIS_BRANCH
- docker tag echocat/goxr:alpine-$TRAVIS_BRANCH echocat/goxr:alpine
- docker tag echocat/goxr:ubuntu-$TRAVIS_BRANCH echocat/goxr:ubuntu
- docker push echocat/goxr:latest
- docker push echocat/goxr:$TRAVIS_BRANCH
- docker push echocat/goxr:alpine-$TRAVIS_BRANCH
- docker push echocat/goxr:alpine
- docker push echocat/goxr:ubuntu-$TRAVIS_BRANCH
- docker push echocat/goxr:ubuntu
deploy:
provider: releases
api_key: "$GITHUB_DEPLOY_TOKEN"
file_glob: true
file: dist/*
skip_cleanup: true
name: $TRAVIS_TAG
on:
tags: true