File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/bash
22set -euo pipefail
33
4- if [[ " ${1:- } " == " " ]]; then
5- echo " Usage: sign.sh FILE" >&2
4+ if [[ " ${2:- } " == " " ]]; then
5+ echo " Usage: sign.sh ARTIFACTTYPE FILE [FILE...]" >&2
6+ echo " " >&2
7+ echo " Creates detached signature as FILE.sig." >&2
68 exit 1
79fi
810
911
1012tmpdir=$( mktemp -d)
1113trap " shred $tmpdir /* && rm -rf $tmpdir " EXIT
1214
13- SECRET=CDK/SigningKey
15+ SECRET=CDK/$1 / SigningKey
1416
1517# Use secrets manager to obtain the key and passphrase into a JSON file
16- echo " Retrieving key..." >&2
18+ echo " Retrieving key $SECRET ..." >&2
1719aws --region us-east-1 secretsmanager get-secret-value --secret-id " $SECRET " --output text --query SecretString > $tmpdir /secret.txt
1820passphrase=$( python -c " import json; print(json.load(file('$tmpdir /secret.txt'))['Passphrase'])" )
1921
2022echo " Importing key..." >&2
2123gpg --homedir $tmpdir --import <( python -c " import json; print(json.load(file('$tmpdir /secret.txt'))['PrivateKey'])" )
2224
23- echo " Signing $1 ..." >&2
24- echo $passphrase | gpg \
25- --homedir $tmpdir \
26- --local-user aws-cdk@amazon.com \
27- --batch --yes \
28- --passphrase-fd 0 \
29- --output $1 .sig \
30- --detach-sign $1
25+ while [[ " ${2:- } " != " " ]]; do
26+ echo " Signing $2 ..." >&2
27+ echo $passphrase | gpg \
28+ --homedir $tmpdir \
29+ --local-user aws-cdk@amazon.com \
30+ --batch --yes \
31+ --passphrase-fd 0 \
32+ --output $2 .sig \
33+ --detach-sign $2
34+ shift
35+ done
3136
3237echo " Done!" >&2
You can’t perform that action at this time.
0 commit comments