-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
46 lines (40 loc) · 1.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
image: golang:latest
variables:
ARTIFACT_NAME: turn
REPO_NAME: kerberos-io/${ARTIFACT_NAME}
REPO_DIR: gitlab.com/${REPO_NAME}
CI_VERSION: "1.0.${CI_JOB_ID}"
DOCKER_HOST: tcp://localhost:2375
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_DIR)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_DIR
- cd $GOPATH/src/$REPO_DIR
stages:
- test
- build
- docker
# - kubernetes
test:
stage: test
script:
- git config --global url."https://${gitlab_id}:${gitlab_token}@gitlab.com/".insteadOf "https://gitlab.com/"
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
- go test -race $(go list ./... | grep -v /vendor/)
build:
stage: build
script:
- git config --global url."https://${gitlab_id}:${gitlab_token}@gitlab.com/".insteadOf "https://gitlab.com/"
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/$ARTIFACT_NAME
artifacts:
paths:
- $ARTIFACT_NAME
docker:
image: docker:19.03.12
stage: docker
services:
- docker:18.09.7-dind
script:
- docker login -u ${gitlab_id} -p ${gitlab_token} $CI_REGISTRY
- docker build --build-arg gitlab_id=${gitlab_id} --build-arg gitlab_token=${gitlab_token} -t $CI_REGISTRY/$REPO_NAME:$CI_VERSION .
- docker push $CI_REGISTRY/$REPO_NAME:$CI_VERSION