-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
38 lines (33 loc) · 1.34 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
workflow:
rules:
# This pipeline only runs for tags
- if: $CI_COMMIT_TAG
stages:
- build
- deploy
variables:
IMAGENAME: 'collaborative-frontend-development-framework'
default:
before_script:
- EXP='^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([0-9a-zA-Z.-]*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
- VERSION=$(echo $CI_COMMIT_TAG | sed -n -E "s/$EXP/\1.\2.\3\4/p")
- TXT_RED="\e[31m"
- TXT_CLEAR="\e[0m"
build:
stage: build
image: docker:20.10
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- echo "Building $IMAGENAME - $CI_COMMIT_TAG - $CI_REGISTRY_IMAGE/$IMAGENAME:$VERSION"
- docker build -m 8g --pull -t $CI_REGISTRY_IMAGE/$IMAGENAME:$VERSION .
- docker tag $CI_REGISTRY_IMAGE/$IMAGENAME:$VERSION $CI_REGISTRY_IMAGE/$IMAGENAME:latest
- docker push $CI_REGISTRY_IMAGE/$IMAGENAME:$VERSION
- docker push $CI_REGISTRY_IMAGE/$IMAGENAME:latest
rules:
# Only run this job if a version tag exists
- if: $CI_COMMIT_TAG =~ /^v?(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
exists:
- Dockerfile
tags:
- unparallel-runner
- docker