-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathconfig.yml
212 lines (204 loc) · 6.27 KB
/
config.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
version: 2.1
jobs:
# Build development binary
build-dev:
docker:
- image: liftbridge/liftbridge-circleci:0.2.0
environment:
GO111MODULE: "on"
steps:
- checkout
- run:
name: Build dev binary
command: |
make build-dev
- persist_to_workspace:
root: .
paths:
- liftbridge-dev
- docker/
# Run unit/integration tests and upload code coverage
test:
docker:
- image: liftbridge/liftbridge-circleci:0.2.0
environment:
GO111MODULE: "on"
steps:
- checkout
- run:
name: Install dependencies
command: |
go get github.com/mattn/goveralls
- run:
name: Test
command: |
go test -v -race . # Run tests in root but exclude from coverage
go test -v -race -coverprofile=coverage.txt.tmp ./server/...
cat coverage.txt.tmp | grep -v ".pb.go" > coverage.txt # Exclude protobuf from coverage
goveralls -coverprofile=coverage.txt -service=circle-ci -repotoken=$COVERALLS_REPO_TOKEN
# Build and publish standalone development Docker image
build-and-push-standalone-dev-image:
docker:
- image: circleci/buildpack-deps:stretch
steps:
- setup_remote_docker
- attach_workspace:
at: ~/project
- run:
name: Set image version
command: |
if [ -n "$CIRCLE_TAG" ]; then
echo "export VERSION='${CIRCLE_TAG}'" >> $BASH_ENV
else
echo "export VERSION='${CIRCLE_SHA1}'" >> $BASH_ENV
fi
- run:
name: Build image
command: |
docker build -t "liftbridge/standalone-dev:${VERSION}" -f docker/dev-standalone/Dockerfile .
docker tag "liftbridge/standalone-dev:${VERSION}" 'liftbridge/standalone-dev:latest'
- run:
name: Publish image
command: |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push "liftbridge/standalone-dev:${VERSION}"
docker push 'liftbridge/standalone-dev:latest'
# Build and publish release Docker image
build-and-push-release-image:
docker:
- image: circleci/buildpack-deps:stretch
steps:
- setup_remote_docker
- checkout
- run:
name: Set image version
command: |
if [ -n "$CIRCLE_TAG" ]; then
echo "export VERSION='${CIRCLE_TAG}'" >> $BASH_ENV
else
echo "export VERSION='${CIRCLE_SHA1}'" >> $BASH_ENV
fi
- run:
name: Build image
command: |
docker build -t "liftbridge/liftbridge:${VERSION}" .
docker tag "liftbridge/liftbridge:${VERSION}" 'liftbridge/liftbridge:latest'
- run:
name: Publish image
command: |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push "liftbridge/liftbridge:${VERSION}"
docker push 'liftbridge/liftbridge:latest'
# Build and publish release k8s Docker image
build-and-push-release-k8s-image:
docker:
- image: circleci/buildpack-deps:stretch
steps:
- setup_remote_docker
- checkout
- run:
name: Set image version
command: |
if [ -n "$CIRCLE_TAG" ]; then
echo "export VERSION='${CIRCLE_TAG}'" >> $BASH_ENV
else
echo "export VERSION='${CIRCLE_SHA1}'" >> $BASH_ENV
fi
- run:
name: Build image
command: |
docker build -t "liftbridge/liftbridge-k8s:${VERSION}" -f k8s/Dockerfile.k8s .
docker tag "liftbridge/liftbridge-k8s:${VERSION}" 'liftbridge/liftbridge-k8s:latest'
- run:
name: Publish image
command: |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push "liftbridge/liftbridge-k8s:${VERSION}"
docker push 'liftbridge/liftbridge-k8s:latest'
# Create GitHub release and upload artifacts
release:
docker:
- image: circleci/golang:1.17
resource_class: large
steps:
- checkout
- run: curl -sL https://git.io/goreleaser | bash
# Build website artifacts
build-website:
docker:
- image: circleci/node
steps:
- checkout
- run:
name: Build website
command: |
yarn --cwd website
make website/build
- persist_to_workspace:
root: .
paths:
- Makefile
- website/
# Deploy website to Google App Engine
deploy-website:
docker:
- image: google/cloud-sdk
steps:
- attach_workspace:
at: ~/project
- run:
name: Deploy website
command: |
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
gcloud config set project $GCLOUD_PROJECT_ID
make website-deploy WEBSITE_DEPLOY_FLAGS=--quiet
workflows:
version: 2
build-test-and-deploy:
jobs:
- build-dev:
filters:
tags:
only: /^v.*/
- test
- build-and-push-standalone-dev-image:
context: docker-push
requires:
- build-dev
filters:
branches:
only: master
tags:
only: /^v.*/
- build-and-push-release-image:
context: docker-push
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
- build-and-push-release-k8s-image:
context: docker-push
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
- release:
context: github-push
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
- build-website:
filters:
branches:
only: master
- deploy-website:
context: website-push
requires:
- build-website
filters:
branches:
only: master