-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
49 lines (42 loc) · 1.07 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
stages:
- build
variables:
CGO_ENABLED: 0
GOARCH: amd64
REPO_NAME: github.com/egeneralov/2fa
.build: &build
image: golang:1.14.2-alpine
stage: build
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
- export GO111MODULE=on
script:
- ls -lha
- go mod download
- go build -a -v -installsuffix cgo -ldflags="-w -s" -o ${CI_PROJECT_DIR}/2fa-${GOOS}-${GOARCH}
artifacts:
paths:
- ${CI_PROJECT_DIR}/2fa-${GOOS}-${GOARCH}
when: on_success
expire_in: 180 days
darwin:
variables:
GOOS: darwin
<<: *build
linux:
variables:
GOOS: linux
<<: *build
docker:
image: docker:latest
stage: build
services:
- docker:dind
variables:
DOCKER_BUILDKIT: 1
script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- docker build --pull -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}" .
- docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}"