Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 71 additions & 69 deletions .gt/remotes/tegonal-scripts/pulled.tsv

Large diffs are not rendered by default.

106 changes: 58 additions & 48 deletions lib/tegonal-scripts/src/ci/install-shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# installs shellcheck v0.11.0 into $HOME/.local/lib and sets up a symlink in $HOME/.local/bin
Expand Down Expand Up @@ -42,56 +42,66 @@ function die() {
exit 1
}

currentDir=$(pwd)
tmpDir=$(mktemp -d -t download-shellcheck-XXXXXXXXXX) || die "could not create a temp directory"
cd "$tmpDir"
shellcheckVersion="v0.11.0"
tarFile="shellcheck-$shellcheckVersion.linux.x86_64.tar.xz"
expectedSha="8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 $tarFile"
echo "$expectedSha" >"$tarFile.sha256"
function main() {
local currentDir tmpDir shellcheckVersion tarFile expectedSha url
currentDir=$(pwd)
tmpDir=$(mktemp -d -t download-shellcheck-XXXXXXXXXX) || die "could not create a temp directory"
# shellcheck disable=SC2064 # we want to expand it here since the vars are local to main
trap "cd '$currentDir'; rm -rf '$tmpDir'" EXIT
cd "$tmpDir"
shellcheckVersion="v0.11.0"
tarFile="shellcheck-$shellcheckVersion.linux.x86_64.tar.xz"
expectedSha="8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 $tarFile"
echo "$expectedSha" >"$tarFile.sha256"

url="https://github.com/koalaman/shellcheck/releases/download/$shellcheckVersion/$tarFile"
echo "going to download shellcheck $shellcheckVersion from: $url"
if command -v curl >/dev/null; then
curl --fail -L -O "$url" || die "could not download shellcheck"
else
# if curl does not exist, then we try it with wget
wget --no-verbose "$url"
fi
sha256sum -c "$tarFile.sha256" || {
actualSha="$(sha256sum "$tarFile")"
die "checksum did not match, aborting\nexpected:\n%s\ngiven :\n%s" "$expectedSha" "$actualSha"
}
tar -xf "./$tarFile"
chmod +x "./shellcheck-$shellcheckVersion/shellcheck" || die "could not make shellcheck executable"
url="https://github.com/koalaman/shellcheck/releases/download/$shellcheckVersion/$tarFile"
echo "going to download shellcheck $shellcheckVersion from: $url"
if command -v curl >/dev/null; then
curl --fail -L -O "$url" || die "could not download shellcheck"
else
# if curl does not exist, then we try it with wget
wget --no-verbose "$url" || die "could not download shellcheck"
fi
sha256sum -c "$tarFile.sha256" || {
local actualSha
actualSha="$(sha256sum "$tarFile")"
die "checksum did not match, aborting\nexpected:\n%s\ngiven :\n%s\n" "$expectedSha" "$actualSha"
}
tar -xf "./$tarFile"
chmod +x "./shellcheck-$shellcheckVersion/shellcheck" || die "could not make shellcheck executable"

local shellcheckInTmp homeLocalBin homeLocalLib shellcheckInHomeLocalLib shellcheckBin
shellcheckInTmp="$tmpDir/shellcheck-$shellcheckVersion"
homeLocalBin="$HOME/.local/bin"
homeLocalLib="$HOME/.local/lib"
shellcheckInHomeLocalLib="$homeLocalLib/shellcheck-$shellcheckVersion"
shellcheckBin="$homeLocalBin/shellcheck"

shellcheckInTmp="$tmpDir/shellcheck-$shellcheckVersion"
homeLocalBin="$HOME/.local/bin"
homeLocalLib="$HOME/.local/lib"
shellcheckInHomeLocalLib="$homeLocalLib/shellcheck-$shellcheckVersion"
shellcheckBin="$homeLocalBin/shellcheck"
mkdir -p "$homeLocalBin" || die "was not able to create the bin directory %s" "$homeLocalBin"

mkdir -p "$homeLocalBin" || die "was not able to create the bin directory %s" "$homeLocalBin"
if [[ -d "$shellcheckInHomeLocalLib" ]]; then
echo "going to remove the existing installation in $shellcheckInHomeLocalLib"
rm -r "$shellcheckInHomeLocalLib" || die "was not able to remove a previous installation in %s" "$shellcheckInHomeLocalLib"
else
mkdir -p "$homeLocalLib" || die "was not able to create the installation directory %s" "$homeLocalLib"
fi
mv "$shellcheckInTmp" "$shellcheckInHomeLocalLib"
if [[ -f "$shellcheckBin" ]]; then
rm "$shellcheckBin"
fi
ln -s "$shellcheckInHomeLocalLib/shellcheck" "$shellcheckBin"

if [[ -d "$shellcheckInHomeLocalLib" ]]; then
echo "going to remove the existing installation in $shellcheckInHomeLocalLib"
rm -r "$shellcheckInHomeLocalLib" || die "was not able to remove a previous installation in %s" "$shellcheckInHomeLocalLib"
else
mkdir -p "$homeLocalLib" || die "was not able to create the installation directory %s" "$homeLocalLib"
fi
mv "$shellcheckInTmp" "$shellcheckInHomeLocalLib"
if [[ -f "$shellcheckBin" ]]; then
rm "$shellcheckBin"
fi
ln -s "$shellcheckInHomeLocalLib/shellcheck" "$shellcheckBin"
cd "$currentDir"

cd "$currentDir"
local shellcheckPath shellcheckCurrentVersion
shellcheckPath=$(command -v shellcheck)
if [[ $shellcheckPath != "$shellcheckBin" ]]; then
shellcheckCurrentVersion=$(shellcheck --version)
logError "was able to install shellcheck in %s but \`command -v shellcheck\` returns another path:\n%s\nFollowing the output of \`shellcheck --version\`:\n%s" "$shellcheckBin" "$shellcheckPath" "$shellcheckCurrentVersion"
else
shellcheck --version
printf "\033[0;32mSUCCESS\033[0m: installed shellcheck %s in %s\n" "$shellcheckVersion" "$homeLocalLib"
fi
}

shellcheckPath=$(command -v shellcheck)
if [[ $shellcheckPath != "$shellcheckBin" ]]; then
shellcheckCurrentVersion=$(shellcheck --version)
logError "was able to install shellcheck in %s but \`command -v shellcheck\` returns another path:\n%s\nFollowing the output of \`shellcheck --version\`:\n%s" "$shellcheckBin" "$shellcheckPath" "$shellcheckCurrentVersion"
else
shellcheck --version
printf "\033[0;32mSUCCESS\033[0m: installed shellcheck %s in %s\n" "$shellcheckVersion" "$homeLocalLib"
fi
main "$@"
88 changes: 49 additions & 39 deletions lib/tegonal-scripts/src/ci/install-shfmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# installs shfmt v3.12.0_linux_amd64 into $HOME/.local/bin
Expand Down Expand Up @@ -42,47 +42,57 @@ function die() {
exit 1
}

currentDir=$(pwd)
tmpDir=$(mktemp -d -t download-shfmt-XXXXXXXXXX) || die "could not create a temp directory"
cd "$tmpDir"
shfmtVersion="v3.12.0"
binFile="shfmt_${shfmtVersion}_linux_amd64"
expectedSha="d9fbb2a9c33d13f47e7618cf362a914d029d02a6df124064fff04fd688a745ea $binFile"
echo "$expectedSha" >"$binFile.sha256"
function main() {
local currentDir tmpDir shfmtVersion binFile expectedSha url
currentDir=$(pwd)
tmpDir=$(mktemp -d -t download-shfmt-XXXXXXXXXX) || die "could not create a temp directory"
# shellcheck disable=SC2064 # we want to expand it here since the vars are local to main
trap "cd '$currentDir'; rm -rf '$tmpDir'" EXIT
cd "$tmpDir"
shfmtVersion="v3.12.0"
binFile="shfmt_${shfmtVersion}_linux_amd64"
expectedSha="d9fbb2a9c33d13f47e7618cf362a914d029d02a6df124064fff04fd688a745ea $binFile"
echo "$expectedSha" >"$binFile.sha256"

url="https://github.com/mvdan/sh/releases/download/$shfmtVersion/$binFile"
echo "going to download shfmt $shfmtVersion from: $url"
if command -v curl >/dev/null; then
curl --fail -L -O "$url" || die "could not download shfmt"
else
# if curl does not exist, then we try it with wget
wget --no-verbose "$url"
fi
sha256sum -c "$binFile.sha256" || {
actualSha="$(sha256sum "$binFile")"
die "checksum did not match, aborting\nexpected:\n%s\ngiven :\n%s" "$expectedSha" "$actualSha"
}
chmod +x "./$binFile" || die "could not make shfmt executable"
url="https://github.com/mvdan/sh/releases/download/$shfmtVersion/$binFile"
echo "going to download shfmt $shfmtVersion from: $url"
if command -v curl >/dev/null; then
curl --fail -L -O "$url" || die "could not download shfmt"
else
# if curl does not exist, then we try it with wget
wget --no-verbose "$url" || die "could not download shfmt"
fi
sha256sum -c "$binFile.sha256" || {
local actualSha
actualSha="$(sha256sum "$binFile")"
die "checksum did not match, aborting\nexpected:\n%s\ngiven :\n%s" "$expectedSha" "$actualSha"
}
chmod +x "./$binFile" || die "could not make shfmt executable"

local shfmtInTmp homeLocalBin shfmtBin
shfmtInTmp="$tmpDir/$binFile"
homeLocalBin="$HOME/.local/bin"
shfmtBin="$homeLocalBin/shfmt"

shfmtInTmp="$tmpDir/$binFile"
homeLocalBin="$HOME/.local/bin"
shfmtBin="$homeLocalBin/shfmt"
mkdir -p "$homeLocalBin" || die "was not able to create the bin directory %s" "$homeLocalBin"

mkdir -p "$homeLocalBin" || die "was not able to create the bin directory %s" "$homeLocalBin"
if [[ -f "$shfmtBin" ]]; then
echo "going to remove the existing installation in $homeLocalBin"
rm "$shfmtBin" || die "was not able to remove a previous installation in %s" "$homeLocalBin"
fi
mv "$shfmtInTmp" "$shfmtBin"

if [[ -f "$shfmtBin" ]]; then
echo "going to remove the existing installation in $homeLocalBin"
rm "$shfmtBin" || die "was not able to remove a previous installation in %s" "$homeLocalBin"
fi
mv "$shfmtInTmp" "$shfmtBin"
cd "$currentDir"

cd "$currentDir"
local shfmtPath shfmtCurrentVersion
shfmtPath=$(command -v shfmt)
if [[ $shfmtPath != "$shfmtBin" ]]; then
shfmtCurrentVersion=$(shfmt --version)
logError "was able to install shfmt in %s but \`command -v shfmt\` returns another path:\n%s\nFollowing the output of \`shfmt --version\`:\n%s" "$shfmtBin" "$shfmtPath" "$shfmtCurrentVersion"
else
shfmt --version
printf "\033[0;32mSUCCESS\033[0m: installed shfmt %s in %s\n" "$shfmtVersion" "$homeLocalBin"
fi
}

shfmtPath=$(command -v shfmt)
if [[ $shfmtPath != "$shfmtBin" ]]; then
shfmtCurrentVersion=$(shfmt --version)
logError "was able to install shfmt in %s but \`command -v shfmt\` returns another path:\n%s\nFollowing the output of \`shfmt --version\`:\n" "$shfmtBin" "$shfmtPath" "$shfmtCurrentVersion"
else
shfmt --version
printf "\033[0;32mSUCCESS\033[0m: installed shfmt %s in %s\n" "$shfmtVersion" "$homeLocalBin"
fi
main "$@"
2 changes: 1 addition & 1 deletion lib/tegonal-scripts/src/qa/check-help-callable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.1.0
# Version: v5.2.0
####### Description #############
#
# function which calls given scripts by passing --help and checks that the exit code is 99 as expected
Expand Down
4 changes: 2 additions & 2 deletions lib/tegonal-scripts/src/qa/run-shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# function which searches for *.sh files within defined paths (directories or a single *.sh) and
Expand All @@ -19,7 +19,7 @@
# shopt -s inherit_errexit || { echo >&2 "please update to bash 5, see errors above" && exit 1; }
# scriptsDir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null && pwd 2>/dev/null)"
# # Assumes tegonal's scripts were fetched with gt - adjust location accordingly
# dir_of_tegonal_scripts="scriptsDir/../lib/tegonal-scripts/src"
# dir_of_tegonal_scripts="$scriptsDir/../lib/tegonal-scripts/src"
# source "$dir_of_tegonal_scripts/setup_tegonal_scripts.sh" "$dir_of_tegonal_scripts"
# source "$dir_of_tegonal_scripts/qa/run-shellcheck.sh"
#
Expand Down
2 changes: 1 addition & 1 deletion lib/tegonal-scripts/src/qa/run-shfmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# function which runs shfmt on defined paths, ignoring *.doc.sh files.
Expand Down
7 changes: 6 additions & 1 deletion lib/tegonal-scripts/src/releasing/common-constants.source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under European Union Public License 1.2
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# constants intended to be sourced into a function
Expand Down Expand Up @@ -39,6 +39,7 @@ local -r projectsRootDirParamDocu='(optional) The projects directory -- default:
local -r additionalPatternParamPatternLong='--pattern'
local -r additionalPatternParamPattern="-p|$additionalPatternParamPatternLong"
local -r additionalPatternParamDocu='(optional) pattern which is used in a perl command (separator /) to search & replace additional occurrences. It should define two match groups and the replace operation looks as follows: '"\\\${1}\$version\\\${2}"
local -r additionalPatternDefaultArg=''

local -r nextVersionParamPatternLong='--next-version'
local -r nextVersionParamPattern="-nv|$nextVersionParamPatternLong"
Expand Down Expand Up @@ -69,3 +70,7 @@ local -r afterVersionUpdateHookParamPatternLong='--after-version-update-hook'
local -r afterVersionUpdateHookParamPattern="$afterVersionUpdateHookParamPatternLong"
local -r afterVersionUpdateHookParamDocu="(optional) if defined, then this function is called after versions were updated and before calling beforePr. \
The following arguments are passed: $versionParamPatternLong version $projectsRootDirParamPatternLong projectsRootDir and $additionalPatternParamPatternLong additionalPattern"

local -r repoUrlParamPatternLong='--repo-url'
local -r repoUrlParamPattern="$repoUrlParamPatternLong"
local -r repoUrlParamDocu='The url to the repo (e.g. https://github.com/tegonal/scripts)'
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# intended to be sourced into a function which expects params version and nextVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034,SC2168
#
# __ __
# / /____ ___ ____ ___ ___ _/ / This script is provided to you by https://github.com/tegonal/scripts
# / __/ -_) _ `/ _ \/ _ \/ _ `/ / Copyright 2022 Tegonal Genossenschaft <info@tegonal.com>
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.2.0
####### Description #############
#
# Defines default args for ...params-definition.source.sh for files which use the same arguments but allow optional
# parameters (the afterVersionUpdateHook as such should not)
#
###################################

if ! [[ -v projectsRootDir ]]; then projectsRootDir=$(realpath ".") || die "could not determine realpath of ."; fi
# shellcheck disable=SC2154 # defined in common-constants which we assume is sourced when this file is sourced
if ! [[ -v additionalPattern ]]; then additionalPattern="$additionalPatternDefaultArg"; fi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines the parameters for afterVersionUpdateHook functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines local variables for the params defined in ...params-definition.source.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines default args for ...params-definition.source.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines the parameters for the function prepareFilesNextDevCycleTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines local variables for the params defined in ...params-definition.source.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines default args for ...params-definition.source.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines the parameters for a prepareNextDevCycle function which is based on prepareNextDevCycleTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
# /___/ Please report bugs and contribute back your improvements
#
# Version: v5.0.0
# Version: v5.2.0
####### Description #############
#
# Defines local variables for the params defined in ...params-definition.source.sh
Expand Down
Loading
Loading