github.com/openshift/source-to-image@v1.4.1-0.20240516041539-bf52fc02204e/hack/build-release.sh (about) 1 #!/bin/bash 2 3 # This script generates release zips into _output/releases. It requires the openshift/sti-release 4 # image to be built prior to executing this command. 5 6 set -o errexit 7 set -o nounset 8 set -o pipefail 9 set -e 10 11 STARTTIME=$(date +%s) 12 S2I_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. 13 source "${S2I_ROOT}/hack/common.sh" 14 source "${S2I_ROOT}/hack/util.sh" 15 s2i::log::install_errexit 16 17 buildCmd=${S2I_BUILD_CMD:-"podman"} 18 19 # Go to the top of the tree. 20 cd "${S2I_ROOT}" 21 22 # Build the images 23 echo "++ Building openshift/sti-release" 24 $buildCmd build -q --tag openshift/sti-release "${S2I_ROOT}/images/release" 25 26 # Clean existing output. 27 rm -rf "${S2I_LOCAL_RELEASEPATH}" 28 mkdir -p "${S2I_LOCAL_RELEASEPATH}" 29 30 # Generate version definitions. 31 # You can commit a specific version by specifying S2I_GIT_COMMIT="" prior to build 32 s2i::build::get_version_vars 33 s2i::build::save_version_vars "${S2I_ROOT}/sti-version-defs" 34 35 echo "++ Building release ${S2I_GIT_VERSION}" 36 37 # Perform the build and release in podman or docker. 38 if [[ "$(go env GOHOSTOS)" == "darwin" ]]; then 39 $buildCmd run --rm -it -e RELEASE_LDFLAGS="-w -s" \ 40 -v "${S2I_ROOT}":/opt/app-root/src/source-to-image \ 41 openshift/sti-release 42 else 43 $buildCmd run --rm -it -e RELEASE_LDFLAGS="-w -s" \ 44 -v "${S2I_ROOT}":/opt/app-root/src/source-to-image:z \ 45 openshift/sti-release 46 fi 47 48 echo "${S2I_GIT_COMMIT}" > "${S2I_LOCAL_RELEASEPATH}/.commit" 49 50 ret=$?; ENDTIME=$(date +%s); echo "$0 took $((ENDTIME - STARTTIME)) seconds"; exit "$ret"