Call the build/publish scripts with bash

This commit is contained in:
flow.gunso
2019-03-15 11:15:15 +01:00
parent c3907a672d
commit 7ca455805e

View File

@@ -4,35 +4,23 @@ services:
- docker:dind - docker:dind
stages: stages:
- build - build_publish
staging: staging:
stage: build stage: build_publish
before_script: before_script:
- echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
script: script:
- docker build -t $CI_REGISTRY_IMAGE:staging . - /bin/bash utils/publish/staging
- docker push $CI_REGISTRY_IMAGE:staging
only: only:
- staging - staging
production: production:
stage: build stage: build_publish
before_script: before_script:
- echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- if ! [[ "$CI_COMMIT_TAG" =~ ^[0-9]+[.][0-9]+[.][0-9]+$ ]]; then echo "Version number must match major.minor.revision!"; exit 1; fi
script: script:
- MAJOR_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $1'}) - /bin/bash utils/publish/production.sh
- MINOR_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $2'})
- REVISION_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $3'})
- MAJOR=$MAJOR_NUMBER
- MINOR=$MAJOR.$MINOR_NUMBER
- REVISION=$MINOR.$REVISION_NUMBER
- docker build -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$MAJOR -t $CI_REGISTRY_IMAGE:$MINOR -t $CI_REGISTRY_IMAGE:$REVISION .
- docker push $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:$MAJOR
- docker push $CI_REGISTRY_IMAGE:$MINOR
- docker push $CI_REGISTRY_IMAGE:$REVISION
only: only:
- tags - tags
except: except: