github.com/boson-project/source-to-image@v1.2.0/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 10 STARTTIME=$(date +%s) 11 S2I_ROOT=$(dirname "${BASH_SOURCE}")/.. 12 source "${S2I_ROOT}/hack/common.sh" 13 source "${S2I_ROOT}/hack/util.sh" 14 s2i::log::install_errexit 15 16 # Go to the top of the tree. 17 cd "${S2I_ROOT}" 18 19 # Build the images 20 echo "++ Building openshift/sti-release" 21 podman build -q --tag openshift/sti-release "${S2I_ROOT}/images/release" 22 23 context="${S2I_ROOT}/_output/buildenv-context" 24 25 # Clean existing output. 26 rm -rf "${S2I_LOCAL_RELEASEPATH}" 27 rm -rf "${context}" 28 mkdir -p "${context}" 29 mkdir -p "${S2I_LOCAL_RELEASEPATH}" 30 31 # Generate version definitions. 32 # You can commit a specific version by specifying S2I_GIT_COMMIT="" prior to build 33 s2i::build::get_version_vars 34 s2i::build::save_version_vars "${context}/sti-version-defs" 35 36 echo "++ Building release ${S2I_GIT_VERSION}" 37 38 # Create the input archive. 39 git archive --format=tar -o "${context}/archive.tar" "${S2I_GIT_COMMIT}" 40 tar -rf "${context}/archive.tar" -C "${context}" sti-version-defs 41 gzip -f "${context}/archive.tar" 42 43 # Perform the build and release in podman. 44 cat "${context}/archive.tar.gz" | podman run -i --cidfile="${context}/cid" -e RELEASE_LDFLAGS="-w -s" openshift/sti-release 45 podman cp $(cat ${context}/cid):/go/src/github.com/openshift/source-to-image/_output/local/releases "${S2I_OUTPUT}" 46 echo "${S2I_GIT_COMMIT}" > "${S2I_LOCAL_RELEASEPATH}/.commit" 47 48 ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"