blob: 46ad2434c654ecc63e0fdf39356f821c4b0fe13c [file] [log] [blame]
Zack Williams27cd3e52018-09-18 16:44:50 -07001#!/usr/bin/env bash
Joey Armstrong28eddda2023-01-10 03:09:34 -05002# -----------------------------------------------------------------------
3# Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
Zack Williams27cd3e52018-09-18 16:44:50 -07004#
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#
9# http://www.apache.org/licenses/LICENSE-2.0
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 Armstrong28eddda2023-01-10 03:09:34 -050016#
Zack Williams27cd3e52018-09-18 16:44:50 -070017# github-release.sh
18# builds (with make) and uploads release artifacts (binaries, etc.) to github
19# given a tag also create checksums files and release notes from the commit
20# message
Joey Armstrong28eddda2023-01-10 03:09:34 -050021# -----------------------------------------------------------------------
Joey Armstrongf085d872023-01-28 17:52:29 -050022# 1) Staging to replace command github-release with gh.
23# 2) gh auth / GIT_TOKEN handling may be needed
24# -----------------------------------------------------------------------
25# gh release create abc/1.2.3-rc2 --discussion-category "Announcements" --generate-notes hello.txt
26# https://github.com/cli/cli/issues/4993
27# -----------------------------------------------------------------------
Zack Williams27cd3e52018-09-18 16:44:50 -070028
Joey Armstrong7f382ef2023-01-25 12:00:08 -050029##-------------------##
30##---] GLOBALS [---##
31##-------------------##
Joey Armstrong7f382ef2023-01-25 12:00:08 -050032declare -g ARGV="$*" # archive for display
Joey Armstrong1962bcf2023-01-27 13:53:18 -050033declare -g SCRIPT_VERSION='1.0' # git changeset needed
34declare -g TRACE=0 # uncomment to set -x
35declare -g VERBOSE=0 # trace github-release calls
Joey Armstrong7f382ef2023-01-25 12:00:08 -050036
Joey Armstrong26707f02023-01-26 12:41:12 -050037declare -g RELEASE_TEMP
38
Joey Armstrong7f382ef2023-01-25 12:00:08 -050039##--------------------##
40##---] INCLUDES [---##
Joey Armstrong1962bcf2023-01-27 13:53:18 -050041##--------------------#
42# declare -g pgmdir="${0%/*}" # dirname($script)
Joey Armstrongbd54b572023-01-25 14:28:10 -050043echo "** ${0}: PWD=$(/bin/pwd)"
Joey Armstrong7f382ef2023-01-25 12:00:08 -050044
Joey Armstrongd8b6f332023-01-25 18:35:17 -050045# -----------------------------------------------------------------------
46# Jenkins must have checked out/copied the script -vs- repository
47# -----------------------------------------------------------------------
48# 17:56:27 [github-release_voltctl] $ /usr/bin/env bash /tmp/jenkins1043949650153731384.sh
49# 17:56:27 ** /tmp/jenkins1043949650153731384.sh: PWD=/w/workspace/github-release_voltctl
50# 17:56:27 5120009 4 drwxrwxr-x 4 jenkins jenkins 4096 Jan 25 22:56 .
51# 17:56:27 5120010 4 drwxrwxr-x 9 jenkins jenkins 4096 Jan 25 22:56 ./voltctl
52# 17:56:27 5120036 4 drwxrwxr-x 2 jenkins jenkins 4096 Jan 25 22:56 ./voltctl@tmp
53# 17:56:27 /tmp/jenkins1043949650153731384.sh: line 44: /tmp/common/common.sh: No such file or directory
54# -----------------------------------------------------------------------
55
Joey Armstrong1962bcf2023-01-27 13:53:18 -050056# declare -a common_args=()
57# common_args+=('--common-args-begin--')
58# common_args+=('--traputils')
59# common_args+=('--stacktrace')
60# common_args+=('--tempdir')
61
Joey Armstrong7f382ef2023-01-25 12:00:08 -050062# shellcheck disable=SC1091
Joey Armstrong1962bcf2023-01-27 13:53:18 -050063# source "${pgmdir}/common/common.sh" "${common_args[@]}"
Joey Armstrong7f382ef2023-01-25 12:00:08 -050064
65## -----------------------------------------------------------------------
66## Intent: Output a log banner to identify the running script/version.
67## -----------------------------------------------------------------------
68## TODO:
69## o SCRIPT_VERSION => git changeset for repo:ci-managment
70## o echo "library version: ${env."library.libName.version"}"
71# -----------------------------------------------------------------------
72# 14:18:38 > git fetch --no-tags --progress -- https://gerrit.opencord.org/ci-management.git +refs/heads/*:refs/remotes/origin/* # timeout=10
73# 14:18:39 Checking out Revision 50f6e0b97f449b32d32ec0e02d59642000351847 (master)
74# -----------------------------------------------------------------------
75function banner()
76{
77 local iam="${0##*/}"
78
79cat <<EOH
80
81** -----------------------------------------------------------------------
82** IAM: ${iam} :: ${FUNCNAME[0]}
83** ARGV: ${ARGV}
84** PWD: $(/bin/pwd)
85** NOW: $(date '+%Y/%m/%d %H:%M:%S')
86** VER: ${SCRIPT_VERSION:-'unknown'}
87** -----------------------------------------------------------------------
88EOH
89
90 return
91}
92
Joey Armstrongaf577ab2022-12-15 14:43:33 -050093## -----------------------------------------------------------------------
Joey Armstrong50f6e0b2023-01-24 14:14:08 -050094## Intent:
95## Display available command versions
96## A github release job is failing due to a command being mia.
97## -----------------------------------------------------------------------
98function displayCommands()
99{
100 # which git || /bin/true
101 # git --version || /bin/true
102 # go version || /bin/true
103 # helm version || /bin/true
104 return
105}
106
107## -----------------------------------------------------------------------
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500108## Intent: Display filesystem with a banner for logging
109## -----------------------------------------------------------------------
110function displayPwd()
111{
112 local iam="${0##*/}"
113 echo "** ${iam}: ENTER"
114
115cat <<EOM
116
117** -----------------------------------------------------------------------
118** IAM: $iam :: ${FUNCNAME[0]}
119** PWD: $(/bin/pwd)
120** -----------------------------------------------------------------------
121EOM
122 find . -maxdepth 1 -ls
123 echo "** ${iam}: LEAVE"
124 return
125}
126
127## -----------------------------------------------------------------------
128## Intent:
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500129## -----------------------------------------------------------------------
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500130function doDebug()
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500131{
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500132 echo "** ${FUNCNAME[0]}: ENTER"
Joey Armstrong28eddda2023-01-10 03:09:34 -0500133
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500134 echo
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500135 echo "** PWD: $(/bin/pwd)"
136 echo "** make-pre: $(/bin/ls -l)"
137 echo
138
139 declare -p ARTIFACT_GLOB
140 declare -p RELEASE_TEMP
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500141
142 echo
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500143 echo "** ${FUNCNAME[0]}: ARTIFACT_GLOB=${ARTIFACT_GLOB}"
144 local artifact_glob="${ARTIFACT_GLOB%/*}"
145 declare -p artifact_glob
Joey Armstrongbd54b572023-01-25 14:28:10 -0500146
147 echo "** ${FUNCNAME[0]}: PWD=$(/bin/pwd)"
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500148 find "$artifact_glob" -print || /bin/true
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500149
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500150 copyToRelease
151
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500152 # Copy artifacts into the release temp dir
153 # shellcheck disable=SC2086
Joey Armstrong7f382ef2023-01-25 12:00:08 -0500154 # cp -v "$ARTIFACT_GLOB" "$RELEASE_TEMP"
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500155 # echo "rsync -rv --checksum \"$artifact_glob/.\" \"$RELEASE_TEMP/.\""
156 # rsync -rv --checksum "$artifact_glob/." "$RELEASE_TEMP/."
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500157
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500158 echo "** ${FUNCNAME[0]}: LEAVE"
159 echo
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500160 return
161}
162
Joey Armstrong26707f02023-01-26 12:41:12 -0500163## -----------------------------------------------------------------------
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500164## Intent:
Joey Armstrong26707f02023-01-26 12:41:12 -0500165## -----------------------------------------------------------------------
166function copyToRelease()
167{
168 local iam="${FUNCNAME[0]}"
169 echo "** ${iam}: ENTER"
170
171 local artifact_glob="${ARTIFACT_GLOB%/*}"
172 echo "** ${iam}: $(declare -p ARTIFACT_GLOB) $(declare -p artifact_glob)"
Joey Armstrong26707f02023-01-26 12:41:12 -0500173
174 # Copy artifacts into the release temp dir
175 # shellcheck disable=SC2086
176 # cp -v "$ARTIFACT_GLOB" "$RELEASE_TEMP"
177 echo "rsync -rv --checksum \"$artifact_glob/.\" \"$RELEASE_TEMP/.\""
178 rsync -rv --checksum "$artifact_glob/." "$RELEASE_TEMP/."
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500179
Joey Armstrong26707f02023-01-26 12:41:12 -0500180 echo "** ${iam}: RELEASE_TEMP=${RELEASE_TEMP}"
181 find "$RELEASE_TEMP" -print
182
183 echo "** ${iam}: LEAVE"
184 echo
185 return
186}
187
188## -----------------------------------------------------------------------
Joey Armstrongf085d872023-01-28 17:52:29 -0500189## Intent:
190## -----------------------------------------------------------------------
191function github_release_pre()
192{
193 local what="$1" ; shift
194 local user="$1" ; shift
195 local repo="$1" ; shift
196 local tag="$1" ; shift
197 local name="$1" ; shift
198 local descr="$1" ; shift
199
200 local iam="${FUNCNAME[0]}"
201 echo "** ${iam}: ENTER"
202
203 case "$what" in
204 gh)
205 declare -a cmd=()
206
207 cmd+=('gh')
208 # cmd+=('--verbose')
209 cmd+=('release')
210 cmd+=('create')
211 cmd+=('--user' "$user")
212 cmd+=('--repo' "$repo")
213 cmd+=('--title' "$name")
214 cmd+=('--descripton' "$descr")
215 cmd+=('--discussion-category' "Announcements")
216 # cmd+=('--latest') - auto based on date & ver
217 cmd+=('--verify-tag')
218
219 # --branch exists, omit switch for tag
220 cmd+=("$tag")
221
222 echo "** ${iam}: RUNNING " "${cmd[@]}"
223 "${cmd[@]}"
224 ;;
225
226 *)
227 declare -a cmd=()
228
229 cmd+=('github-release')
230 # cmd+=('--verbose')
231 cmd+=('release')
232 cmd+=('--user' "$user")
233 cmd+=('--repo' "$repo")
234 cmd+=('--tag' "$tag")
235 cmd+=('--name' "$name")
236 cmd+=('--descripton' "$descr")
237
238 echo "** ${iam}: RUNNING " "${cmd[@]}"
239 "${cmd[@]}"
240 ;;
241 esac
242 set +x
243
244 echo "** ${iam}: ENTER"
245 return
246}
247
248## -----------------------------------------------------------------------
249## Intent:
250## -----------------------------------------------------------------------
251function github_release_view()
252{
253 local what="$1" ; shift
254 local user="$1" ; shift
255 local repo="$1" ; shift
256 local tag="$1" ; shift
257 local name="$1" ; shift
258 local descr="$1" ; shift
259
260 local iam="${FUNCNAME[0]}"
261 echo "** ${iam}: ENTER"
262
263 case "$what" in
264 gh)
265 declare -a cmd=()
266 cmd+=('gh')
267 cmd+=('relase')
268 cmd+=('view')
269 cmd+=("$tag")
270
271 echo "** ${iam}: RUNNING " "${cmd[@]}"
272 "${cmd[@]}"
273 ;;
274
275 *)
276 showReleaseInfo \
277 "$user"\
278 "$repo"\
279 "$tag"
280 ;;
281 esac
282
283 echo "** ${iam}: LEAVE"
284
285 return
286}
287
288## -----------------------------------------------------------------------
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500289## Intent:
Joey Armstrong26707f02023-01-26 12:41:12 -0500290## -----------------------------------------------------------------------
Joey Armstrongf085d872023-01-28 17:52:29 -0500291function showCommands()
Joey Armstrong26707f02023-01-26 12:41:12 -0500292{
293 local iam="${FUNCNAME[0]}"
294 echo "** ${iam}: ENTER"
295
Joey Armstrongf085d872023-01-28 17:52:29 -0500296 declare -a cmds=()
297 cmds+=('github-release')
298 cmds+=('gh')
299
300 local cmd
301 for cmd in "${cmds[@]}";
Joey Armstrong26707f02023-01-26 12:41:12 -0500302 do
Joey Armstrongf085d872023-01-28 17:52:29 -0500303 echo
304 echo "Checking Command: $cmd"
305 echo "==========================================================================="
306 which -a "$cmd"
307 "$cmd" --version
Joey Armstrong26707f02023-01-26 12:41:12 -0500308 done
Joey Armstrongf085d872023-01-28 17:52:29 -0500309
Joey Armstrong26707f02023-01-26 12:41:12 -0500310 echo "** ${iam}: LEAVE"
311 echo
312 return
313}
314
315## -----------------------------------------------------------------------
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500316## Intent: Display info about a release stored on github.
Joey Armstrong26707f02023-01-26 12:41:12 -0500317## -----------------------------------------------------------------------
318function showReleaseInfo()
319{
320 local user="$1" ; shift
321 local repo="$1" ; shift
322 local tag=''
323 if [ $# -gt 0 ]; then
324 tag="$1" ; shift
325 fi
326
327 local iam="${FUNCNAME[0]}"
328 echo "** ${iam}: ENTER"
329
330 cat <<EOM
331
332** -------------------------------------------------------------------
333** ${iam}
334** -------------------------------------------------------------------
335EOM
336
337 declare -a args=()
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500338 [[ $VERBOSE -eq 1 ]] && args+=('--verbose')
339 args+=('info')
Joey Armstrong26707f02023-01-26 12:41:12 -0500340 args+=('--user' "$user")
341 args+=('--repo' "$repo")
342 if [ ${#tag} -gt 0 ]; then
343 args+=('--tag' "$tag")
344 fi
345
346 echo "${iam}: github-relase info"
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500347 github-release "${args[@]}"
Joey Armstrong26707f02023-01-26 12:41:12 -0500348
349 echo "** ${iam}: LEAVE"
350 return
351}
352
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500353##----------------##
354##---] MAIN [---##
355##----------------##
Zack Williams27cd3e52018-09-18 16:44:50 -0700356set -eu -o pipefail
357
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500358iam="${0##*/}"
359
Joey Armstrong7f382ef2023-01-25 12:00:08 -0500360banner
361
Zack Williams27cd3e52018-09-18 16:44:50 -0700362# when not running under Jenkins, use current dir as workspace and a blank
363# project name
364WORKSPACE=${WORKSPACE:-.}
365GERRIT_PROJECT=${GERRIT_PROJECT:-}
366
367# Github organization (or user) this project is published on. Project name should
368# be the same on both Gerrit and GitHub
369GITHUB_ORGANIZATION=${GITHUB_ORGANIZATION:-}
370
371# glob pattern relative to project dir matching release artifacts
Joey Armstrong7f382ef2023-01-25 12:00:08 -0500372# ARTIFACT_GLOB=${ARTIFACT_GLOB:-"release/*"} # stat -- release/* not found, literal string (?)
Joey Armstrong50f6e0b2023-01-24 14:14:08 -0500373ARTIFACT_GLOB=${ARTIFACT_GLOB:-"release/."}
Zack Williams27cd3e52018-09-18 16:44:50 -0700374
375# Temporary staging directory to copy artifacts to
376RELEASE_TEMP="$WORKSPACE/release"
Zack Williams2f8e8472019-05-21 16:29:06 -0700377mkdir -p "$RELEASE_TEMP"
Zack Williams27cd3e52018-09-18 16:44:50 -0700378
379# Use "release" as the default makefile target, can be a space separated list
380RELEASE_TARGETS=${RELEASE_TARGETS:-release}
381
Zack Williams0f398492019-10-23 16:02:24 -0700382
Zack Williams27cd3e52018-09-18 16:44:50 -0700383# check that we're on a semver released version, or exit
384pushd "$GERRIT_PROJECT"
385 GIT_VERSION=$(git tag -l --points-at HEAD)
386
Zack Williams6e070f52019-10-04 11:08:59 -0700387 # match bare versions or v-prefixed golang style version
388 if [[ "$GIT_VERSION" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]
Zack Williams27cd3e52018-09-18 16:44:50 -0700389 then
390 echo "git has a SemVer released version tag: '$GIT_VERSION'"
391 echo "Building artifacts for GitHub release."
392 else
393 echo "No SemVer released version tag found, exiting..."
394 exit 0
395 fi
396popd
397
Zack Williams0f398492019-10-23 16:02:24 -0700398# Set and handle GOPATH and PATH
399export GOPATH=${GOPATH:-$WORKSPACE/go}
400export PATH=$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:$GOPATH/bin
401
402# To support golang projects that require GOPATH to be set and code checked out there
Zack Williams27cd3e52018-09-18 16:44:50 -0700403# If $DEST_GOPATH is not an empty string:
Zack Williams76356cb2019-08-30 10:44:42 -0700404# - create GOPATH within WORKSPACE, and destination directory within
Zack Williams27cd3e52018-09-18 16:44:50 -0700405# - set PATH to include $GOPATH/bin and the system go binaries
Zack Williams76356cb2019-08-30 10:44:42 -0700406# - move project from $WORKSPACE/$GERRIT_PROJECT to new location in $GOPATH
407# - start release process within that directory
Zack Williams27cd3e52018-09-18 16:44:50 -0700408
409DEST_GOPATH=${DEST_GOPATH:-}
Joey Armstrong28eddda2023-01-10 03:09:34 -0500410if [ -n "$DEST_GOPATH" ]; then
Zack Williams27cd3e52018-09-18 16:44:50 -0700411 mkdir -p "$GOPATH/src/$DEST_GOPATH"
Zack Williams27cd3e52018-09-18 16:44:50 -0700412 release_path="$GOPATH/src/$DEST_GOPATH/$GERRIT_PROJECT"
Zack Williams76356cb2019-08-30 10:44:42 -0700413 mv "$WORKSPACE/$GERRIT_PROJECT" "$release_path"
Zack Williams27cd3e52018-09-18 16:44:50 -0700414else
415 release_path="$WORKSPACE/$GERRIT_PROJECT"
416fi
417
418if [ ! -f "$release_path/Makefile" ]; then
419 echo "Makefile not found at $release_path!"
420 exit 1
421else
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500422
Joey Armstrong7f382ef2023-01-25 12:00:08 -0500423 # shellcheck disable=SC2015
424 [[ -v TRACE ]] && { set -x; } || { set +x; } # SC2015 (shellcheck -x)
425
Zack Williams27cd3e52018-09-18 16:44:50 -0700426 pushd "$release_path"
427
428 # Release description is sanitized version of the log message
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500429 RELEASE_DESCRIPTION="$(git log -1 --pretty=%B | tr -dc "[:alnum:]\n\r\.\[\]\:\-\\\/\`\' ")"
Zack Williams27cd3e52018-09-18 16:44:50 -0700430
431 # build the release, can be multiple space separated targets
432 # shellcheck disable=SC2086
Joey Armstrongaf577ab2022-12-15 14:43:33 -0500433 make "$RELEASE_TARGETS"
Zack Williams27cd3e52018-09-18 16:44:50 -0700434
Joey Armstrong26707f02023-01-26 12:41:12 -0500435 # doDebug # deterine why ARTIFACT_GLOB is empty
436 copyToRelease
Joey Armstrong50f6e0b2023-01-24 14:14:08 -0500437
438 # Are we failing on a literal string "release/*" ?
Joey Armstrong1b443bf2023-01-24 10:22:18 -0500439 # cp -v "$ARTIFACT_GLOB" "$RELEASE_TEMP"
Joey Armstrongd8b6f332023-01-25 18:35:17 -0500440 # echo "rsync -rv --checksum \"$artifact_glob/.\" \"$RELEASE_TEMP/.\""
441 # rsync -rv --checksum "$artifact_glob/." "$RELEASE_TEMP/."
Joey Armstrong50f6e0b2023-01-24 14:14:08 -0500442
Joey Armstrong26707f02023-01-26 12:41:12 -0500443 showReleaseInfo \
444 "$GITHUB_ORGANIZATION"\
445 "$GERRIT_PROJECT"
Joey Armstrong50f6e0b2023-01-24 14:14:08 -0500446
Joey Armstrongf085d872023-01-28 17:52:29 -0500447 showCommands
Joey Armstrong26707f02023-01-26 12:41:12 -0500448
449 cat <<EOM
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500450
451** -----------------------------------------------------------------------
452** Create the release:
453** 1) Create initial github release with download area.
454** 2) Generate checksum.SHA256 for all released files.
455** 3) Upload files to complete the release.
456** 4) Display released info from github.
457** -----------------------------------------------------------------------
Joey Armstrong26707f02023-01-26 12:41:12 -0500458EOM
459
Joey Armstrongf085d872023-01-28 17:52:29 -0500460# git auth login
461# git auth logout
462
Joey Armstrong26707f02023-01-26 12:41:12 -0500463 # Usage: github-release [global options] <verb> [verb options]
Zack Williams27cd3e52018-09-18 16:44:50 -0700464 # create release
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500465 echo "** ${iam} Creating Release: $GERRIT_PROJECT - $GIT_VERSION"
Joey Armstrongf085d872023-01-28 17:52:29 -0500466 github_release_pre 'gh'\
467 "$GITHUB_ORGANIZATION"\
468 "$GERRIT_PROJECT"\
469 "$GIT_VERSION"\
470 "$GERRIT_PROJECT - $GIT_VERSION"\
471 "$RELEASE_DESCRIPTION"
Zack Williams27cd3e52018-09-18 16:44:50 -0700472
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500473 echo "** ${iam} Packaging release files"
Zack Williams27cd3e52018-09-18 16:44:50 -0700474 pushd "$RELEASE_TEMP"
475
Joey Armstrongf085d872023-01-28 17:52:29 -0500476 echo "** ${iam}: Files to release:"
477 readarray -t to_release < <(find . -mindepth 1 -maxdepth 1 -type f -print)
478 declare -p to_release
Joey Armstrongd8b6f332023-01-25 18:35:17 -0500479
Zack Williams27cd3e52018-09-18 16:44:50 -0700480 # Generate and check checksums
Zack Williams2f8e8472019-05-21 16:29:06 -0700481 sha256sum -- * > checksum.SHA256
Zack Williams27cd3e52018-09-18 16:44:50 -0700482 sha256sum -c < checksum.SHA256
483
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500484 echo
485 echo "** ${iam} Checksums(checksum.SHA256):"
Zack Williams0d93d842019-05-21 17:02:49 -0700486 cat checksum.SHA256
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500487 echo
Zack Williams0d93d842019-05-21 17:02:49 -0700488
Joey Armstrongf085d872023-01-28 17:52:29 -0500489 echo "** ${iam} Upload files being released"
490 what='gh'
491 case "$what" in
492 gh)
493 gh release upload "$GIT_VERSION" "${to_release[@]}"
494 ;;
495
496 *)
497
498 # upload all files to the release
499 for rel_file in *
500 do
501 echo "** ${iam} Uploading file: $rel_file"
502 github-release \
503 upload \
504 --user "$GITHUB_ORGANIZATION" \
505 --repo "$GERRIT_PROJECT" \
506 --tag "$GIT_VERSION" \
507 --name "$rel_file" \
508 --file "$rel_file"
509 done
510 ;;
511 esac
Zack Williams27cd3e52018-09-18 16:44:50 -0700512
513 popd
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500514 popd
Joey Armstrong26707f02023-01-26 12:41:12 -0500515
Joey Armstrong1962bcf2023-01-27 13:53:18 -0500516 echo "** ${iam} Display released info"
Joey Armstrongf085d872023-01-28 17:52:29 -0500517 github_release_view 'gh'\
518 "$GITHUB_ORGANIZATION"\
519 "$GERRIT_PROJECT"\
520 "$GIT_VERSION"\
521 "$GERRIT_PROJECT - $GIT_VERSION"\
522 "$RELEASE_DESCRIPTION"
Zack Williams27cd3e52018-09-18 16:44:50 -0700523fi
Joey Armstrong28eddda2023-01-10 03:09:34 -0500524
525# [SEE ALSO]
526# -----------------------------------------------------------------------
527# https://www.shellcheck.net/wiki/SC2236
Joey Armstrong26707f02023-01-26 12:41:12 -0500528# https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
Joey Armstrong28eddda2023-01-10 03:09:34 -0500529# -----------------------------------------------------------------------
Joey Armstrongf085d872023-01-28 17:52:29 -0500530# https://cli.github.com/manual/gh_help_reference
531# https://cli.github.com/manual/gh_release
532# -----------------------------------------------------------------------
Joey Armstrong28eddda2023-01-10 03:09:34 -0500533
534# [EOF]