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