github.com/KyaXTeam/consul@v1.4.5/build-support/scripts/release.sh (about) 1 #!/bin/bash 2 SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" 3 pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null 4 SCRIPT_DIR=$(pwd) 5 pushd ../.. > /dev/null 6 SOURCE_DIR=$(pwd) 7 popd > /dev/null 8 pushd ../functions > /dev/null 9 FN_DIR=$(pwd) 10 popd > /dev/null 11 popd > /dev/null 12 13 source "${SCRIPT_DIR}/functions.sh" 14 15 function usage { 16 cat <<-EOF 17 Usage: ${SCRIPT_NAME} [<options ...>] 18 19 Description: 20 21 This script will do a full release build of Consul. Building each component 22 is done within a docker container. In addition to building Consul this 23 script will do a few more things. 24 25 * Update version/version*.go files 26 * Update CHANGELOG.md to put things into release mode 27 * Create a release commit. It changes in the commit include the CHANGELOG.md 28 version files and the assetfs. 29 * Tag the release 30 * Generate the SHA256SUMS file for the binaries 31 * Sign the SHA256SUMS file with a GPG key 32 33 34 Options: 35 -s | --source DIR Path to source to build. 36 Defaults to "${SOURCE_DIR}" 37 38 -t | --tag BOOL Whether to add a release commit and tag the build. 39 This also controls whether we put the tree into 40 release mode 41 Defaults to 1. 42 43 -b | --build BOOL Whether to perform the build of the ui's, assetfs and 44 binaries. Defaults to 1. 45 46 -S | --sign BOOL Whether to sign the generated SHA256SUMS file. 47 Defaults to 1. 48 49 -g | --gpg-key KEY Alternative GPG key to use for signing operations. 50 Defaults to ${HASHICORP_GPG_KEY} 51 52 -v | --version VERSION The version of Consul to be built. If not specified 53 the version will be parsed from the source. 54 55 -d | --date DATE The release date. Defaults to today. 56 57 -r | --release STRING The prerelease version. Defaults to an empty pre-release. 58 59 -h | --help Print this help text. 60 EOF 61 } 62 63 function err_usage { 64 err "$1" 65 err "" 66 err "$(usage)" 67 } 68 69 function ensure_arg { 70 if test -z "$2" 71 then 72 err_usage "ERROR: option $1 requires an argument" 73 return 1 74 fi 75 76 return 0 77 } 78 79 function main { 80 declare sdir="${SOURCE_DIR}" 81 declare -i do_tag=1 82 declare -i do_build=1 83 declare -i do_sign=1 84 declare gpg_key="${HASHICORP_GPG_KEY}" 85 declare version="" 86 declare release_ver="" 87 declare release_date=$(date +"%B %d, %Y") 88 89 while test $# -gt 0 90 do 91 case "$1" in 92 -h | --help ) 93 usage 94 return 0 95 ;; 96 -s | --source ) 97 ensure_arg "-s/--source" "$2" || return 1 98 99 if ! test -d "$2" 100 then 101 err_usage "ERROR: '$2' is not a directory and not suitable for the value of -s/--source" 102 return 1 103 fi 104 105 sdir="$2" 106 shift 2 107 ;; 108 -t | --tag ) 109 ensure_arg "-t/--tag" "$2" || return 1 110 do_tag="$2" 111 shift 2 112 ;; 113 -b | --build ) 114 ensure_arg "-b/--build" "$2" || return 1 115 do_build="$2" 116 shift 2 117 ;; 118 -S | --sign ) 119 ensure_arg "-s/--sign" "$2" || return 1 120 do_sign="$2" 121 shift 2 122 ;; 123 -g | --gpg-key ) 124 ensure_arg "-g/--gpg-key" "$2" || return 1 125 gpg_key="$2" 126 shift 2 127 ;; 128 -v | --version ) 129 ensure_arg "-v/--version" "$2" || return 1 130 version="$2" 131 shift 2 132 ;; 133 -d | --date) 134 ensure_arg "-d/--date" "$2" || return 1 135 release_date="$2" 136 shift 2 137 ;; 138 -r | --release) 139 ensure_arg "-r/--release" "$2" || return 1 140 release_ver="$2" 141 shift 2 142 ;; 143 *) 144 err_usage "ERROR: Unknown argument: '$1'" 145 return 1 146 ;; 147 esac 148 done 149 150 build_release "${sdir}" "${do_tag}" "${do_build}" "${do_sign}" "${version}" "${release_date}" "${release_ver}" "${gpg_key}" 151 return $? 152 } 153 154 main "$@" 155 exit $? 156