-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend expiration take 2 - update in src/gt and also create signature
- Loading branch information
Showing
6 changed files
with
149 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# / /____ ___ ____ ___ ___ _/ / This file is provided to you by https://github.com/tegonal/github-commons | ||
# / __/ -_) _ `/ _ \/ _ \/ _ `/ / Copyright 2022 Tegonal Genossenschaft <info@tegonal.com> | ||
# \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Creative Commons Zero v1.0 Universal | ||
# /___/ Please report bugs and contribute back your improvements | ||
# | ||
# Version: v2.9.0-SNAPSHOT | ||
################################### | ||
set -euo pipefail | ||
shopt -s inherit_errexit | ||
unset CDPATH | ||
|
||
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 | ||
|
||
sourceOnce "$dir_of_tegonal_scripts/utility/gpg-utils.sh" | ||
|
||
function setupTmpDir() { | ||
local -r tmpDir=$1 | ||
mkdir "$tmpDir" | ||
local -r gpgDir="$tmpDir/gpg" | ||
mkdir "$gpgDir" | ||
chmod 700 "$gpgDir" | ||
} | ||
|
||
function importGpgViaClipboard() { | ||
local -r tmpDir=$1 | ||
local -r keyId=$2 | ||
local -r gpgDir="$tmpDir/gpg" | ||
|
||
echo "copy the private key of $keyId into your clipboard and press enter" | ||
read -r | ||
xclip -o -sel clipboard >"$tmpDir/$keyId.asc" | ||
# we make sure the asc ends with an empty line otherwise gpg will fail | ||
echo "" >>"./$keyId.asc" | ||
gpg --homedir "$gpgDir" --import "$tmpDir/$keyId.asc" | ||
|
||
gpg --homedir "$gpgDir" --list-secret-keys | ||
} | ||
|
||
function extendExpirationSigningKey() { | ||
trap "[[ -d /tmp/signing-key ]] && rm -r /tmp/signing-key" EXIT | ||
|
||
local -r signingKey="$dir_of_github_commons/gt/signing-key.public.asc" | ||
local -r actualSig="$dir_of_github_commons/gt/signing-key.public.asc.actual_sig" | ||
local -r tmpDir="/tmp/signing-key" | ||
local -r gpgDir="$tmpDir/gpg" | ||
|
||
setupTmpDir "$tmpDir" | ||
gpg --homedir "$gpgDir" --import "$signingKey" | ||
importGpgViaClipboard "$tmpDir" 6B82BB2BECEE0447 | ||
printf "key 945FE615904E5C85\nexpire\n1y\nsave\n" | | ||
gpg --homedir "$gpgDir" --batch --command-fd 0 --edit-key 6B82BB2BECEE0447 | ||
gpg --homedir "$gpgDir" --export --armor 6B82BB2BECEE0447 >"$signingKey" | ||
rm -r "$tmpDir" | ||
|
||
setupTmpDir "$tmpDir" | ||
importGpgViaClipboard "$tmpDir" 4B78012139378220 | ||
gpg --homedir "$gpgDir" --detach-sign -u 4B78012139378220 --output "$actualSig" "$signingKey" | ||
rm -r "$tmpDir" | ||
|
||
"$scriptsDir/before-pr.sh" | ||
|
||
logSuccess "expiration date for %s updated and signed (%s) and copied to the .gt directory" "$signingKey" "$actualSig" | ||
|
||
} | ||
|
||
${__SOURCED__:+return} | ||
extendExpirationSigningKey "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.