From 83bf6b82ce851faed86c113207db705f8876feb4 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 31 Mar 2026 17:21:13 +0200 Subject: [PATCH] switch to setup_tegonal_scripts.sh --- .gt/remotes/tegonal-scripts/pulled.tsv | 1 + .../src/setup_tegonal_scripts.sh | 51 +++++++++++++++++++ scripts/before-pr.sh | 15 +----- scripts/cleanup-on-push-to-main.sh | 15 +----- scripts/dirs.source.sh | 30 +++++++++++ scripts/extend-expiration-signing-key.sh | 16 +----- scripts/prepare-next-dev-cycle.sh | 10 +--- scripts/release.sh | 15 +----- scripts/run-shellcheck.sh | 5 +- scripts/run-shfmt.sh | 5 +- scripts/update-version-in-non-sh-files.sh | 15 +----- 11 files changed, 90 insertions(+), 88 deletions(-) create mode 100644 lib/tegonal-scripts/src/setup_tegonal_scripts.sh create mode 100644 scripts/dirs.source.sh diff --git a/.gt/remotes/tegonal-scripts/pulled.tsv b/.gt/remotes/tegonal-scripts/pulled.tsv index eeb3ac6..0d9bfee 100644 --- a/.gt/remotes/tegonal-scripts/pulled.tsv +++ b/.gt/remotes/tegonal-scripts/pulled.tsv @@ -38,3 +38,4 @@ v4.11.0 src/utility/cleanups.sh ../lib/tegonal-scripts/src/utility/cleanups.sh . v4.11.0 src/utility/string-utils.sh ../lib/tegonal-scripts/src/utility/string-utils.sh .* false e6bad5ae8aa26188d1f09815d5336b85e4dfdb4e92f8869d531d8f095410293b0aa67bdc117b45f23bc23a6804d79e83392cb6d0735ecbd97d2d478e60bab473 v4.11.0 src/ci/install-shfmt.sh ../lib/tegonal-scripts/src/ci/install-shfmt.sh .* false 43dc9cbefc9eb0ae965e022cd413675bdad95d1b4ba36c82d444aaca2212f85a800b8f52140acde0968e70b0a609b4ff01498400273b639832bbb32225463831 v4.11.0 src/qa/run-shfmt.sh ../lib/tegonal-scripts/src/qa/run-shfmt.sh .* false 0c34f42975fc9459a6f8014bc4c72a1c1dff5c6eca36761dcadc46b1690d84e5aafed74dd48a16533eff89dfa5141c26640429a6b2c9fb0ce2b47f45a68e392c +v4.11.0 src/setup_tegonal_scripts.sh ../lib/tegonal-scripts/src/setup_tegonal_scripts.sh .* false 4802417b353cad2de4c2ff52cae73bab06ab294d6af4e3d85ae08e2d6bf63a7ead5eb68c2404238ef667064e8ea2fe319b437c693f7cceb3ba29ab9f1718ab7a diff --git a/lib/tegonal-scripts/src/setup_tegonal_scripts.sh b/lib/tegonal-scripts/src/setup_tegonal_scripts.sh new file mode 100644 index 0000000..7b1869b --- /dev/null +++ b/lib/tegonal-scripts/src/setup_tegonal_scripts.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# __ __ +# / /____ ___ ____ ___ ___ _/ / This script is provided to you by https://github.com/tegonal/scripts +# / __/ -_) _ `/ _ \/ _ \/ _ `/ / Copyright 2022 Tegonal Genossenschaft +# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0 +# /___/ Please report bugs and contribute back your improvements +# +# Version: v4.11.0 +####### Description ############# +# +# script which should be sourced and sets up variables and functions for the scripts +# +####### Usage ################### +# +# #!/usr/bin/env bash +# set -euo pipefail +# shopt -s inherit_errexit || { echo >&2 "please update to bash 5, see errors above" && exit 1; } +# +# if ! [[ -v dir_of_tegonal_scripts ]]; then +# # Assumes your script is in (root is project folder) e.g. /src or /scripts and +# # the tegonal scripts have been pulled via gt and put into /lib/tegonal-scripts +# dir_of_tegonal_scripts="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)/../lib/tegonal-scripts/src" +# source "$dir_of_tegonal_scripts/setup_tegonal_scripts.sh" "$dir_of_tegonal_scripts" +# fi +# +# sourceOnce "$dir_of_tegonal_scripts/utility/io.sh" +# +################################### +set -euo pipefail +shopt -s inherit_errexit || { echo >&2 "please update to bash 5, see errors above" && exit 1; } +unset CDPATH + +# shellcheck disable=SC2034 # global var used in log.sh +declare -A TEGONAL_SCRIPTS_SUPPRESSED_DEPRECATION=() +# shellcheck disable=SC2034 # global var used in log.sh +declare TEGONAL_SCRIPTS_ERROR_ON_DEPRECATION=true + +if (($# != 1)); then + printf >&2 "\033[0;31mERROR\033[0m: You need to pass the path to the tegonal scripts directory as first argument. Following an example\n" + echo >&2 "source \"\$dir_of_tegonal_scripts/setup_tegonal_scripts.sh\" \"\$dir_of_tegonal_scripts\"" + exit 9 +fi + +declare dir_of_tegonal_scripts +if ! dir_of_tegonal_scripts=$(realpath "$1"); then + printf >&2 "\033[0;31mERROR\033[0m: looks like the passed dir_of_tegonal_scripts is not a realpath: %s" "$1" + exit 9 +fi +readonly dir_of_tegonal_scripts +source "$dir_of_tegonal_scripts/utility/source-once.sh" diff --git a/scripts/before-pr.sh b/scripts/before-pr.sh index d769d33..f9996d0 100755 --- a/scripts/before-pr.sh +++ b/scripts/before-pr.sh @@ -15,21 +15,8 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi +source "$scriptsDir/dirs.source.sh" -if ! [[ -v projectDir ]]; then - projectDir="$(realpath "$scriptsDir/../")" - readonly projectDir -fi - -if ! [[ -v dir_of_github_commons ]]; then - dir_of_github_commons="$projectDir/src" - readonly dir_of_github_commons -fi - -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$scriptsDir/../lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi sourceOnce "$scriptsDir/run-shellcheck.sh" sourceOnce "$scriptsDir/cleanup-on-push-to-main.sh" diff --git a/scripts/cleanup-on-push-to-main.sh b/scripts/cleanup-on-push-to-main.sh index 51c5ca7..5658855 100755 --- a/scripts/cleanup-on-push-to-main.sh +++ b/scripts/cleanup-on-push-to-main.sh @@ -16,21 +16,8 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi +source "$scriptsDir/dirs.source.sh" -if ! [[ -v projectDir ]]; then - projectDir="$(realpath "$scriptsDir/../")" - readonly projectDir -fi - -if ! [[ -v dir_of_github_commons ]]; then - dir_of_github_commons="$projectDir/src" - readonly dir_of_github_commons -fi - -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$projectDir/lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi sourceOnce "$dir_of_tegonal_scripts/utility/cleanups.sh" sourceOnce "$dir_of_github_commons/gt/pull-hook-functions.sh" sourceOnce "$dir_of_tegonal_scripts/utility/update-bash-docu.sh" diff --git a/scripts/dirs.source.sh b/scripts/dirs.source.sh new file mode 100644 index 0000000..3b14bc7 --- /dev/null +++ b/scripts/dirs.source.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2034,SC2168,SC2154 +# +# __ __ +# / /____ ___ ____ ___ ___ _/ / This script is provided to you by https://github.com/tegonal/github-commons +# / __/ -_) _ `/ _ \/ _ \/ _ `/ / Copyright 2022 Tegonal Genossenschaft +# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under European Union Public License 1.2 +# /___/ Please report bugs and contribute back your improvements +# +# Version: v5.1.0-SNAPSHOT +####### Description ############# +# +# constants intended to be sourced in sh files in the scripts folder +# +################################### + +if ! [[ -v projectDir ]]; then + projectDir="$(realpath "$scriptsDir/../")" + readonly projectDir +fi + +if ! [[ -v dir_of_github_commons ]]; then + dir_of_github_commons="$projectDir/src" + readonly dir_of_github_commons +fi + +if ! [[ -v dir_of_tegonal_scripts ]]; then + dir_of_tegonal_scripts="$scriptsDir/../lib/tegonal-scripts/src" + source "$dir_of_tegonal_scripts/setup_tegonal_scripts.sh" "$dir_of_tegonal_scripts" +fi diff --git a/scripts/extend-expiration-signing-key.sh b/scripts/extend-expiration-signing-key.sh index 60beea4..64ed33b 100755 --- a/scripts/extend-expiration-signing-key.sh +++ b/scripts/extend-expiration-signing-key.sh @@ -15,21 +15,7 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi - -if ! [[ -v projectDir ]]; then - projectDir="$(realpath "$scriptsDir/../")" - readonly projectDir -fi - -if ! [[ -v dir_of_github_commons ]]; then - dir_of_github_commons="$projectDir/src" - readonly dir_of_github_commons -fi - -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$scriptsDir/../lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi +source "$scriptsDir/dirs.source.sh" function extendExpirationSigningKey() { local tmpDir diff --git a/scripts/prepare-next-dev-cycle.sh b/scripts/prepare-next-dev-cycle.sh index 8ecab60..19eea2a 100755 --- a/scripts/prepare-next-dev-cycle.sh +++ b/scripts/prepare-next-dev-cycle.sh @@ -16,16 +16,8 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi +source "$scriptsDir/dirs.source.sh" -if ! [[ -v projectDir ]]; then - projectDir="$(realpath "$scriptsDir/../")" - readonly projectDir -fi - -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$projectDir/lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi sourceOnce "$dir_of_tegonal_scripts/releasing/prepare-files-next-dev-cycle.sh" sourceOnce "$scriptsDir/before-pr.sh" sourceOnce "$scriptsDir/update-version-in-non-sh-files.sh" diff --git a/scripts/release.sh b/scripts/release.sh index 4bf51f9..8fb5d49 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -16,21 +16,8 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi +source "$scriptsDir/dirs.source.sh" -if ! [[ -v projectDir ]]; then - projectDir="$(realpath "$scriptsDir/../")" - readonly projectDir -fi - -if ! [[ -v dir_of_github_commons ]]; then - dir_of_github_commons="$projectDir/src" - readonly dir_of_github_commons -fi - -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$projectDir/lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi sourceOnce "$dir_of_tegonal_scripts/releasing/release-files.sh" sourceOnce "$scriptsDir/before-pr.sh" sourceOnce "$scriptsDir/prepare-next-dev-cycle.sh" diff --git a/scripts/run-shellcheck.sh b/scripts/run-shellcheck.sh index a651b6e..fa12631 100755 --- a/scripts/run-shellcheck.sh +++ b/scripts/run-shellcheck.sh @@ -15,11 +15,8 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi +source "$scriptsDir/dirs.source.sh" -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$scriptsDir/../lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi sourceOnce "$dir_of_tegonal_scripts/qa/run-shellcheck.sh" function customRunShellcheck() { diff --git a/scripts/run-shfmt.sh b/scripts/run-shfmt.sh index fdb2a99..83100bf 100755 --- a/scripts/run-shfmt.sh +++ b/scripts/run-shfmt.sh @@ -16,11 +16,8 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi +source "$scriptsDir/dirs.source.sh" -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$scriptsDir/../lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi sourceOnce "$dir_of_tegonal_scripts/qa/run-shfmt.sh" function customRunShfmt() { diff --git a/scripts/update-version-in-non-sh-files.sh b/scripts/update-version-in-non-sh-files.sh index 197dc7f..376304b 100755 --- a/scripts/update-version-in-non-sh-files.sh +++ b/scripts/update-version-in-non-sh-files.sh @@ -16,21 +16,8 @@ if ! [[ -v scriptsDir ]]; then scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)" readonly scriptsDir fi +source "$scriptsDir/dirs.source.sh" -if ! [[ -v projectDir ]]; then - projectDir="$(realpath "$scriptsDir/../")" - readonly projectDir -fi - -if ! [[ -v dir_of_github_commons ]]; then - dir_of_github_commons="$projectDir/src" - readonly dir_of_github_commons -fi - -if ! [[ -v dir_of_tegonal_scripts ]]; then - dir_of_tegonal_scripts="$scriptsDir/../lib/tegonal-scripts/src" - source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts" -fi sourceOnce "$dir_of_tegonal_scripts/utility/parse-args.sh" function updateVersionInNonShFiles() {