-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
66 lines (61 loc) · 1.74 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
# Variables
variables:
DOCKER_DRIVER: "overlay2"
DOCKER_HOST: "tcp://docker:2376"
DOCKER_TLS_VERIFY: 1
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_CERT_PATH: "/certs/client"
get_version:
stage: .pre
image: alpine:edge
before_script:
- apk add --no-cache -U jq curl
script:
- |
# Get latest version
KCPTUN_BRANCH=$(curl -sS https://api.github.com/repos/xtaci/kcptun/releases/latest | jq -cre '.tag_name')
# Debug
echo "Version: ${KCPTUN_BRANCH}"
echo -n "${KCPTUN_BRANCH}" > .version
artifacts:
paths:
- .version
.build-image:
stage: build
image: docker:23
services:
- docker:23-dind
variables:
KCPTUN_BRANCH: "master"
before_script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" ${CI_REGISTRY}
build-master:
extends: .build-image
script:
# Master tag
- docker build --pull --build-arg KCPTUN_BRANCH=${KCPTUN_BRANCH} -t "${CI_REGISTRY_IMAGE}:${KCPTUN_BRANCH}" .
- docker push "${CI_REGISTRY_IMAGE}:${KCPTUN_BRANCH}"
only:
- master
build-stable:
extends: .build-image
needs:
- get_version
script:
- export KCPTUN_BRANCH=$(cat .version)
# Latest tag
- docker build --pull --build-arg KCPTUN_BRANCH=${KCPTUN_BRANCH} -t "${CI_REGISTRY_IMAGE}" .
- docker push "${CI_REGISTRY_IMAGE}"
# Version tag
- docker tag "${CI_REGISTRY_IMAGE}" "${CI_REGISTRY_IMAGE}:${KCPTUN_BRANCH}"
- docker push "${CI_REGISTRY_IMAGE}:${KCPTUN_BRANCH}"
only:
- master
build:
extends: .build-image
script:
# Git SHA tag
- docker build --pull --build-arg KCPTUN_BRANCH=${KCPTUN_BRANCH} -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}" .
- docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}"
except:
- master