forked from TheThingsArchive/ttn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
109 lines (100 loc) · 2.8 KB
/
.gitlab-ci.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
stages:
- test
- build
- sign
- package
variables:
CONTAINER_NAME: thethingsnetwork/ttn
cache:
key: "$CI_PROJECT_PATH"
paths:
- .govendor
before_script:
- mkdir -p $(pwd)/.govendor
- rm -rf $GOPATH
- mkdir -p $GOPATH/.cache && ln -s $(pwd)/.govendor $GOPATH/.cache/govendor
- mkdir -p $GOPATH/src/github.com/TheThingsNetwork && ln -s $(pwd) $GOPATH/src/github.com/TheThingsNetwork/ttn
tests:
stage: test
image: golang:latest
services:
- thethingsnetwork/rabbitmq
- redis
variables:
REDIS_HOST: redis
MQTT_ADDRESS: thethingsnetwork__rabbitmq:1883
AMQP_ADDRESS: thethingsnetwork__rabbitmq:5672
script:
- pushd $GOPATH/src/github.com/TheThingsNetwork/ttn
- make deps
- make test
- popd
binaries:
stage: build
image: golang:latest
script:
- mkdir release
- export CI_BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
- echo "date $CI_BUILD_DATE" >> release/info
- echo "commit $CI_BUILD_REF" >> release/info
- pushd $GOPATH/src/github.com/TheThingsNetwork/ttn
- make deps
- GOOS=linux GOARCH=386 make build
- GOOS=linux GOARCH=amd64 make build
- GOOS=linux GOARCH=arm make build
- GOOS=darwin GOARCH=amd64 make build
- GOOS=windows GOARCH=386 make build
- GOOS=windows GOARCH=amd64 make build
- popd
artifacts:
paths:
- release/
sign:
only:
- v1-staging@thethingsnetwork/ttn
- v2-preview@thethingsnetwork/ttn
stage: sign
image: golang:latest
script:
- pushd release
- shasum -a 256 $(ls) > checksums
- gpg --no-tty --batch --import /gpg/signing.ci.gpg-key
- gpg --no-tty --batch --no-use-agent --passphrase $GPG_PASSPHRASE --detach-sign checksums
- popd
artifacts:
paths:
- release/checksums
- release/checksums.sig
gitlab-image:
stage: package
image: docker:git
services:
- "docker:dind"
script:
- docker build -t ttn .
- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" registry.gitlab.com
- docker tag ttn registry.gitlab.com/$CONTAINER_NAME:$CI_BUILD_REF_NAME
- docker push registry.gitlab.com/$CONTAINER_NAME:$CI_BUILD_REF_NAME
dockerhub-image:
only:
- v1-staging@thethingsnetwork/ttn
- v2-preview@thethingsnetwork/ttn
stage: package
image: docker:git
services:
- "docker:dind"
script:
- docker build -t ttn .
- docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_PASSWORD"
- docker tag ttn $CONTAINER_NAME:$CI_BUILD_REF_NAME
- docker push $CONTAINER_NAME:$CI_BUILD_REF_NAME
azure-binaries:
only:
- v1-staging@thethingsnetwork/ttn
- v2-preview@thethingsnetwork/ttn
stage: package
image: registry.gitlab.com/thethingsindustries/upload
script:
- cd release
- export STORAGE_CONTAINER=release STORAGE_KEY=$AZURE_STORAGE_KEY ZIP=true TGZ=true PREFIX=$CI_BUILD_REF_NAME/
- upload *