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