Skip to content

Commit fd8c26a

Browse files
committed
contrib/sign-release.sh: allow secret via stdin
Providing the secret via stdin has the advantage of not needing to store the secret in cleartext somewhere on the filesystem. Instead it can be decrypted on the fly and provided via stdin. A few examples: gpg -d singkey.gpg | contrib/sign-release.sh v2.2.1 age -d -i ~/.ssh/id_ed25519 signkey.age | ./contrib/sign-release.sh v2.2.1 gopass show signkey | ./contrib/sign-release.sh v2.2.1 keepassxc-cli show -k ~/db.key ~/db.kdbx signkey -a Password | contrib/sign-release.sh v2.2.1
1 parent 3656827 commit fd8c26a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

contrib/functions-sign.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function create_signature() {
4040
split_manifest "$manifest" "$upper" "$lower"
4141

4242
# Sign upper part of manifest
43-
ecdsasign "$upper" < "$secret"
43+
ecdsasign "$upper" <<< "$secret"
4444

4545
# Remove temporary files
4646
rm -f "$upper" "$lower"

contrib/sign-release.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
77
source "${SCRIPT_DIR}/functions-sign.sh"
88

99
function usage() {
10-
echo "Usage: $0 <release-version> <private-key-path>"
11-
echo "Example: $0 2.0.0 /path/to/private-key.ecdsakey"
10+
echo "Usage: $0 <release-version> [<private-key-path>]"
11+
echo "Example: $0 v2.0.0 /path/to/private-key.ecdsakey"
12+
echo ""
13+
echo "The script expects the private key via stdin if no private-key-path is provided."
1214
exit 1
1315
}
1416

@@ -26,9 +28,12 @@ GITHUB_REPOSITORY_URL="${GITHUB_REPOSITORY_URL:-$DEFAULT_GITHUB_REPOSITORY_URL}"
2628

2729
RELEASE_VERSION="${1:-}"
2830
PRIVATE_KEY_PATH="${2:-}"
31+
PRIVATE_KEY=""
2932

3033
[ -z "$RELEASE_VERSION" ] && usage
31-
[ -z "$PRIVATE_KEY_PATH" ] && usage
34+
[ -n "$PRIVATE_KEY_PATH" ] && PRIVATE_KEY="$(cat "$PRIVATE_KEY_PATH")"
35+
[ -z "$PRIVATE_KEY" ] && [ ! -t 0 ] && PRIVATE_KEY=$(cat)
36+
[ -z "$PRIVATE_KEY" ] && usage
3237

3338
# Create Temporary working directory
3439
TEMP_DIR="$(mktemp -d)"
@@ -61,7 +66,7 @@ for manifest_path in "${TEMP_DIR}/"*.manifest; do
6166

6267
# Get Signature
6368
echo "-- Signature for $manifest_branch_name --"
64-
create_signature "$manifest_path" "$PRIVATE_KEY_PATH"
69+
create_signature "$manifest_path" "$PRIVATE_KEY"
6570
done
6671

6772
# Remove Temporary working directory

0 commit comments

Comments
 (0)