-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
103 lines (97 loc) · 2.62 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
stages:
- build
- push
- release
variables:
DOCKERIO_MIRROR: hub.wuhoo.xyz
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:v1.9.1-debug
entrypoint: [""]
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- >-
/kaniko/executor
--registry-mirror "${DOCKERIO_MIRROR}"
--build-arg "CI_PROJECT_PATH"
--build-arg "CI_PROJECT_PATH"
--build-arg "CI_PROJECT_URL"
--build-arg "CI_COMMIT_SHORT_SHA"
--build-arg "CI_COMMIT_SHA"
--build-arg "CI_PIPELINE_ID"
--build-arg "CI_PIPELINE_URL"
--cache=true
--cache-repo "${CI_REGISTRY_IMAGE}/build-cache"
--cache-ttl 720h0m0s
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination=image
--no-push
--tarPath image.tar
artifacts:
untracked: false
expire_in: 7 days
paths:
- image.tar
when: on_success
push:
stage: push
image:
name: gcr.io/go-containerregistry/crane/debug:v0.12.0
entrypoint: [""]
script:
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- crane push image.tar ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
- crane push image.tar ${CI_REGISTRY_IMAGE}:latest
needs:
- build
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
push:release:
stage: push
image:
name: gcr.io/go-containerregistry/crane/debug:v0.12.0
entrypoint: [""]
script:
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- crane push image.tar ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
- crane push image.tar ${CI_REGISTRY_IMAGE}:stable
needs:
- build
rules:
- if: $CI_COMMIT_TAG
when: on_success
build_binary_tag:
stage: build
image: golang:1.19
before_script:
- go version
script:
- go mod tidy
- go build -v -a ./cmd/omgur
artifacts:
paths:
- omgur
only:
- tags
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- build_binary_tag
script:
- echo "Creating release for $CI_COMMIT_TAG"
release:
name: "Release $CI_COMMIT_TAG"
description: './release-notes/$CI_COMMIT_TAG/CHANGELOG.md'
tag_name: "$CI_COMMIT_TAG"
ref: "$CI_COMMIT_TAG"
assets:
links:
- name: '$CI_PROJECT_NAME-linux'
url: '$CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_TAG/raw/$CI_PROJECT_NAME?job=build_binary_tag'
only:
- tags