-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
52 lines (49 loc) · 1.49 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
variables:
GOOS: linux
GOARCH: amd64
CGO_ENABLED: 0
UPX_URL: https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz
NAME: mailer
stages:
- "build"
- "release"
- "deploy"
build:
image: golang:1.15-buster
stage: "build"
script:
- |
if [ ! -f "$GOPATH/bin/upx" ]; then \
apt update && apt install -y --no-install-recommends xz-utils && \
go get -v github.com/pwaller/goupx && \
curl -ksSL $UPX_URL -o /tmp/upx.tar.xz && \
mkdir -p $GOPATH/src/upx && \
tar -xJvpf /tmp/upx.tar.xz --strip-components=1 -C $GOPATH/src/upx && \
ln -s $GOPATH/src/upx/upx $GOPATH/bin/upx; \
fi
- go get -d -v
- go build -a -tags "netgo" -ldflags '-s -w -extldflags "-static"' -o mailer.bin .
- goupx mailer.bin
- if [ -f /etc/ssl/certs/ca-certificates.crt ] ; then cp /etc/ssl/certs/ca-certificates.crt . ; fi
artifacts:
name: "$CI_JOB_STAGE-$CI_COMMIT_REF_NAME"
paths:
- mailer.bin
- ca-certificates.crt
only:
refs:
- master
needs: []
release:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: "release"
needs: ["build"]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile.scratch --destination $CI_REGISTRY_IMAGE
only:
refs:
- master
when: on_success