From 82f96679aaf7d980df07b5acb3025299c87d4f98 Mon Sep 17 00:00:00 2001 From: Ian Tewksbury Date: Wed, 16 Sep 2020 16:45:28 +0000 Subject: [PATCH] add script and doc for manually publishing images --- README.md | 53 +++++++++++++++++++++++-- manual-publish.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 3 deletions(-) create mode 100755 manual-publish.sh diff --git a/README.md b/README.md index 84517d2..71c6ca9 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ podman build --build-arg FROM_IMAGE=tssc-base --tag tssc-tool-argocd tssc-tool-a podman build --build-arg FROM_IMAGE=tssc-base --tag tssc-tool-buildah tssc-tool-buildah podman build --build-arg FROM_IMAGE=tssc-base --tag tssc-tool-config-lint tssc-tool-config-lint podman build --build-arg FROM_IMAGE=tssc-base-java-8 --tag tssc-tool-maven tssc-tool-maven -podman build --build-arg FROM_IMAGE=tssc-base --tag tssc-tool-openscap tssc-tool-openscap +podman build --build-arg FROM_IMAGE=tssc-tool-buildah --tag tssc-tool-openscap tssc-tool-openscap podman build --build-arg FROM_IMAGE=tssc-base --tag tssc-tool-skopeo tssc-tool-skopeo podman build --build-arg FROM_IMAGE=tssc-base --tag tssc-tool-sonar tssc-tool-sonar ``` @@ -108,6 +108,53 @@ podman build --build-arg FROM_IMAGE=tssc-base --tag tssc-tool-sonar tssc-tool-so > **TODO** -# Publish +## Publish +Steps for manually publishing the images that need to be manually published. -> **TODO** +* tssc-tool-buildah +* tssc-tool-openscap + +### Setup +Setup steps. +``` +yum -y install podman, buildah +``` + +### Publish edge + +#### Publish to quay.io/tssc +``` +./manual-publish.sh +``` +or +``` +./manual-publish.sh edge tssc +``` +or +``` +./manual-publish.sh edge tssc quay.io +``` + +#### Publish to personal quay.io repo +``` +./manual-publish.sh edge $QUAY_USER_NAME +``` +or +``` +./manual-publish.sh edge $QUAY_USER_NAME quay.io +``` + +### Pubish release verson + +#### Publish the v1.0.0 release version to quay.io/tssc +``` +./manual-publish.sh v1.0.0 +``` + +# How to Release? + +1. tag this repository with the release version + * ex: `v1.42.0` + * __NOTE__: must start with `v` +2. manually publish the images that can't be automatically published + * ex: `./manual-publish.sh v1.42.0 tssc quay.io` diff --git a/manual-publish.sh b/manual-publish.sh new file mode 100755 index 0000000..79a0199 --- /dev/null +++ b/manual-publish.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# PARAMS +# $1 - image version +# $2 - registry repository +# $3 - registry uri + +build_tag_push() { + IMAGE_NAME=$1 + FROM_IMAGE_NAME=$2 + + echo BUILD: ${IMAGE_NAME} + podman build --build-arg FROM_IMAGE=${REGISTRY_URI}/${REGISTRY_REPOSITORY}/${FROM_IMAGE_NAME}:${IMAGE_VERSION} --tag ${IMAGE_NAME} ${IMAGE_NAME} + + for IMAGE_TAG in ${IMAGE_TAGS}; do + FULL_TAG="${REGISTRY_URI}/${REGISTRY_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" + echo "TAG: ${FULL_TAG}" + buildah tag localhost/${IMAGE_NAME} ${FULL_TAG} + + echo "PUSH: ${FULL_TAG}" + buildah push ${FULL_TAG} + done +} + +if [ -z "$1" ]; then + IMAGE_VERSION='edge' +else + IMAGE_VERSION=$1 +fi + +if [ -z "$2" ]; then + REGISTRY_REPOSITORY='tssc' +else + REGISTRY_REPOSITORY=$2 +fi + +if [ -z "$3" ]; then + REGISTRY_URI='quay.io' +else + REGISTRY_URI=$3 +fi + +GIT_REV=$(git rev-parse HEAD) +GIT_HASH_TAG=sha-${GIT_REV::8} + +echo +echo -------------------- +echo +echo "LOGIN: ${REGISTRY_URI}" +buildah login ${REGISTRY_URI} + +echo +echo -------------------- +echo +echo CALCULATE TAGS +IMAGE_TAGS="${IMAGE_VERSION} ${GIT_HASH_TAG}" +if [[ $IMAGE_VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + MINOR=${IMAGE_VERSION%.*} + MAJOR=${MINOR%.*} + IMAGE_TAGS="${IMAGE_TAGS} ${MINOR} ${MAJOR} latest" +fi + +echo +echo -------------------- +echo +echo CONFIRMATION +echo " IMAGES: tssc-tool-buildah tssc-tool-openscap" +echo " IMAGE VERSION: ${IMAGE_VERSION}" +echo " IMAGE TAGS: ${IMAGE_TAGS}" +echo " REGISTRY REPOSITORY: ${REGISTRY_REPOSITORY}" +echo " REGISTRY_URI: ${REGISTRY_URI}" +echo + +read -p "Are you sure you want to build, tag, and push? (Y/N): " +if ! [[ $REPLY =~ ^[Yy]$ ]]; then + exit 1 +fi + +##################### +# tssc-tool-buildah # +##################### +echo +echo -------------------- +echo +IMAGE_NAME=tssc-tool-buildah +FROM_IMAGE_NAME=tssc-base +build_tag_push ${IMAGE_NAME} ${FROM_IMAGE_NAME} + +###################### +# tssc-tool-openscap # +###################### +echo +echo -------------------- +echo +IMAGE_NAME=tssc-tool-openscap +FROM_IMAGE_NAME=tssc-tool-buildah +build_tag_push ${IMAGE_NAME} ${FROM_IMAGE_NAME} +