1
0
intel-media-ffmpeg/scripts/push-rolling-image.sh
James Ketrenos 363f40de52 Refactored scripts/* and .gitlab-ci.yml
Fix #6: Define TAG in .gitlab-ci.yml and update scripts to defer to it.

renamed:    scripts/push-test-image.sh -> scripts/push-image.sh
renamed:    scripts/test-tag.sh -> scripts/test-image.sh

Refactored some of the scripts/* so they are generic and not tied to CI usages.

Added error checking and output to push-rolling-image.sh and remove-tag.sh

Added scripts/trigger.sh to auto-trigger builds.

Signed-off-by: James Ketrenos <james.p.ketrenos@intel.com>
2019-12-17 21:04:52 -08:00

62 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Bring in the variables from SOLUTION file, supporting
# nested substitution
. SOLUTION
. MANIFEST
VARS=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" SOLUTION))
VARS+=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" MANIFEST))
for var in ${VARS[@]}; do
export ${var}
done
RELEASE_INFO=${RELEASE_INFO:-N/A}
[[ "${RELEASE_INFO}" == "N/A" ]] && {
TAG=${TAG:-${OS_DISTRO}-${PACKAGE_STREAM}-$(date +%Y%m%d)}
} || {
TAG=${TAG:-${OS_DISTRO}-${PACKAGE_STREAM}-${RELEASE_INFO}}
}
[[ "${TARGET_TAG}" != "" ]] || {
echo >&2 "TARGET_TAG needs to be set to the tag to push to Harbor"
exit 1
}
function fail {
>&2 echo "$*"
exit -1
}
cat << EOF
The following will done to publish latest rolling image:
1. Pull ${CONTAINER}:${TAG}
2. Tag #1 as ${CONTAINER}:${TARGET_TAG}
3. Tag #1 as ${CONTAINER}:latest-${TARGET_TAG}
4. Push #2
5. Push #3
6. Delete ${CONTAINER}:${TAG}
EOF
docker pull ${REGISTRY_URL}/${CONTAINER}:${TAG} ||
fail "Unable to pull image"
docker tag ${REGISTRY_URL}/${CONTAINER}:${TAG} \
${REGISTRY_URL}/${CONTAINER}:${TARGET_TAG} ||
fail "Unable to tag image (1/2)"
docker tag ${REGISTRY_URL}/${CONTAINER}:${TAG} \
${REGISTRY_URL}/${CONTAINER}:latest-${TARGET_TAG} ||
fail "Unable to tag image (2/2)"
docker push ${REGISTRY_URL}/${CONTAINER}:${TARGET_TAG} ||
fail "Unable to push ${CONTAINER}:${TARGET_TAG}"
docker push ${REGISTRY_URL}/${CONTAINER}:latest-${TARGET_TAG} ||
fail "Unable to push ${CONTAINER}:latest-${TARGET_TAG}"
echo "Done tagging and pushing ${CONTAINER} as ${TARGET_TAG}"