-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
35 lines (29 loc) · 1.15 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
image: docker:19.03
services:
- docker:dind
variables:
FULL_IMAGE_NAME: $CI_REGISTRY/mollybet/kustomize-sopsgenerator/kustomizer
create_image:
only:
- tags
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# Alias version names so it's easier to understand what's going on below.
# The `| rev | cut -d"." -f2- | rev` just pops the last rightmost fragment of
# the version
- export MAJOR_MINOR_PATCH=${CI_COMMIT_TAG#v}
- export MAJOR_MINOR=$(echo $MAJOR_MINOR_PATCH | cut -d. -f1-2)
- export MAJOR=$(echo $MAJOR_MINOR | cut -d. -f1)
script:
# Publish latest
- docker build -t $FULL_IMAGE_NAME:latest .
- docker push $FULL_IMAGE_NAME:latest
# Publish patch
- docker tag $FULL_IMAGE_NAME:latest $FULL_IMAGE_NAME:$MAJOR_MINOR_PATCH
- docker push $FULL_IMAGE_NAME:$MAJOR_MINOR_PATCH
# Overwrite major minor version
- docker tag $FULL_IMAGE_NAME:latest $FULL_IMAGE_NAME:$MAJOR_MINOR
- docker push $FULL_IMAGE_NAME:$MAJOR_MINOR
# Overwrite major version
- docker tag $FULL_IMAGE_NAME:latest $FULL_IMAGE_NAME:$MAJOR
- docker push $FULL_IMAGE_NAME:$MAJOR