@@ -22,7 +22,7 @@ build-dist options:
22
22
--no-windows do not build for Windows
23
23
--no-unix do not build for UNIX
24
24
--no-compress do not create zip/tar
25
-
25
+ --sign Use GPG to sign and verify packages
26
26
--dist-clean rm -rf the DIST_ROOT w/out prompts
27
27
__EOF__
28
28
@@ -56,6 +56,38 @@ main() {
56
56
$SKIP_ZIP || make_zip
57
57
}
58
58
59
+ # perform sign and verify
60
+ sign_verify () {
61
+ # make sure gpg exists
62
+ gpgbin=$( which gpg)
63
+ if [ $? -ne 0 ];
64
+ then
65
+ echo " No gpg binary found in path."
66
+ return 1
67
+ fi
68
+
69
+ # $1 is our filename, it should exist
70
+ if [ -e " $1 " ]; then
71
+ sign_out=$( gpg -qb " $1 " 2>&1 )
72
+ # if signing worked, let's verify it
73
+ if [ $? -eq 0 ];
74
+ then
75
+ verify_out=$( gpg -q --verify " $1 .sig" 2>&1 )
76
+ # if it's verified, return true
77
+ if [ $? -eq 0 ];
78
+ then
79
+ note " Sign and verify successful!"
80
+ return 0
81
+ fi
82
+ fi
83
+ # signing failed
84
+ note " Signing failed."
85
+ return 1
86
+ else
87
+ note " The file $1 doesn't exist or isn't readable."
88
+ fi
89
+ }
90
+
59
91
# prep DIST_ROOT
60
92
dist_clean () {
61
93
if [ -e " $DIST_ROOT " ]; then
@@ -142,20 +174,23 @@ stage_win() {
142
174
make_tar () {
143
175
(cd " $DIST_ROOT /unix/" ; tar -czf " ../${PV} .tgz" " $PV " ) || die " tar failed"
144
176
note " tarball created at: $DIST_ROOT /${PV} .tgz"
177
+ $SKIP_SIGN || sign_verify " $DIST_ROOT /${PV} .tgz"
145
178
}
146
179
147
180
make_zip () {
148
181
for win in win32 win64;
149
182
do
150
183
(cd " $DIST_ROOT /$win /" ; zip -qr " ../${PV} -$win .zip" " $PV " ) || die " zip failed"
151
184
note " zip file created at: $DIST_ROOT /${PV} -$win .zip"
185
+ $SKIP_SIGN || sign_verify " $DIST_ROOT /${PV} -$win .zip"
152
186
done
153
187
}
154
188
155
189
SKIP_WIN=false
156
190
SKIP_UNIX=false
157
191
SKIP_ZIP=false
158
192
SKIP_TAR=false
193
+ SKIP_SIGN=true
159
194
# parse CLI options:
160
195
while [ -n " $1 " ]
161
196
do
180
215
# shellcheck disable=SC2034
181
216
BIN_DEST=" $val "
182
217
;;
218
+ --sign)
219
+ SKIP_SIGN=false
220
+ ;;
183
221
--dist-clean)
184
222
DISTCLEAN=1
185
223
;;
0 commit comments