forked from drone-plugins/drone-github-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
81 lines (74 loc) · 2.53 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
stages:
- build
- publish
## Templates
.runners: &runners
tags:
- private
- docker
- kubernetes
- amd64
.publish_container_image: &publish_container_image
<<: *runners
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- REGISTRY_AUTH=$(echo -n ${REGISTRY_USER}:${REGISTRY_PASSWORD} | base64)
- echo "{\"auths\":{\"${REGISTRY}\":{\"auth\":\"${REGISTRY_AUTH}\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context ${CI_PROJECT_DIR}
--dockerfile ${CI_PROJECT_DIR}/${CONTAINER_DOCKERFILE:-Dockerfile}
--destination ${CONTAINER_IMAGE_NAME}
${KANIKO_EXTRA_ARG}
build:
stage: build
<<: *runners
image: golang:1.12.7
before_script:
- go mod download
- mkdir -p release/linux/amd64/
script:
- GOOS=linux GOARCH=amd64 go build -o release/linux/amd64/drone-github-release -ldflags="-X 'main.version=${CI_COMMIT_TAG:-${CI_COMMIT_SHORT_SHA}}'"
artifacts:
paths:
- release/
## Gitlab: builds every commit publishing the container image in the gitlab registry
gitlab_unstable:
stage: publish
<<: *publish_container_image
variables:
REGISTRY: ${CI_REGISTRY}
REGISTRY_USER: ${CI_REGISTRY_USER}
REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD}
CONTAINER_IMAGE_NAME: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
CONTAINER_DOCKERFILE: docker/Dockerfile.linux.amd64
KANIKO_EXTRA_ARG: ""
except:
- /^v([0-9]+)\.([0-9]+)\.([0-9]+)-rc([0-9]+)-fork$/
- /^v([0-9]+)\.([0-9]+)\.([0-9]+)-fork$/
## Dockerhub: publish the image if is a release candidate or a final release
dockerhub_release_cadidate:
stage: publish
<<: *publish_container_image
variables:
REGISTRY: ${DOCKERHUB_REGISTRY}
REGISTRY_USER: ${DOCKERHUB_REGISTRY_USER}
REGISTRY_PASSWORD: ${DOCKERHUB_REGISTRY_PASSWORD}
CONTAINER_IMAGE_NAME: ${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG}
CONTAINER_DOCKERFILE: docker/Dockerfile.linux.amd64
KANIKO_EXTRA_ARG: ""
only:
- /^v([0-9]+)\.([0-9]+)\.([0-9]+)-rc([0-9]+)-fork$/
dockerhub_stable:
stage: publish
<<: *publish_container_image
variables:
REGISTRY: ${DOCKERHUB_REGISTRY}
REGISTRY_USER: ${DOCKERHUB_REGISTRY_USER}
REGISTRY_PASSWORD: ${DOCKERHUB_REGISTRY_PASSWORD}
CONTAINER_IMAGE_NAME: ${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG}
CONTAINER_DOCKERFILE: docker/Dockerfile.linux.amd64
KANIKO_EXTRA_ARG: "--destination ${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:latest"
only:
- /^v([0-9]+)\.([0-9]+)\.([0-9]+)-fork$/