Commit dfb4aadb authored by Sandro Mathys's avatar Sandro Mathys
Browse files

fail if version already exists

parent 99366b96
# TODO: explanation wrt staging/production
default:
tags:
- docker-host-linux
......@@ -141,6 +143,7 @@ package production:
# TODO: only run this in production
# TODO: add tag to branch?
# if the version in Chart.yaml was increased, let's save and push a new version - otherwise, fail
upload staging:
stage: upload
environment:
......@@ -149,9 +152,10 @@ upload staging:
- staging
interruptible: true
script:
- echo "${SHIBBOLETH_SP_HELM_CHART_REGISTRY_TOKEN}" | helm registry login "${CI_REGISTRY}/maps/shibboleth-sp-helm-chart/" -u "gitlab-ci-shibboleth-sp-helm-chart" --password-stdin
- chart_version=$(grep "^version:" chart/Chart.yaml | sed "s/^.*:\W*//")
# check if this version already exists - if so, nothing more to do
- helm chart pull "cr.gitlab-int.switch.ch/maps/shibboleth-sp-helm-chart/chart/shibboleth-sp:${chart_version}" > /dev/null && exit 0
- echo "Found version ${chart_version} in Chart.yaml"
- echo "${SHIBBOLETH_SP_HELM_CHART_REGISTRY_TOKEN}" | helm registry login "${CI_REGISTRY}/maps/shibboleth-sp-helm-chart/" -u "gitlab-ci-shibboleth-sp-helm-chart" --password-stdin
# check if this version already exists (i.e. it can be downloaded) - if so, fail, otherwise continue
- helm chart pull "cr.gitlab-int.switch.ch/maps/shibboleth-sp-helm-chart/chart/shibboleth-sp:${chart_version}" > /dev/null && ( echo "FATAL - the version in Chart.yaml already exist in the repository"; exit 1 )
- helm chart save chart "cr.gitlab-int.switch.ch/maps/shibboleth-sp-helm-chart/chart/shibboleth-sp"
- helm chart push "cr.gitlab-int.switch.ch/maps/shibboleth-sp-helm-chart/chart/shibboleth-sp:${chart_version}"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment