#!/bin/sh12# This script gets called from CI to establish the name of the current docker3# tag to build and also the image which is used to seed the cache.45# ****************************************************************************6# Copyright (C) 2018 Julian Rüth <[email protected]>7#8# This program is free software: you can redistribute it and/or modify9# it under the terms of the GNU General Public License as published by10# the Free Software Foundation, either version 2 of the License, or11# (at your option) any later version.12# http://www.gnu.org/licenses/13# ****************************************************************************1415set -ex1617# The maintainer of the CI environment, e.g., the people administrating the18# SageMath account on gitlab.com, can decide to inject an arbitrary19# base64-encoded script early into the CI execution. The script has access to20# all the CI variables, e.g., to find out which job is being executed, and21# it could do things such as "exit 1" to fail early, or "git merge" a fix for a22# known bug in CI. The CI_MONKEY_PATCH could of course also curl a more23# complicated script and execute that.24if [ -n "$CI_MONKEY_PATCH" ]; then25SCRIPT=$(echo "$CI_MONKEY_PATCH" | base64 -d)26$SCRIPT27fi2829# From the docker documentation: "A tag name must be valid ASCII and may30# contain lowercase and uppercase letters, digits, underscores, periods and31# dashes. A tag name may not start with a period or a dash and may contain a32# maximum of 128 characters."33export DOCKER_TAG=`echo $DOCKER_TAG | tr -d '[:space:]' | tr -c '[:alnum:]_.-' '-' | sed 's/^[-.]*//' | cut -c1-128`3435[[ -z "$DOCKER_TAG" ]] && export DOCKER_TAG=none36[[ "$DOCKER_TAG" = "master" ]] && export DOCKER_TAG=latest3738export DOCKER_IMAGE_CLI=${DOCKER_NAMESPACE:-sagemath}/sagemath:$DOCKER_TAG39export DOCKER_IMAGE_DEV=${DOCKER_NAMESPACE:-sagemath}/sagemath-dev:$DOCKER_TAG4041export DOCKER_IMAGE_BINDER="${DOCKER_NAMESPACE:-sagemath}/sagemath:${CI_COMMIT_SHA}"4243# Seed the build cache with this image (set to source-clean to build from44# scratch.)45export ARTIFACT_BASE=${ARTIFACT_BASE:-$DEFAULT_ARTIFACT_BASE}464748