forked from TheThingsArchive/ttn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
112 lines (103 loc) · 3.15 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
110
111
112
stages:
- test
- build
- sign
- package
variables:
CONTAINER_NAME: thethingsnetwork/ttn
PLATFORMS: linux-386 linux-amd64 linux-arm darwin-amd64 windows-386 windows-amd64
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
- for platform in $PLATFORMS; do $(echo $platform | awk -F '-' '{print "export GOOS=" $1 " GOARCH=" $2}') && make build; done
- popd
artifacts:
paths:
- release/
sign:
only:
- tags@thethingsnetwork/ttn
- master@thethingsnetwork/ttn
- develop@thethingsnetwork/ttn
stage: sign
image: golang:latest
script:
- pushd release
- shasum -a 256 $(ls) > checksums
- mkdir ~/.gnupg && chmod 700 ~/.gnupg
- echo -e "use-agent\npinentry-mode loopback" > ~/.gnupg/gpg.conf
- echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
- gpg --no-tty --batch --import /gpg/signing.ci.gpg-key
- echo $GPG_PASSPHRASE | gpg --batch --no-tty --yes --passphrase-fd 0 --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:
- tags@thethingsnetwork/ttn
- master@thethingsnetwork/ttn
- develop@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
- if [[ "$CI_BUILD_REF_NAME" == "master" ]]; then docker tag ttn $CONTAINER_NAME:latest && docker push $CONTAINER_NAME:latest; fi
azure-binaries:
only:
- tags@thethingsnetwork/ttn
- master@thethingsnetwork/ttn
- develop@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 *