@@ -3,27 +3,45 @@ set -eu
33
44# Notarization
55# ============
6- # This script uploads binaries to Apple to get the code signatures trusted. Like the codesign script,
7- # it only makes sense to do this conditionally.
6+ # This script combines two painful concepts. Apple Notarization and GoReleaser Signing.
87
98FILE=" ${1:? missing file argument} "
10- NAME=" $( basename " $FILE " " .tar.gz" ) "
11- [ " $NAME " == " redskyctl-darwin-amd64" ] || { echo >&2 " skipping notarization for file=[$1 ]" ; exit ; }
12- command -v ditto > /dev/null 2>&1 || { echo >&2 " skipping notarization, ditto not present" ; exit ; }
13- command -v xcrun > /dev/null 2>&1 || { echo >&2 " skipping notarization, xcrun not present" ; exit ; }
14- command -v jq > /dev/null 2>&1 || { echo >&2 " skipping notarization, jq not present" ; exit ; }
15- [ -n " ${AC_USERNAME:- } " ] || { echo >&2 " skipping notarization, no credentials" ; exit ; }
16- [ -n " ${AC_PASSWORD:- } " ] || { echo >&2 " skipping notarization, no credentials" ; exit ; }
9+ OUTPUT=" ${2:? missing output argument} "
10+
11+ # This script MUST produce an output file or fail.
12+ case " $( basename " $FILE " ) " in
13+ " redskyctl-darwin-amd64.tar.gz" )
14+ # Do nothing, just fall through to the notarization bit (the "signature file" will contain the request UUID)
15+ ;;
16+ " checksums.txt" )
17+ # Sign the checksums using GPG (mimic the default GoReleaser behavior)
18+ gpg --output " ${OUTPUT} " --detach-sign " ${FILE} "
19+ exit
20+ ;;
21+ * )
22+ # Just create an empty file to upload to the release
23+ touch " ${OUTPUT} "
24+ exit
25+ ;;
26+ esac
27+
28+ # Verify we can actually do something
29+ command -v ditto > /dev/null 2>&1 || { echo >&2 " notarization failed, ditto not present" ; exit 1; }
30+ command -v xcrun > /dev/null 2>&1 || { echo >&2 " notarization failed, xcrun not present" ; exit 1; }
31+ command -v jq > /dev/null 2>&1 || { echo >&2 " notarization failed, jq not present" ; exit 1; }
32+ [ -n " ${AC_USERNAME:- } " ] || { echo >&2 " notarization failed, no credentials" ; exit 1; }
33+ [ -n " ${AC_PASSWORD:- } " ] || { echo >&2 " notarization failed, no credentials" ; exit 1; }
1734
1835# Create a temporary location to perform notarization
36+ NAME=" $( basename " $FILE " " .tar.gz" ) "
1937WORKDIR=" $( mktemp -d) "
2038function removeWorkdir()
2139{
2240 rm -rf " $WORKDIR "
2341}
2442trap removeWorkdir EXIT
2543
26- # Re-archive as a Zip
44+ # Re-archive as a Zip (we cannot just do code signing here and re-pack the tarball without also re-computing `checksums.txt`)
2745mkdir " $WORKDIR /$NAME "
2846tar -xf " $FILE " -C " $WORKDIR /$NAME "
2947ditto -c -k " $WORKDIR /$NAME " " $WORKDIR /$NAME .zip"
@@ -40,8 +58,8 @@ doNotarizeInfo() {
4058
4159# Submit the Zip file for notarization, retain the request identifier
4260REQUEST_UUID=" $( doNotarizeApp " $WORKDIR /$NAME .zip" | jq -r ' .RequestUUID' ) "
43- [ " ${REQUEST_UUID:- null} " != " null" ] || { echo >&2 " notarization request was not submitted" ; exit 1; }
44- echo >&2 " notarization request submitted id= $REQUEST_UUID "
61+ [ " ${REQUEST_UUID:- null} " != " null" ] || { echo >&2 " notarization failed, request was not submitted" ; exit 1; }
62+ echo " ${REQUEST_UUID} " >> " ${OUTPUT} "
4563
4664# Wait for a result
4765SLEEP_TIME=10
0 commit comments