Skip to content

Commit 43ca63b

Browse files
committedApr 7, 2025
Import public GPG key
Signed-off-by: marko-bekhta <[email protected]>
1 parent 7429181 commit 43ca63b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎release.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ function gpg_import() {
145145
keyId=$(gpg "${@}" --batch --import "$privateKeyPath" 2>&1 | tee >(cat 1>&2) | grep 'key.*: secret key imported' | sed -E 's/.*key ([^:]+):.*/\1/')
146146
# output the fingerprint of the imported key
147147
gpg "${@}" --list-secret-keys --with-colon "$keyId" | sed -E '2!d;s/.*:([^:]+):$/\1/'
148-
export JRELEASER_GPG_KEYNAME=$keyId
149148
}
150149

151150
function gpg_delete() {
@@ -154,6 +153,12 @@ function gpg_delete() {
154153
gpg "${@}" --batch --yes --delete-secret-keys "$fingerprint"
155154
}
156155

156+
function gpg_delete_public() {
157+
local fingerprint="$1"
158+
shift
159+
gpg "${@}" --batch --yes --delete-keys "$fingerprint"
160+
}
161+
157162
#--------------------------------------------
158163
# Cleanup on exit
159164

@@ -162,6 +167,10 @@ function cleanup() {
162167
echo "Deleting imported GPG private key..."
163168
gpg_delete "$IMPORTED_KEY" || true
164169
fi
170+
if [ -n "$IMPORTED_PUBLIC_KEY" ]; then
171+
echo "Deleting imported GPG public key..."
172+
gpg_delete_public "$IMPORTED_PUBLIC_KEY" || true
173+
fi
165174
if [ -d "$RELEASE_GPG_HOMEDIR" ]; then
166175
echo "Cleaning up GPG homedir..."
167176
rm -rf "$RELEASE_GPG_HOMEDIR" || true
@@ -186,6 +195,7 @@ if [ -z "$IMPORTED_KEY" ]; then
186195
echo "Failed to import GPG key"
187196
exit 1
188197
fi
198+
IMPORTED_PUBLIC_KEY="$(gpg_import "$RELEASE_GPG_PUBLIC_KEY_PATH")"
189199

190200
if [ "$PUSH_CHANGES" != "true" ]; then
191201
ADDITIONAL_OPTIONS="-d"

0 commit comments

Comments
 (0)
Please sign in to comment.