Skip to content

Commit

Permalink
add script and doc for manually publishing images
Browse files Browse the repository at this point in the history
  • Loading branch information
itewk committed Sep 16, 2020
1 parent f98fe2d commit 82f9667
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 3 deletions.
53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,61 @@ 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
```
## Test

> **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`
98 changes: 98 additions & 0 deletions manual-publish.sh
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 82f9667

Please sign in to comment.