This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
/
.gitlab-ci.yml
88 lines (81 loc) · 2.3 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
stages:
- test
- build
- package
variables:
GO111MODULE: 'on'
CONTAINER_NAME: thethingsnetwork/ttn
PLATFORMS: linux-386 linux-amd64 linux-arm darwin-amd64 windows-386 windows-amd64
cache:
key: "$CI_PROJECT_PATH"
paths:
- /go/pkg/mod
tests:
stage: test
image: golang:1.16
services:
- thethingsnetwork/rabbitmq
- redis
variables:
REDIS_HOST: redis
MQTT_ADDRESS: thethingsnetwork__rabbitmq:1883
AMQP_ADDRESS: thethingsnetwork__rabbitmq:5672
script:
- make deps
- make test
retry: 2
binaries:
stage: build
image: golang:1.16
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
- make deps
- for platform in $PLATFORMS; do $(echo $platform | awk -F '-' '{print "export GOOS=" $1 " GOARCH=" $2}') && make build; done
artifacts:
paths:
- release/
gitlab-image:
stage: package
image: docker:git
services:
- "docker:dind"
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: /certs
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"
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: /certs
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 *