From 58c784b0a0e239b0489aea87ac90d559fe688fbd Mon Sep 17 00:00:00 2001 From: "Rick Farina (Zero_Chaos)" Date: Tue, 30 Jan 2024 14:29:06 -0500 Subject: [PATCH 1/3] shellcheck fixes Conditionalize use of signify-openbsd Closes: https://github.com/gnuradio/volk/issues/748 Signed-off-by: Rick Farina (Zero_Chaos) --- scripts/tools/release.sh | 43 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/scripts/tools/release.sh b/scripts/tools/release.sh index 5361db2c7..14da1144c 100755 --- a/scripts/tools/release.sh +++ b/scripts/tools/release.sh @@ -6,7 +6,9 @@ # # SPDX-License-Identifier: LGPL-3.0-or-later -setopt ERR_EXIT #exit on error +set -e +set -u + #Project name project=volk #What to prefix in release tags in front of the version number @@ -55,22 +57,22 @@ shortlog=" ## [${version}] - $(date +'%Y-%m-%d') -$(git shortlog -e ${last_release}..HEAD) +$(git shortlog -e "${last_release}"..HEAD) " echo "${shortlog}" -echo "${shortlog}" > ${deltafile} +echo "${shortlog}" > "${deltafile}" -${EDITOR} ${deltafile} +${EDITOR} "${deltafile}" -echo "$(cat ${deltafile})" >> ${changelog} -echo "${releaseprefix}${version}" > ${lastreleasefile} +cat "${deltafile}" >> "${changelog}" +echo "${releaseprefix}${version}" > "${lastreleasefile}" # 3. Commit changelog git commit -m "Release ${version}" "${changelog}" "${lastreleasefile}" CMakeLists.txt # 4. prepare tag -cat "${deltafile}" > ${annotationfile} +cat "${deltafile}" > "${annotationfile}" # Append the HEAD commit hash to the annotation echo "git-describes-hash: $(git rev-parse --verify HEAD)" >> "${annotationfile}" @@ -93,11 +95,11 @@ outfile="${tempdir}/${tarprefix}.tar" git archive "--output=${outfile}" "--prefix=${tarprefix}/" HEAD # Append submodule archives git submodule foreach --recursive "git archive --output ${tempdir}/${tarprefix}-sub-\${sha1}.tar --prefix=${tarprefix}/\${sm_path}/ HEAD" -if [[ $(ls ${tempdir}/${tarprefix}-sub*.tar | wc -l) != 0 ]]; then +if [[ $(ls "${tempdir}/${tarprefix}"-sub*.tar | wc -l) != 0 ]]; then # combine all archives into one tar - tar --concatenate --file ${outfile} ${tempdir}/${tarprefix}-sub*.tar + tar --concatenate --file "${outfile}" "${tempdir}/${tarprefix}"-sub*.tar fi -echo "Created tape archive '${outfile}' of size $(du -h ${outfile})." +echo "Created tape archive ${outfile} of size $(du -h "${outfile}")." # 6. compress echo "compressing:" @@ -113,15 +115,17 @@ echo "…compressed." # 7. sign # 7.1 with openbsd-signify -echo "signing file list…" -filelist="${tempdir}/${version}.sha256" -pushd "${tempdir}" -sha256sum --tag *.tar.* > "${filelist}" -signify-openbsd -S -e -s "${seckey}" -m "${filelist}" -echo "…signed. Check with 'signify -C -p \"${pubkey}\" -x \"${filelist}\"'." -signify-openbsd -C -p "${pubkey}" -x "${filelist}.sig" -popd -echo "checked." +if type 'signify-openbsd' > /dev/null; then + echo "signing file list…" + filelist="${tempdir}/${version}.sha256" + pushd "${tempdir}" || exit 1 + sha256sum --tag -- *.tar.* > "${filelist}" + signify-openbsd -S -e -s "${seckey}" -m "${filelist}" + echo "…signed. Check with 'signify -C -p \"${pubkey}\" -x \"${filelist}\"'." + signify-openbsd -C -p "${pubkey}" -x "${filelist}.sig" + popd + echo "checked." +fi # 7.2 with GPG echo "signing tarballs with GPG ..." @@ -143,4 +147,3 @@ echo "Release tag: 'git push ${remote} v${releaseprefix}${version}'" # git push "${remote}" HEAD # git push "${remote}" "v${releaseprefix}${version}" #fi - From e322a819814090cc0c9d4ec96272bf258b5a146a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20M=C3=BCller?= Date: Tue, 30 Jan 2024 23:12:47 +0100 Subject: [PATCH 2/3] scripts/release: fix multi-concatenation of submodule tars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also, add early exit on existing new or missing old tag Signed-off-by: Marcus Müller --- scripts/tools/release.sh | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/scripts/tools/release.sh b/scripts/tools/release.sh index 14da1144c..8b4247ddd 100755 --- a/scripts/tools/release.sh +++ b/scripts/tools/release.sh @@ -49,6 +49,21 @@ version_maint=$(grep -i 'set(version_info_maint' CMakeLists.txt |\ sed 's/.*VERSION_INFO_MAINT_VERSION[[:space:]]*\([[:digit:]a-zA-z-]*\))/\1/i') version="${version_major}.${version_minor}.${version_maint}" last_release="$(cat ${lastreleasefile})" + +# Check whether tag of last release exists +if git --no-pager reflog "${last_release}" > /dev/null 2>&1 ; then + # all right + echo "Found last tag ${last_release}" +else + echo "Last release tag ${last_release} does not exist, aborting…" + exit -1 +fi +# Check for whether tag already exists +if git --no-pager reflog "${releaseprefix}${version}" > /dev/null 2>&1 ; then + echo "Tag ${releaseprefix}${version} already exists, aborting…" + exit -2 +fi + echo "Releasing version ${version}" # 2. Prepare Changelog @@ -94,12 +109,15 @@ tarprefix="${project}-${version}" outfile="${tempdir}/${tarprefix}.tar" git archive "--output=${outfile}" "--prefix=${tarprefix}/" HEAD # Append submodule archives -git submodule foreach --recursive "git archive --output ${tempdir}/${tarprefix}-sub-\${sha1}.tar --prefix=${tarprefix}/\${sm_path}/ HEAD" -if [[ $(ls "${tempdir}/${tarprefix}"-sub*.tar | wc -l) != 0 ]]; then - # combine all archives into one tar - tar --concatenate --file "${outfile}" "${tempdir}/${tarprefix}"-sub*.tar -fi -echo "Created tape archive ${outfile} of size $(du -h "${outfile}")." +git submodule update --init --recursive +git submodule foreach --recursive "git archive --output \"${tempdir}/${tarprefix}-sub-\${sha1}.tar\" --prefix=${tarprefix}/\${sm_path}/ HEAD" +submodule_tars=( "${tempdir}/${tarprefix}-sub-*.tar" ) +# if the number of entries isn't zero +for submod_tar in $submodule_tars ; do + echo "Appending submodule tar ${submod_tar} to ${outfile}…" + tar --concatenate --file "${outfile}" "${submod_tar}" +done +echo "Created tape archive ${outfile} of size $(du -h "${outfile}")" # 6. compress echo "compressing:" From 1a8ddd571af9245645642e5198e6f950e35efcfe Mon Sep 17 00:00:00 2001 From: "Rick Farina (Zero_Chaos)" Date: Tue, 30 Jan 2024 17:43:39 -0500 Subject: [PATCH 3/3] bash negative exit codes are not portable, let's be positive Signed-off-by: Rick Farina (Zero_Chaos) --- scripts/tools/release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/tools/release.sh b/scripts/tools/release.sh index 8b4247ddd..7bef7eb43 100755 --- a/scripts/tools/release.sh +++ b/scripts/tools/release.sh @@ -56,12 +56,12 @@ if git --no-pager reflog "${last_release}" > /dev/null 2>&1 ; then echo "Found last tag ${last_release}" else echo "Last release tag ${last_release} does not exist, aborting…" - exit -1 + exit 255 fi # Check for whether tag already exists if git --no-pager reflog "${releaseprefix}${version}" > /dev/null 2>&1 ; then echo "Tag ${releaseprefix}${version} already exists, aborting…" - exit -2 + exit 254 fi echo "Releasing version ${version}"