github.com/hs0210/hashicorp-terraform@v0.11.12-beta1/scripts/docker-release/release.sh (about) 1 #!/usr/bin/env bash 2 3 # This script is an interactive wrapper around the scripts build.sh, tag.sh 4 # and push.sh intended for use during official Terraform releases. 5 # 6 # This script should be used only when git HEAD is pointing at the release tag 7 # for what will become the new latest *stable* release, since it will update 8 # the "latest", "light", and "full" tags to refer to what was built. 9 # 10 # To release a specific version without updating the various symbolic tags, 11 # use build.sh directly and then manually push the single release tag it 12 # creates. This is appropriate both when publishing a beta version and if, 13 # for some reason, it's necessary to (re-)publish and older version. 14 15 set -eu 16 17 BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 18 cd "$BASE" 19 20 # We assume that this is always running while git HEAD is pointed at a release 21 # tag or a branch that is pointed at the same commit as a release tag. If not, 22 # this will fail since we can't build a release image for a commit that hasn't 23 # actually been released. 24 VERSION="$(git describe)" 25 VERSION_SLUG="${VERSION#v}" 26 27 # Verify that the version is already deployed to releases.hashicorp.com. 28 if curl --output /dev/null --silent --head --fail "https://releases.hashicorp.com/terraform/${VERSION_SLUG}/terraform_${VERSION_SLUG}_SHA256SUMS"; then 29 echo "===== Docker image release for Terraform $VERSION =====" 30 echo "" 31 else 32 cat >&2 <<EOT 33 34 There is no $VERSION release of Terraform on releases.hashicorp.com. 35 36 release.sh can only create docker images for released versions. Use 37 "git checkout {version}" to switch to a release tag before running this 38 script. 39 40 To create an untagged docker image for any arbitrary commit, use 'docker build' 41 directly in the root of the Terraform repository. 42 43 EOT 44 exit 1 45 fi 46 47 # Build the two images tagged with the version number 48 ./build.sh "$VERSION" 49 50 # Verify that they were built correctly. 51 echo "-- Testing $VERSION Images --" 52 echo "" 53 54 echo -n "light image version: " 55 docker run --rm -e "CHECKPOINT_DISABLE=1" "hashicorp/terraform:${VERSION_SLUG}" version 56 echo -n "full image version: " 57 docker run --rm -e "CHECKPOINT_DISABLE=1" "hashicorp/terraform:${VERSION_SLUG}-full" version 58 59 echo "" 60 61 read -p "Did both images produce suitable version output for $VERSION? " -n 1 -r 62 echo "" 63 if ! [[ $REPLY =~ ^[Yy]$ ]]; then 64 echo >&2 Aborting due to inconsistent version output. 65 exit 1 66 fi 67 echo "" 68 69 # Update the latest, light and full tags to point to the images we just built. 70 ./tag.sh "$VERSION" 71 72 # Last chance to bail out 73 echo "-- Prepare to Push --" 74 echo "" 75 echo "The following Terraform images are available locally:" 76 docker images --format "{{.ID}}\t{{.Tag}}" hashicorp/terraform 77 echo "" 78 read -p "Ready to push the tags $VERSION_SLUG, light, full, and latest up to dockerhub? " -n 1 -r 79 echo "" 80 if ! [[ $REPLY =~ ^[Yy]$ ]]; then 81 echo >&2 "Aborting because reply wasn't positive." 82 exit 1 83 fi 84 echo "" 85 86 # Actually upload the images 87 ./push.sh "$VERSION" 88 89 echo "" 90 echo "-- All done! --" 91 echo "" 92 echo "Confirm the release at https://hub.docker.com/r/hashicorp/terraform/tags/" 93 echo ""