Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | eb84a63 | 2024-03-21 13:36:32 -0400 | [diff] [blame] | 3 | # Copyright 2018-2024 Open Networking Foundation Contributors |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Joey Armstrong | eb84a63 | 2024-03-21 13:36:32 -0400 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
| 17 | # SPDX-FileCopyrightText: 2018-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 20 | # Intent: |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 21 | # builds (with make) and uploads release artifacts (binaries, etc.) to github |
| 22 | # given a tag also create checksums files and release notes from the commit |
| 23 | # message |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 24 | # ----------------------------------------------------------------------- |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 25 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 26 | set -euo pipefail |
| 27 | |
| 28 | ##-------------------## |
| 29 | ##---] GLOBALS [---## |
| 30 | ##-------------------## |
| 31 | declare -g WORKSPACE |
| 32 | declare -g GERRIT_PROJECT |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 33 | declare -g __githost=github.com |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 34 | # export DEBUG=1 |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 35 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 36 | declare -g pgm |
| 37 | pgm="$(readlink --canonicalize-existing "$0")" |
| 38 | readonly pgm |
| 39 | declare libdir="${pgm:0:-3}" |
| 40 | readonly libdir |
| 41 | |
| 42 | ##--------------------## |
| 43 | ##---] INCLUDES [---## |
| 44 | ##--------------------## |
| 45 | source "$libdir/help.sh" |
| 46 | source "$libdir/parse-args.sh" |
| 47 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 48 | ## ----------------------------------------------------------------------- |
| 49 | ## Uncomment to activate |
| 50 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 51 | # declare -g -i debug |
| 52 | |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 53 | # Debug arguments |
| 54 | # declare -i -g argv_gen_version=1 |
| 55 | # declare -i -g draft_release=1 |
Joey Armstrong | 41923cc | 2023-01-30 14:38:16 -0500 | [diff] [blame] | 56 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 57 | declare -a -g ARGV=() # Capture args to minimize globals and arg passing |
| 58 | [[ $# -gt 0 ]] && ARGV=("$@") |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 59 | |
| 60 | declare -g scratch # temp workspace for downloads |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 61 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 62 | declare -g SCRIPT_VERSION='1.5' # git changeset needed |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 63 | |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 64 | ##--------------------## |
| 65 | ##---] INCLUDES [---## |
Joey Armstrong | 1962bcf | 2023-01-27 13:53:18 -0500 | [diff] [blame] | 66 | ##--------------------# |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 67 | |
| 68 | ## ----------------------------------------------------------------------- |
| 69 | ## Intent: Register an interrupt handler to display a stack trace on error |
| 70 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 71 | function bannerEL() |
| 72 | { |
| 73 | # echo " $i: ${BASH_SOURCE[$i+1]}:${BASH_LINENO[$i]} ${FUNCNAME[$i]}(...)" |
| 74 | |
| 75 | # iam="${0##*/}" |
| 76 | if [[ -v debug ]]; then |
| 77 | if [[ $# -gt 0 ]]; then |
| 78 | local type="$1"; shift |
| 79 | else |
| 80 | local type='LEAVE' |
| 81 | fi |
| 82 | |
| 83 | local func="${FUNCNAME[1]}" |
| 84 | local line="${BASH_LINENO[1]}" |
| 85 | case "$type" in |
| 86 | LEAVE) ;; |
| 87 | *) type='ENTER' ;; |
| 88 | esac |
| 89 | |
| 90 | printf "** %s %s (LINENO:%s)\n" "$func" "$type" "$line" |
| 91 | fi |
| 92 | |
| 93 | return |
| 94 | } |
| 95 | |
| 96 | ## ----------------------------------------------------------------------- |
| 97 | ## Intent: Register an interrupt handler to display a stack trace on error |
| 98 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 99 | function errexit() |
| 100 | { |
| 101 | local err=$? |
| 102 | set +o xtrace |
| 103 | local code="${1:-1}" |
| 104 | |
| 105 | local prefix="${BASH_SOURCE[1]}:${BASH_LINENO[0]}" |
| 106 | echo -e "\nOFFENDER: ${prefix}" |
| 107 | if [ $# -gt 0 ] && [ "$1" == '--stacktrace-quiet' ]; then |
| 108 | code=1 |
| 109 | else |
| 110 | echo "ERROR: '${BASH_COMMAND}' exited with status $err" |
| 111 | fi |
| 112 | |
| 113 | # Print out the stack trace described by $function_stack |
| 114 | if [ ${#FUNCNAME[@]} -gt 2 ] |
| 115 | then |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 116 | echo "Call tree:" |
| 117 | for ((i=1;i<${#FUNCNAME[@]}-1;i++)) |
| 118 | do |
| 119 | echo " $i: ${BASH_SOURCE[$i+1]}:${BASH_LINENO[$i]} ${FUNCNAME[$i]}(...)" |
| 120 | done |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 121 | fi |
| 122 | |
| 123 | echo "Exiting with status ${code}" |
| 124 | echo |
| 125 | exit "${code}" |
| 126 | # return |
| 127 | } |
| 128 | |
| 129 | # trap ERR to provide an error handler whenever a command exits nonzero |
| 130 | # this is a more verbose version of set -o errexit |
| 131 | trap errexit ERR |
| 132 | |
| 133 | # setting errtrace allows our ERR trap handler to be propagated to functions, |
| 134 | # expansions and subshells |
| 135 | set -o errtrace |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 136 | |
| 137 | ## ----------------------------------------------------------------------- |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 138 | ## Intent: Cleanup scratch area on exit |
| 139 | ## ----------------------------------------------------------------------- |
| 140 | function sigtrap() |
| 141 | { |
| 142 | ## Prevent mishaps |
| 143 | local is_read_only |
| 144 | is_read_only="$(declare -p scratch)" |
| 145 | if [[ $is_read_only != *"declare -r scratch="* ]]; then |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 146 | echo "ERROR: variable scratch is not read-only, cleanup skipped" |
| 147 | exit 1 |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 148 | fi |
| 149 | |
| 150 | if [ -d "$scratch" ]; then |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 151 | /bin/rm -fr "$scratch" |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 152 | fi |
| 153 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 154 | # shellcheck disable=SC2119 |
| 155 | do_logout |
| 156 | |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 157 | return |
| 158 | } |
| 159 | trap sigtrap EXIT |
| 160 | |
| 161 | ## ----------------------------------------------------------------------- |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 162 | ## Intent: Return a random release version string. |
| 163 | ## ----------------------------------------------------------------------- |
| 164 | ## Note: Do not use this function in production. get_version() is |
| 165 | ## intended for local use or debugging $0 from within a jenkins |
| 166 | ## job. |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 167 | ## ----------------------------------------------------------------------- |
| 168 | function get_version() |
| 169 | { |
Joey Armstrong | 1cc9029 | 2024-04-02 09:27:33 -0400 | [diff] [blame] | 170 | local -n ref=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 171 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 172 | declare -a rev=() |
| 173 | rev+=("$(( RANDOM % 10 + 1 ))") |
| 174 | rev+=("$(( RANDOM % 256 + 1 ))") |
Joey Armstrong | eef8c2c | 2023-03-27 17:27:43 -0400 | [diff] [blame] | 175 | rev+=("$(( RANDOM % 10000 + 1 ))") |
Joey Armstrong | fc20ed5 | 2023-04-03 19:37:58 -0400 | [diff] [blame] | 176 | local ver="v${rev[0]}.${rev[1]}.${rev[2]}" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 177 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 178 | func_echo "GENERATED VERSION STRING: $ver" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 179 | ref="$ver" |
| 180 | return |
| 181 | } |
| 182 | |
| 183 | ## ----------------------------------------------------------------------- |
| 184 | ## Intent: Provide defaults for environment variables |
| 185 | ## ----------------------------------------------------------------------- |
| 186 | function initEnvVars() |
| 187 | { |
| 188 | # when not running under Jenkins, use current dir as workspace and a blank |
| 189 | # project name |
| 190 | declare -g WORKSPACE=${WORKSPACE:-.} |
| 191 | declare -g GERRIT_PROJECT=${GERRIT_PROJECT:-} |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 192 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 193 | # Github organization (or user) this project is published on. Project name should |
| 194 | # be the same on both Gerrit and GitHub |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 195 | declare -g GITHUB_ORGANIZATION=${GITHUB_ORGANIZATION:-} |
| 196 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 197 | # glob pattern relative to project dir matching release artifacts |
| 198 | # ARTIFACT_GLOB=${ARTIFACT_GLOB:-"release/*"} # stat -- release/* not found, literal string (?) |
| 199 | declare -g ARTIFACT_GLOB=${ARTIFACT_GLOB:-"release/."} |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 200 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 201 | # Use "release" as the default makefile target, can be a space separated list |
| 202 | declare -g RELEASE_TARGETS=${RELEASE_TARGETS:-release} |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 203 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 204 | # Set and handle GOPATH and PATH |
| 205 | export GOPATH=${GOPATH:-$WORKSPACE/go} |
| 206 | export PATH=$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:$GOPATH/bin |
| 207 | return |
| 208 | } |
| 209 | |
| 210 | ## ----------------------------------------------------------------------- |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 211 | ## Intent: Create a scratch area for downloads and transient tools |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 212 | ## temp directory will be automatically removed upon exit. |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 213 | ## ----------------------------------------------------------------------- |
| 214 | function init() |
| 215 | { |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 216 | local pkgbase="${0##*/}" # basename |
| 217 | local pkgname="${pkgbase%.*}" |
| 218 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 219 | bannerEL 'ENTER' |
| 220 | |
Joey Armstrong | ad7b1e0 | 2023-03-27 11:55:48 -0400 | [diff] [blame] | 221 | # initEnvVars # moved to full_banner() |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 222 | |
| 223 | ## Create a temp directory for auto-cleanup |
| 224 | declare -g scratch |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 225 | scratch="$(mktemp -d -t "${pkgname}.XXXXXXXXXX")" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 226 | readonly scratch |
| 227 | declare -p scratch |
| 228 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 229 | ## prime the stream: cache answers |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 230 | local work |
| 231 | get_release_dir work |
| 232 | declare -p work |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 233 | |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 234 | local git_version |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 235 | getGitVersion git_version |
| 236 | func_echo "$(declare -p git_version)" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 237 | return |
| 238 | } |
| 239 | |
| 240 | ## ----------------------------------------------------------------------- |
| 241 | ## Intent: Verbose output for logging |
| 242 | ## ----------------------------------------------------------------------- |
| 243 | function banner() |
| 244 | { |
| 245 | local iam="${0##*/}" |
| 246 | cat <<EOB |
| 247 | |
| 248 | ** ----------------------------------------------------------------------- |
| 249 | ** ${iam}::${FUNCNAME[1]}: $* |
| 250 | ** ----------------------------------------------------------------------- |
| 251 | EOB |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 255 | ## Intent: Output a log banner to identify the running script/version. |
| 256 | ## ----------------------------------------------------------------------- |
| 257 | ## TODO: |
| 258 | ## o SCRIPT_VERSION => git changeset for repo:ci-managment |
| 259 | ## o echo "library version: ${env."library.libName.version"}" |
| 260 | # ----------------------------------------------------------------------- |
| 261 | # 14:18:38 > git fetch --no-tags --progress -- https://gerrit.opencord.org/ci-management.git +refs/heads/*:refs/remotes/origin/* # timeout=10 |
| 262 | # 14:18:39 Checking out Revision 50f6e0b97f449b32d32ec0e02d59642000351847 (master) |
| 263 | # ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 264 | function full_banner() |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 265 | { |
Joey Armstrong | ad7b1e0 | 2023-03-27 11:55:48 -0400 | [diff] [blame] | 266 | local iam="${0##*/}" |
| 267 | |
| 268 | initEnvVars # set defaults |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 269 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 270 | cat <<EOH |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 271 | |
| 272 | ** ----------------------------------------------------------------------- |
| 273 | ** IAM: ${iam} :: ${FUNCNAME[0]} |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 274 | ** ARGV: ${ARGV[@]} |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 275 | ** PWD: $(/bin/pwd) |
| 276 | ** NOW: $(date '+%Y/%m/%d %H:%M:%S') |
| 277 | ** VER: ${SCRIPT_VERSION:-'unknown'} |
| 278 | ** ----------------------------------------------------------------------- |
Joey Armstrong | ad7b1e0 | 2023-03-27 11:55:48 -0400 | [diff] [blame] | 279 | ** GERRIT_PROJECT: $(declare -p GERRIT_PROJECT) |
| 280 | ** GITHUB_ORGANIZATION: $(declare -p GITHUB_ORGANIZATION) |
| 281 | ** RELEASE_TARGETS: $(declare -p RELEASE_TARGETS) |
| 282 | ** GOPATH: $(declare -p GOPATH) |
| 283 | ** ----------------------------------------------------------------------- |
| 284 | ** PATH += /usr/lib/go-1.12/bin:/usr/local/go/bin:GOPATH/bin |
| 285 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 286 | EOH |
| 287 | |
| 288 | return |
| 289 | } |
| 290 | |
Joey Armstrong | af577ab | 2022-12-15 14:43:33 -0500 | [diff] [blame] | 291 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 292 | ## Intent: Display a message with 'iam' identifier for logging |
Joey Armstrong | 50f6e0b | 2023-01-24 14:14:08 -0500 | [diff] [blame] | 293 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 294 | function func_echo() |
Joey Armstrong | 1962bcf | 2023-01-27 13:53:18 -0500 | [diff] [blame] | 295 | { |
| 296 | local iam="${0##*/}" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 297 | echo "** ${iam} :: ${FUNCNAME[1]}: $*" |
Joey Armstrong | 1962bcf | 2023-01-27 13:53:18 -0500 | [diff] [blame] | 298 | return |
| 299 | } |
| 300 | |
| 301 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 302 | ## Intent: Display an error message then exit with status. |
| 303 | ## ----------------------------------------------------------------------- |
| 304 | function error() |
| 305 | { |
| 306 | local iam="${0##*/}" |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 307 | local func="${FUNCNAME[1]}" |
| 308 | local line="${BASH_LINENO[1]}" |
| 309 | printf "\nERROR %s :: %s (LINENO:%s): %s" "$iam" "$func" "$line" "$*" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 310 | exit 1 |
| 311 | } |
| 312 | |
| 313 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 314 | ## Intent: Script self checking, direct API access for troubleshooting |
| 315 | ## ----------------------------------------------------------------------- |
| 316 | function do_api_validation() |
| 317 | { |
| 318 | # if --verify credentials |
| 319 | do_login |
| 320 | # shellcheck disable=SC2119 |
| 321 | do_logout |
| 322 | return |
| 323 | } |
| 324 | |
| 325 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 326 | ## Intent: Verify sandbox/build is versioned for release. |
| 327 | ## ----------------------------------------------------------------------- |
| 328 | function getGitVersion() |
| 329 | { |
Joey Armstrong | 1cc9029 | 2024-04-02 09:27:33 -0400 | [diff] [blame] | 330 | local -n varname=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 331 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 332 | bannerEL 'ENTER' |
| 333 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 334 | local __ver # use prefix('__') to protect callers variable name |
| 335 | if [[ -v cached_getGitVersion ]]; then |
| 336 | __ver="$cached_getGitVersion" |
| 337 | varname="$__ver" |
| 338 | return |
Joey Armstrong | 39fac65 | 2023-03-27 18:50:43 -0400 | [diff] [blame] | 339 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 340 | elif [[ -v argv_gen_version ]]; then |
| 341 | get_version __ver |
| 342 | |
| 343 | elif [[ -v WORKSPACE ]] && [[ -v GITHUB_TOKEN ]]; then # i_am_jenkins |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 344 | local path="$GERRIT_PROJECT" |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 345 | pushd "$path" || { error "pushd GERRIT_PROJECT= failed $(declare -p path)"; } |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 346 | __ver="$(git tag -l --points-at HEAD)" |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 347 | popd || { error "popd GERRIT_PROJECT= failed"; } |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 348 | |
| 349 | elif [[ -v argv_version_file ]]; then # local debug |
| 350 | [[ ! -f VERSION ]] && error "./VERSION file not found" |
| 351 | readarray -t tmp < <(sed -e 's/[[:blank:]]//g' 'VERSION') |
| 352 | __ver="v${tmp[0]}" |
| 353 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 354 | elif [[ ${#GERRIT_PROJECT} -gt 0 ]]; then |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 355 | cd .. |
| 356 | local path="$GERRIT_PROJECT" |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 357 | declare -p path |
| 358 | pushd "$path" || { error "pushd GERRIT_PROJECT= failed $(declare -p path)"; } |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 359 | __ver="$(git tag -l --points-at HEAD)" |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 360 | popd || { error "popd GERRIT_PROJECT= failed"; } |
| 361 | |
| 362 | else # pwd==sandbox |
| 363 | |
| 364 | local line="${BASH_LINENO[0]}" |
| 365 | local message=" |
| 366 | GERRIT_PROJECT= is not defined: |
| 367 | o One of the following are required: |
| 368 | - Define GERRIT_PROJECT= (~jenkins). |
| 369 | - Argument --verison-file. |
| 370 | " |
| 371 | error "$message" |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 372 | fi |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 373 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 374 | # ------------------------------------------------------ |
| 375 | # match bare versions or v-prefixed golang style version |
| 376 | # Critical failure for new/yet-to-be-released repo ? |
| 377 | # ------------------------------------------------------ |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 378 | if [[ "$__ver" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then |
Joey Armstrong | fc20ed5 | 2023-04-03 19:37:58 -0400 | [diff] [blame] | 379 | echo "git has a SemVer released version tag: '$__ver'" |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 380 | echo "Building artifacts for GitHub release." |
| 381 | |
| 382 | elif [[ "$__ver" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)-dev([0-9]+)$ ]]; then |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 383 | # v1.2.3-dev (*-dev*) is an implicit draft release. |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 384 | declare -i -g draft_release=1 |
| 385 | echo "Detected --draft SemVer release version tag [$__ver]" |
| 386 | echo "Building artifacts for GitHub release." |
| 387 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 388 | # Should also accept: X.Y.Z-{alpha,beta,...} |
Joey Armstrong | 4f87de8 | 2023-08-25 12:42:39 -0400 | [diff] [blame] | 389 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 390 | else |
Joey Armstrong | 4f87de8 | 2023-08-25 12:42:39 -0400 | [diff] [blame] | 391 | echo "Version string contains: [${__ver}]" |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 392 | error "No SemVer released version tag found, exiting..." |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 393 | fi |
| 394 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 395 | ## Cache value for subsequent calls. |
| 396 | ## readonly is a guarantee assignment happens once. |
| 397 | declare -g cached_getGitVersion="$__ver" |
| 398 | readonly cached_getGitVersion; |
| 399 | |
| 400 | varname="$__ver" |
| 401 | func_echo "Version is [$__ver] from $(/bin/pwd)" |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 402 | |
| 403 | bannerEL 'LEAVE' |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 404 | return |
| 405 | } |
| 406 | |
| 407 | ## ----------------------------------------------------------------------- |
| 408 | ## Intent: |
| 409 | ## Note: Release description is sanitized version of the log message |
| 410 | ## ----------------------------------------------------------------------- |
| 411 | function getReleaseDescription() |
| 412 | { |
Joey Armstrong | 1cc9029 | 2024-04-02 09:27:33 -0400 | [diff] [blame] | 413 | local -n varname=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 414 | |
| 415 | local msg |
| 416 | msg="$(git log -1 --pretty=%B)" |
| 417 | |
| 418 | local val |
| 419 | val="$(tr -dc "[:alnum:]\n\r\.\[\]\:\-\\\/\`\' " <<< "$msg")" |
| 420 | |
| 421 | [[ ${#val} -eq 0 ]] && error "Release Description is empty ($msg)" |
| 422 | varname="$val" |
| 423 | return |
| 424 | } |
| 425 | |
| 426 | ## ----------------------------------------------------------------------- |
| 427 | ## Intent: Retrieve value of the release temp directory. |
| 428 | ## ----------------------------------------------------------------------- |
| 429 | ## Note: Limit use of globals so logic can be isolated in function calls. |
| 430 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 431 | function get_release_dir() |
| 432 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 433 | local -n varname=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 434 | |
| 435 | # Temporary staging directory to copy artifacts to |
| 436 | varname="$scratch/release" |
| 437 | mkdir -p "$varname" |
| 438 | return |
| 439 | } |
| 440 | |
| 441 | ## ----------------------------------------------------------------------- |
| 442 | ## Intent: Retrieve github server hostname |
| 443 | ## ----------------------------------------------------------------------- |
| 444 | function get_gh_hostname() |
| 445 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 446 | local -n varname=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 447 | varname+=('--hostname' "${__githost}") |
| 448 | return |
| 449 | } |
| 450 | |
| 451 | ## ----------------------------------------------------------------------- |
| 452 | ## Intent: Retrieve repository organizaiton name |
| 453 | ## ----------------------------------------------------------------------- |
| 454 | function get_gh_repo_org() |
| 455 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 456 | local -n ref=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 457 | declare -g __repo_org |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 458 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 459 | local org |
| 460 | if [[ -v __repo_org ]]; then |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 461 | org="$__repo_org" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 462 | elif [[ ! -v GITHUB_ORGANIZATION ]]; then |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 463 | error "--repo-org or GITHUB_ORGANIZATION= are required" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 464 | else |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 465 | org="${GITHUB_ORGANIZATION}" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 466 | fi |
| 467 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 468 | ref="$org" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 469 | return |
| 470 | } |
| 471 | |
| 472 | ## ----------------------------------------------------------------------- |
| 473 | ## Intent: Retrieve repository organizaiton name |
| 474 | ## ----------------------------------------------------------------------- |
| 475 | function get_gh_repo_name() |
| 476 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 477 | local -n ref=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 478 | declare -g __repo_name |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 479 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 480 | local name |
| 481 | if [[ -v __repo_name ]]; then |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 482 | name="$__repo_name" |
Joey Armstrong | 39fac65 | 2023-03-27 18:50:43 -0400 | [diff] [blame] | 483 | elif [[ ! -v GERRIT_PROJECT ]]; then |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 484 | error "--repo-name or GERRIT_PROJECT= are required" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 485 | else |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 486 | name="${GERRIT_PROJECT}" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 487 | fi |
| 488 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 489 | ref="$name" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 490 | return |
| 491 | } |
| 492 | |
| 493 | ## ----------------------------------------------------------------------- |
| 494 | ## Intent: Return path for the gh release query |
| 495 | ## ----------------------------------------------------------------------- |
| 496 | function get_gh_releases() |
| 497 | { |
Joey Armstrong | 1cc9029 | 2024-04-02 09:27:33 -0400 | [diff] [blame] | 498 | local -n ref=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 499 | |
| 500 | local repo_org |
| 501 | get_gh_repo_org repo_org |
| 502 | |
| 503 | local repo_name |
| 504 | get_gh_repo_name repo_name |
| 505 | |
| 506 | ref="repos/${repo_org}/${repo_name}/releases" |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 507 | func_echo "releases_uri=$ref" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 508 | return |
| 509 | } |
| 510 | |
| 511 | ## ----------------------------------------------------------------------- |
| 512 | ## Intent: Retrieve repository path argument |
| 513 | ## ----------------------------------------------------------------------- |
| 514 | function get_argv_repo() |
| 515 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 516 | local -n ref=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 517 | |
| 518 | local repo_org |
| 519 | get_gh_repo_org repo_org |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 520 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 521 | local repo_name |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 522 | get_gh_repo_name repo_name |
| 523 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 524 | ref="${repo_org}/${repo_name}" |
| 525 | # func_echo "ref=$(declare -p ref)" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 526 | return |
| 527 | } |
| 528 | |
| 529 | ## ----------------------------------------------------------------------- |
| 530 | ## Intent: Retrieve release name string "project - version" |
| 531 | ## ----------------------------------------------------------------------- |
| 532 | function get_argv_name() |
| 533 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 534 | local -n ref=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 535 | |
| 536 | local repo_name |
| 537 | get_gh_repo_name repo_name |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 538 | |
| 539 | local repo_ver |
| 540 | getGitVersion repo_ver |
| 541 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 542 | # ref="${repo_name} - $GIT_VERSION" |
| 543 | ref="${repo_name} - ${repo_ver}" |
| 544 | func_echo "ref=$(declare -p ref)" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 545 | return |
| 546 | } |
| 547 | |
| 548 | ## ----------------------------------------------------------------------- |
| 549 | ## Intent: Retrieve tag version |
| 550 | ## ----------------------------------------------------------------------- |
| 551 | function get_argv_tag() |
| 552 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 553 | local -n ref=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 554 | |
| 555 | # cached_argv_tag='v3.41.3204' |
| 556 | if [[ ! -v cached_argv_tag ]]; then |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 557 | declare -g cached_argv_tag |
| 558 | if [[ -v GIT_VERSION ]]; then # hello jenkins |
| 559 | cached_argv_tag="$GIT_VERSION" |
| 560 | fi |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 561 | fi |
| 562 | |
| 563 | [[ ${#cached_argv_tag} -eq 0 ]] && error "Unable to determine GIT_VERSION=" |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 564 | ref="$cached_argv_tag" |
| 565 | func_echo "ref=$(declare -p ref)" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 566 | return |
| 567 | } |
| 568 | |
| 569 | ## ----------------------------------------------------------------------- |
| 570 | ## Intent: |
| 571 | ## ----------------------------------------------------------------------- |
| 572 | # To support golang projects that require GOPATH to be set and code checked out there |
| 573 | # If $DEST_GOPATH is not an empty string: |
| 574 | # - create GOPATH within WORKSPACE, and destination directory within |
| 575 | # - set PATH to include $GOPATH/bin and the system go binaries |
| 576 | # - move project from $WORKSPACE/$GERRIT_PROJECT to new location in $GOPATH |
| 577 | # - start release process within that directory |
| 578 | ## ----------------------------------------------------------------------- |
| 579 | function get_release_path() |
| 580 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 581 | local -n ref=$1; shift |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 582 | local varpath="$ref" |
Joey Armstrong | daa1f0a | 2024-04-03 18:07:59 -0400 | [diff] [blame] | 583 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 584 | DEST_GOPATH=${DEST_GOPATH:-} |
| 585 | if [ -n "$DEST_GOPATH" ]; then |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 586 | mkdir -p "$GOPATH/src/$DEST_GOPATH" |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 587 | varpath="$GOPATH/src/$DEST_GOPATH/$GERRIT_PROJECT" |
| 588 | mv "$WORKSPACE/$GERRIT_PROJECT" "$varpath" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 589 | else |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 590 | varpath="$WORKSPACE/$GERRIT_PROJECT" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 591 | fi |
| 592 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 593 | ## Verify pwd is OK |
| 594 | for path in \ |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 595 | "${varpath}/Makefile"\ |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 596 | "${varpath}/makefile"\ |
| 597 | "__ERROR__"\ |
| 598 | ; do |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 599 | case "$path" in |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 600 | __ERROR__) error "Makefile not found at ${varpath} !" ;; |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 601 | *) [[ -f "$path" ]] && break ;; |
| 602 | esac |
| 603 | done |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 604 | |
Mahir Gunyel | 2c9e850 | 2024-03-29 13:05:38 -0700 | [diff] [blame] | 605 | ref="$varpath" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | ## ----------------------------------------------------------------------- |
| 609 | ## Intent: Display future enhancements |
| 610 | ## ----------------------------------------------------------------------- |
| 611 | function todo() |
| 612 | { |
| 613 | local iam="${0##*/}" |
| 614 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 615 | cat <<EOT |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 616 | |
| 617 | ** ----------------------------------------------------------------------- |
| 618 | ** IAM: ${iam} :: ${FUNCNAME[0]} |
| 619 | ** ----------------------------------------------------------------------- |
| 620 | o get_release_path() |
| 621 | - refactor redundant paths into local vars. |
| 622 | - see comments, do we have a one-off failure condition ? |
Joey Armstrong | ad7b1e0 | 2023-03-27 11:55:48 -0400 | [diff] [blame] | 623 | o PATH += golang appended 3 times, release needs a single, reliable answer. |
| 624 | o do_login, do_logout and api calls do not use the my_gh wrapper: |
| 625 | - Add a lookup function to cache and retrieve path to downloaded gh command. |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 626 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 627 | EOT |
| 628 | |
| 629 | return |
| 630 | } |
| 631 | |
| 632 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 633 | ## Intent: Verify a directory contains content for release. |
| 634 | ## ----------------------------------------------------------------------- |
| 635 | ## Given: |
| 636 | ## scalar Path to release/ directory |
| 637 | ## ref Results returned through this indirect var. |
| 638 | ## ----------------------------------------------------------------------- |
| 639 | ## Usage: |
| 640 | ## declare -a artifacts=() |
| 641 | ## get_artifacts '/foo/bar/tans' artifacts |
| 642 | ## declare -p artifacts |
| 643 | ## ----------------------------------------------------------------------- |
| 644 | function get_artifacts() |
| 645 | { |
| 646 | local dir="$1" ; shift |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 647 | local -n refA=$1 ; shift |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 648 | |
Joey Armstrong | 55fe80e | 2023-04-05 18:32:14 -0400 | [diff] [blame] | 649 | # Glob available files, exclude checksums |
| 650 | readarray -t __artifacts < <(find "$dir" -mindepth 1 ! -type d \ |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 651 | | grep -iv -e 'sum256' -e 'checksum') |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 652 | # func_echo "$(declare -p __artifacts)" |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 653 | |
| 654 | # ----------------------------------------------------------------------- |
| 655 | # Verify count>0 to inhibit source-only release |
| 656 | # Problem children: |
| 657 | # o build or make release failures. |
| 658 | # o docker container filesystem mount problem (~volume) |
| 659 | # ----------------------------------------------------------------------- |
| 660 | [[ ${#__artifacts[@]} -eq 0 ]] \ |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 661 | && error "Artifact dir is empty: $(declare -p dir)" |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 662 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 663 | refA=("${__artifacts[@]}") |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 664 | return |
| 665 | } |
| 666 | |
| 667 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 668 | ## Intent: Copy files from the build directory into the release staging |
| 669 | ## directory for publishing to github releases/ endpoint. |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 670 | ## ----------------------------------------------------------------------- |
| 671 | function copyToRelease() |
| 672 | { |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 673 | banner '' |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 674 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 675 | local artifact_glob="${ARTIFACT_GLOB%/*}" |
| 676 | func_echo "$(declare -p artifact_glob)" |
| 677 | |
| 678 | local work |
| 679 | get_release_dir work |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 680 | func_echo "Artifact dir: $(declare -p work)" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 681 | |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 682 | ## Verify release content is available |
| 683 | declare -a artifacts=() |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 684 | # get_artifacts "$work" artifacts |
| 685 | get_artifacts "$artifact_glob" artifacts |
| 686 | func_echo "Artifacts in copy_from: $(declare -p artifacts)" |
Joey Armstrong | 472bfba | 2023-03-27 18:12:28 -0400 | [diff] [blame] | 687 | |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 688 | # Copy artifacts into the release temp dir |
| 689 | # shellcheck disable=SC2086 |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 690 | echo "rsync -rv --checksum \"$artifact_glob/.\" \"$work/.\"" |
| 691 | rsync -rv --checksum "$artifact_glob/." "$work/." |
Joey Armstrong | 1962bcf | 2023-01-27 13:53:18 -0500 | [diff] [blame] | 692 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 693 | get_artifacts "$work" artifacts |
| 694 | func_echo "Artifacts in copy_to: $(declare -p artifacts)" |
| 695 | |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 696 | return |
| 697 | } |
| 698 | |
| 699 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 700 | ## https://docs.github.com/en/rest/releases?apiVersion=2022-11-28 |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 701 | # https://cli.github.com/manual/gh_release_create |
| 702 | # --target <branch> or commit SHA |
| 703 | # --title |
| 704 | # --generate-notes |
| 705 | # --release-notes (notes file) |
| 706 | # --release |
| 707 | # release create dist/*.tgz |
| 708 | # --discussion-category "General" |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 709 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 710 | # https://cli.github.com/manual/gh_release_create |
| 711 | ## ----------------------------------------------------------------------- |
| 712 | function gh_release_create() |
Joey Armstrong | 38bfeea | 2023-02-06 18:01:29 -0500 | [diff] [blame] | 713 | { |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 714 | banner '' |
Joey Armstrong | 38bfeea | 2023-02-06 18:01:29 -0500 | [diff] [blame] | 715 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 716 | local version |
| 717 | getGitVersion version |
Joey Armstrong | 38bfeea | 2023-02-06 18:01:29 -0500 | [diff] [blame] | 718 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 719 | local work |
| 720 | get_release_dir work |
| 721 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 722 | declare -a args=() |
| 723 | args+=('--host-repo') |
| 724 | args+=('--title') |
| 725 | if [[ -v draft_release ]]; then |
| 726 | args+=('--draft') |
| 727 | else |
| 728 | args+=('--discussion-category' 'Announcements') |
| 729 | fi |
| 730 | |
Joey Armstrong | 55fe80e | 2023-04-05 18:32:14 -0400 | [diff] [blame] | 731 | if [[ -v release_notes ]]; then |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 732 | args+=('--notes-file' "$release_notes") |
Joey Armstrong | 55fe80e | 2023-04-05 18:32:14 -0400 | [diff] [blame] | 733 | fi |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 734 | |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 735 | pushd "$work/.." >/dev/null |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 736 | # func_echo "WORK=$work" |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 737 | readarray -t payload < <(find 'release' -maxdepth 4 ! -type d -print) |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 738 | |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 739 | func_echo "$gh_cmd release create ${version} ${args[*]} ${payload[*]}" |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 740 | |
| 741 | if [[ -v dry_run ]]; then |
| 742 | echo "[SKIP] dry run" |
| 743 | else |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 744 | func_echo "my_gh release create '$version' ${args[*]} ${payload[*]}" |
Joey Armstrong | 4dbe700 | 2023-04-04 12:47:38 -0400 | [diff] [blame] | 745 | my_gh 'release' 'create' "$version" "${args[@]}" "${payload[@]}" |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 746 | fi |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 747 | popd >/dev/null |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 748 | |
Joey Armstrong | 38bfeea | 2023-02-06 18:01:29 -0500 | [diff] [blame] | 749 | return |
| 750 | } |
| 751 | |
| 752 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 753 | ## Intent: Authenticate credentials for a github gh session |
Joey Armstrong | 38bfeea | 2023-02-06 18:01:29 -0500 | [diff] [blame] | 754 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 755 | ## NOTE: my_gh currently unused due to --with-token < "$pac" |
| 756 | ## ----------------------------------------------------------------------- |
| 757 | function do_login() |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 758 | { |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 759 | # shellcheck disable=SC2120 |
| 760 | # shellcheck disable=SC2034 |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 761 | [[ $# -gt 0 ]] && { local unused="$1"; shift; } |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 762 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 763 | declare -g pac |
Joey Armstrong | 485081f | 2023-03-27 13:34:08 -0400 | [diff] [blame] | 764 | declare -a login_args=() |
| 765 | [[ $# -gt 0 ]] && login_args+=("$@") |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 766 | |
Joey Armstrong | 485081f | 2023-03-27 13:34:08 -0400 | [diff] [blame] | 767 | # https://github.com/cli/cli/issues/2922#issuecomment-775027762 |
Joey Armstrong | 75a0d93 | 2023-03-28 08:59:54 -0400 | [diff] [blame] | 768 | # (sigh) why not quietly return VS forcing a special logic path |
Joey Armstrong | e6e18eb | 2023-03-27 14:19:21 -0400 | [diff] [blame] | 769 | # [[ -v WORKSPACE ]] && [[ -v GITHUB_TOKEN ]] && return |
| 770 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 771 | # 12:58:36 ** ----------------------------------------------------------------------- |
| 772 | # 12:58:36 ** jenkins582353203049151829.sh::do_login: --hostname github.com |
| 773 | # 12:58:36 ** --------------------------------------------------------------------# --- |
| 774 | # 12:58:36 ** jenkins582353203049151829.sh :: do_login: Detected ENV{GITHUB_TOKEN}= |
| 775 | # 12:58:36 The value of the GITHUB_TOKEN environment variable is being used for authentication. |
| 776 | # 12:58:36 To have GitHub CLI store credentials instead, first clear the value from the environment. |
| 777 | # ----------------------------------------------------------------------- |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 778 | |
Joey Armstrong | 485081f | 2023-03-27 13:34:08 -0400 | [diff] [blame] | 779 | get_gh_hostname login_args |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 780 | |
Joey Armstrong | 485081f | 2023-03-27 13:34:08 -0400 | [diff] [blame] | 781 | banner "${login_args[@]}" |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 782 | func_echo "$(declare -p WORKSPACE)" |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 783 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 784 | ## Read from disk is safer than export GITHUB_TOKEN= |
| 785 | if [[ -v pac ]] && [[ ${#pac} -gt 0 ]]; then # interactive/debugging |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 786 | [ ! -f "$pac" ] && error "PAC token file $pac does not exist" |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 787 | func_echo "$gh_cmd auth login ${login_args[*]} --with-token < $pac" |
Joey Armstrong | 485081f | 2023-03-27 13:34:08 -0400 | [diff] [blame] | 788 | "$gh_cmd" auth login "${login_args[@]}" --with-token < "$pac" |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 789 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 790 | elif [[ ! -v GITHUB_TOKEN ]]; then |
| 791 | error "--token [t] or GITHUB_TOKEN= are required" |
Joey Armstrong | 41923cc | 2023-01-30 14:38:16 -0500 | [diff] [blame] | 792 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 793 | else # jenkins |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 794 | func_echo "$gh_cmd auth login ${login_args[*]} (ie: jenkins)" |
Joey Armstrong | 733ea9f | 2023-04-03 21:19:46 -0400 | [diff] [blame] | 795 | |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 796 | # https://github.com/cli/cli/issues/2922#issuecomment-775027762 |
| 797 | # When using GITHUB_TOKEN, there is no need to even run gh auth login |
Joey Armstrong | 733ea9f | 2023-04-03 21:19:46 -0400 | [diff] [blame] | 798 | # "$gh_cmd" auth login "${login_args[@]}" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 799 | fi |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 800 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 801 | declare -i -g active_login=1 # signal logout needed |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 802 | |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 803 | return |
| 804 | } |
| 805 | |
| 806 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 807 | ## Intent: Destroy credentials/gh session authenticated by do_login |
| 808 | ## ----------------------------------------------------------------------- |
| 809 | ## NOTE: my_gh currently unused due to "<<< 'y'" |
| 810 | ## ----------------------------------------------------------------------- |
| 811 | function do_logout() |
| 812 | { |
| 813 | declare -i -g active_login |
| 814 | [[ ! -v active_login ]] && return |
| 815 | |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 816 | declare -a logout_args=() |
| 817 | [[ $# -gt 0 ]] && logout_args+=("$@") |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 818 | |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 819 | get_gh_hostname logout_args |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 820 | |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 821 | banner "${logout_args[@]}" |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 822 | func_echo "$gh_cmd auth logout ${logout_args[*]} <<< 'Y'" |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 823 | "$gh_cmd" auth logout "${logout_args[@]}" <<< 'Y' |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 824 | unset active_login |
| 825 | return |
| 826 | } |
| 827 | |
| 828 | ## ----------------------------------------------------------------------- |
| 829 | ## Intent: Query for repository version strings |
| 830 | ## ----------------------------------------------------------------------- |
| 831 | function get_releases() |
| 832 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 833 | # shellcheck disable=SC2178 |
Joey Armstrong | 1cc9029 | 2024-04-02 09:27:33 -0400 | [diff] [blame] | 834 | local -n refA=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 835 | |
| 836 | banner "" |
| 837 | pushd "$scratch" >/dev/null |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 838 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 839 | # gh api repos/{owner}/{repo}/releases |
| 840 | local releases_uri |
| 841 | get_gh_releases releases_uri |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 842 | |
| 843 | func_echo "RUNNING: $gh_cmd api $releases_uri | jq . > release.raw" |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 844 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 845 | refA=() |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 846 | "$gh_cmd" api "$releases_uri" | jq . > 'release.raw' |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 847 | readarray -t __tmp < <(jq '.[] | "\(.tag_name)"' 'release.raw') |
| 848 | |
| 849 | local release |
| 850 | for release in "${__tmp[@]}"; |
| 851 | do |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 852 | release="${release//\"/}" |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 853 | refA+=("$release") |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 854 | done |
| 855 | |
| 856 | popd >/dev/null |
| 857 | return |
| 858 | } |
| 859 | |
| 860 | ## ----------------------------------------------------------------------- |
| 861 | ## Intent: Display repository query strings. |
| 862 | ## Indirect: verify authentication and API |
| 863 | ## ----------------------------------------------------------------------- |
| 864 | function showReleases() |
| 865 | { |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 866 | declare -a raw=() |
| 867 | get_releases raw |
| 868 | |
| 869 | ## Sort for display, we may need to prune volume later on |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 870 | readarray -t releases < <(sort -nr <<<"${raw[*]}") |
| 871 | # IFS=$'\n' releases=($(sort -nr <<<"${raw[*]}")) |
| 872 | # unset IFS |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 873 | |
| 874 | local release |
| 875 | for release in "${releases[@]}"; |
| 876 | do |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 877 | func_echo "$release" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 878 | done |
| 879 | return |
| 880 | } |
| 881 | |
| 882 | ## ----------------------------------------------------------------------- |
| 883 | ## Intent: Install the gh command line tool locally |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 884 | ## ----------------------------------------------------------------------- |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 885 | function install_gh_binary() |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 886 | { |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 887 | banner |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 888 | |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 889 | pushd "$scratch" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 890 | func_echo "Retrieve latest gh download URLs" |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 891 | |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 892 | local latest="https://github.com/cli/cli/releases/latest" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 893 | local tarball="gh.tar.tgz" |
| 894 | |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 895 | readarray -t latest < <(\ |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 896 | curl --silent -qI "$latest" \ |
| 897 | | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}') |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 898 | declare -p latest |
| 899 | if [ ${#latest[@]} -ne 1 ]; then |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 900 | error "Unable to determine latest gh package version" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 901 | fi |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 902 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 903 | local VER="${latest[0]}" |
| 904 | |
| 905 | func_echo "Download latest gh binary" |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 906 | local url="https://github.com/cli/cli/releases/download/${VER}/gh_${VER#v}_linux_amd64.tar.gz" |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 907 | func_echo "wget --quiet --output-document='$tarball' '$url'" |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 908 | wget --quiet --output-document="$tarball" "$url" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 909 | |
| 910 | func_echo "Unpack tarball" |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 911 | tar zxf "$tarball" |
| 912 | |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 913 | declare -g gh_cmd |
| 914 | gh_cmd="$(find "${scratch}" -name 'gh' -print)" |
| 915 | #declare -g gh_cmd='/usr/bin/gh' |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 916 | readonly gh_cmd |
| 917 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 918 | func_echo "Command: ${gh_cmd}" |
| 919 | func_echo "Version: $("$gh_cmd" --version)" |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 920 | popd |
| 921 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 922 | return |
| 923 | } |
| 924 | |
| 925 | ## ----------------------------------------------------------------------- |
| 926 | ## Intent: Danger Will Robinson |
| 927 | ## ----------------------------------------------------------------------- |
| 928 | function releaseDelete() |
| 929 | { |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 930 | # shellcheck disable=SC2178 |
| 931 | local -n refA=$1; shift |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 932 | local version="$1"; shift |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 933 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 934 | banner "${refA[@]}" |
| 935 | # declare -a refA=() |
| 936 | refA+=('--host-repo') |
| 937 | refA+=('--yes') |
| 938 | # refA+=('--cleanup-tag') |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 939 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 940 | echo |
| 941 | echo "===========================================================================" |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 942 | my_gh 'release' 'delete' "$version" "${refA[@]}" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 943 | echo "===========================================================================" |
| 944 | echo |
| 945 | |
| 946 | showReleases |
| 947 | return |
| 948 | } |
| 949 | |
| 950 | ## ----------------------------------------------------------------------- |
| 951 | ## Intent: Copy binaries into temp/release, checksum then publish |
| 952 | ## ----------------------------------------------------------------------- |
| 953 | function release_staging() |
| 954 | { |
| 955 | local release_temp |
| 956 | get_release_dir release_temp |
| 957 | |
| 958 | banner '' |
| 959 | func_echo "Packaging release files" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 960 | |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 961 | pushd "$release_temp" >/dev/null \ |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 962 | || { error "pushd failed: dir is [$release_temp]"; } |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 963 | |
| 964 | declare -a to_release=() |
| 965 | get_artifacts '.' to_release |
| 966 | |
Joey Armstrong | 55fe80e | 2023-04-05 18:32:14 -0400 | [diff] [blame] | 967 | if false; then |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 968 | for fyl in "${to_release[@]}"; |
| 969 | do |
| 970 | func_echo "sha256sum $fyl > ${fyl}.sha256" |
| 971 | sha256sum "$fyl" > "${fyl}.sha256" |
| 972 | done |
Joey Armstrong | 55fe80e | 2023-04-05 18:32:14 -0400 | [diff] [blame] | 973 | fi |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 974 | |
| 975 | # Generate and check checksums |
Joey Armstrong | 55fe80e | 2023-04-05 18:32:14 -0400 | [diff] [blame] | 976 | sha256sum -- * | grep -iv -e 'checksum' -e 'sha256' > checksum.SHA256 |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 977 | sha256sum -c < checksum.SHA256 |
| 978 | |
| 979 | echo |
| 980 | func_echo "Checksums(checksum.SHA256):" |
| 981 | cat checksum.SHA256 |
| 982 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 983 | if false; then |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 984 | # Careful with credentials display |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 985 | get_gh_hostname login_args |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 986 | banner "gh auth status ${login_args[*]}" |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 987 | gh auth status "${login_args[@]}" |
| 988 | fi |
| 989 | |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 990 | gh_release_create # publish |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 991 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 992 | popd >/dev/null || { error "pushd failed: dir is [$release_temp]"; } |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 993 | |
| 994 | return |
| 995 | } |
| 996 | |
| 997 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 998 | ## Intent: Normalize common arguments and access to the gh command. |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 999 | ## o Cache path to the gh command |
| 1000 | ## o Construct a gh command line from given args |
| 1001 | ## o Command wrapper can provide defaults (--hostname github.com) |
| 1002 | ## ----------------------------------------------------------------------- |
| 1003 | ## Given: |
Joey Armstrong | db43bde | 2024-04-01 14:54:35 -0400 | [diff] [blame] | 1004 | ## scalar Array variable name (local -n is a reference) |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1005 | ## Return: |
| 1006 | ## ref gh command line passed back to caller |
| 1007 | ## Switches: |
| 1008 | ## --host Pass default github hostname |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 1009 | ## --verbose Enable verbose mode |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1010 | ## --version Display command version |
| 1011 | ## @array Remaining arguments passed as command switches. |
| 1012 | ## ----------------------------------------------------------------------- |
| 1013 | ## See Also: |
| 1014 | ## o https://cli.github.com/manual |
| 1015 | ## ----------------------------------------------------------------------- |
| 1016 | function my_gh() |
| 1017 | { |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1018 | bannerEL 'ENTER' |
Joey Armstrong | daa1f0a | 2024-04-03 18:07:59 -0400 | [diff] [blame] | 1019 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1020 | declare -a cmd=() |
| 1021 | cmd+=("$gh_cmd") |
| 1022 | |
| 1023 | ## ---------------------- |
| 1024 | ## Construct command line |
| 1025 | ## ---------------------- |
| 1026 | # shellcheck disable=SC2034 |
| 1027 | declare -A action=() # pending operations |
| 1028 | declare -a args=() # common gh command line args |
| 1029 | |
| 1030 | while [ $# -gt 0 ]; do |
| 1031 | local arg="$1"; shift |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1032 | func_echo "function arg is [$arg]" |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1033 | case "$arg" in |
| 1034 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1035 | # Modes |
Joey Armstrong | daa1f0a | 2024-04-03 18:07:59 -0400 | [diff] [blame] | 1036 | -*debug) |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1037 | # shellcheck disable=SC2034 |
| 1038 | declare -i -g debug=1 |
| 1039 | ;; |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1040 | -*verbose) args+=('--verbose') ;; |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1041 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1042 | -*hostname) |
| 1043 | get_gh_hostname in_args |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1044 | ;; |
| 1045 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1046 | --host-repo) |
| 1047 | local val |
| 1048 | get_argv_repo val |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 1049 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1050 | # --repo <[HOST/]OWNER/REPO> |
Joey Armstrong | 78cecc5 | 2023-04-03 11:39:11 -0400 | [diff] [blame] | 1051 | args+=('--repo' "${__githost}/${val}") |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1052 | ;; |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 1053 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1054 | # args+=('--repo' 'github.com/opencord/bbsim') |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 1055 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1056 | --repo) |
| 1057 | local val |
| 1058 | get_argv_repo val |
| 1059 | args+=('--repo' "$val") |
| 1060 | ;; |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1061 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1062 | --tag) |
| 1063 | local val |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1064 | get_argv_tag val |
Joey Armstrong | 4dbe700 | 2023-04-04 12:47:38 -0400 | [diff] [blame] | 1065 | args+=("$val") # No switch, pass inline |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1066 | ;; |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1067 | |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1068 | --title) |
| 1069 | local val |
| 1070 | get_argv_name val |
Joey Armstrong | f9a0a88 | 2023-04-17 11:53:57 -0400 | [diff] [blame] | 1071 | args+=('--title' "'$val'") |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1072 | ;; |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 1073 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1074 | *) args+=("$arg") ;; |
| 1075 | esac |
| 1076 | done |
Joey Armstrong | 76026b7 | 2023-03-29 12:19:17 -0400 | [diff] [blame] | 1077 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1078 | cmd+=("${args[@]}") |
Joey Armstrong | 73bb2f6 | 2023-04-17 19:31:50 -0400 | [diff] [blame] | 1079 | |
| 1080 | echo |
| 1081 | declare -p cmd |
| 1082 | |
| 1083 | echo |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1084 | echo "** Running: ${cmd[*]}" |
| 1085 | "${cmd[@]}" |
| 1086 | local status=$? |
| 1087 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1088 | bannerEL 'LEAVE' |
Joey Armstrong | 73bb2f6 | 2023-04-17 19:31:50 -0400 | [diff] [blame] | 1089 | |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1090 | if [[ $status -eq 0 ]]; then |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1091 | true |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1092 | else |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1093 | false |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1094 | fi |
| 1095 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1096 | return |
| 1097 | } |
| 1098 | |
Joey Armstrong | af577ab | 2022-12-15 14:43:33 -0500 | [diff] [blame] | 1099 | ##----------------## |
| 1100 | ##---] MAIN [---## |
| 1101 | ##----------------## |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1102 | bannerEL 'ENTER' |
Joey Armstrong | 1962bcf | 2023-01-27 13:53:18 -0500 | [diff] [blame] | 1103 | iam="${0##*/}" |
| 1104 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1105 | full_banner |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1106 | parse_args "$@" |
Joey Armstrong | d99e3d2 | 2023-01-29 12:35:43 -0500 | [diff] [blame] | 1107 | init |
| 1108 | install_gh_binary |
Joey Armstrong | 7f382ef | 2023-01-25 12:00:08 -0500 | [diff] [blame] | 1109 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1110 | [[ -v argv_self_check ]] && { do_api_validation; exit 0; } |
| 1111 | |
Joey Armstrong | 01e4edb | 2023-08-18 12:50:32 -0400 | [diff] [blame] | 1112 | do_login "$*" |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 1113 | |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1114 | release_path='/dev/null' |
| 1115 | get_release_path release_path |
| 1116 | declare -p release_path |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 1117 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1118 | pushd "$release_path" || { error "pushd failed: dir is [$release_path]"; } |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 1119 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1120 | # legacy: getGitVersion "$GERRIT_PROJECT" GIT_VERSION |
| 1121 | getGitVersion GIT_VERSION |
| 1122 | getReleaseDescription RELEASE_DESCRIPTION |
| 1123 | if [[ ! -v release_notes ]]; then |
| 1124 | func_echo "Generating release notes from RELEASE_DESCRIPTION" |
| 1125 | declare -g release_notes="$scratch/release.notes" |
| 1126 | echo "$RELEASE_DESCRIPTION" > "$release_notes" |
| 1127 | fi |
| 1128 | cat "$release_notes" |
Zack Williams | 27cd3e5 | 2018-09-18 16:44:50 -0700 | [diff] [blame] | 1129 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1130 | cat <<EOM |
Joey Armstrong | eef8c2c | 2023-03-27 17:27:43 -0400 | [diff] [blame] | 1131 | |
| 1132 | ** ----------------------------------------------------------------------- |
| 1133 | ** GIT VERSION: $(declare -p GIT_VERSION) |
| 1134 | ** RELEASE_DESCRIPTION: $(declare -p RELEASE_DESCRIPTION) |
| 1135 | ** RELEASE_TARGETS: $(declare -p RELEASE_TARGETS) |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1136 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1137 | ** URL: https://github.com/opencord/{repo}/releases |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1138 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 43c4842 | 2023-04-03 10:17:32 -0400 | [diff] [blame] | 1139 | ** Running: make ${RELEASE_TARGETS} |
Joey Armstrong | eef8c2c | 2023-03-27 17:27:43 -0400 | [diff] [blame] | 1140 | ** ----------------------------------------------------------------------- |
| 1141 | EOM |
Joey Armstrong | 50f6e0b | 2023-01-24 14:14:08 -0500 | [diff] [blame] | 1142 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1143 | # build the release, can be multiple space separated targets |
| 1144 | # ----------------------------------------------------------------------- |
| 1145 | # % go build command-line-arguments: |
| 1146 | # copying /tmp/go-build4212845548/b001/exe/a.out: |
| 1147 | # open release/voltctl-1.8.25-linux-amd64: permission denied |
| 1148 | # missing: docker run mkdir |
| 1149 | # ----------------------------------------------------------------------- |
| 1150 | # shellcheck disable=SC2086 |
| 1151 | make "$RELEASE_TARGETS" |
| 1152 | copyToRelease |
| 1153 | |
| 1154 | cat <<EOM |
Joey Armstrong | 1962bcf | 2023-01-27 13:53:18 -0500 | [diff] [blame] | 1155 | |
| 1156 | ** ----------------------------------------------------------------------- |
| 1157 | ** Create the release: |
| 1158 | ** 1) Create initial github release with download area. |
| 1159 | ** 2) Generate checksum.SHA256 for all released files. |
| 1160 | ** 3) Upload files to complete the release. |
Joey Armstrong | 75a0d93 | 2023-03-28 08:59:54 -0400 | [diff] [blame] | 1161 | ** 4) Display released info from github |
Joey Armstrong | 1962bcf | 2023-01-27 13:53:18 -0500 | [diff] [blame] | 1162 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 1163 | EOM |
| 1164 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1165 | showReleases |
| 1166 | release_staging |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1167 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1168 | # Useful to display but --draft images use a non-standard subdir identifier. |
| 1169 | # showReleaseUrl |
Joey Armstrong | e8560da | 2023-04-26 15:44:45 -0400 | [diff] [blame] | 1170 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1171 | popd || { error "pushd failed: dir is [$release_path]"; } |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 1172 | |
Joey Armstrong | 4d612a9 | 2024-04-24 15:30:49 -0400 | [diff] [blame] | 1173 | # shellcheck disable=SC2119 |
Joey Armstrong | 2097d3e | 2023-03-26 10:32:03 -0400 | [diff] [blame] | 1174 | do_logout |
| 1175 | |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 1176 | # [SEE ALSO] |
| 1177 | # ----------------------------------------------------------------------- |
| 1178 | # https://www.shellcheck.net/wiki/SC2236 |
Joey Armstrong | 26707f0 | 2023-01-26 12:41:12 -0500 | [diff] [blame] | 1179 | # https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 1180 | # ----------------------------------------------------------------------- |
Joey Armstrong | f085d87 | 2023-01-28 17:52:29 -0500 | [diff] [blame] | 1181 | # https://cli.github.com/manual/gh_help_reference |
| 1182 | # https://cli.github.com/manual/gh_release |
| 1183 | # ----------------------------------------------------------------------- |
Joey Armstrong | 28eddda | 2023-01-10 03:09:34 -0500 | [diff] [blame] | 1184 | |
| 1185 | # [EOF] |