Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit 617e52a

Browse files
committed
Attempt to restore signing behavior for releases
1 parent 514b1a8 commit 617e52a

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

.goreleaser.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ brews:
4444
homepage: "https://redskyops.dev/"
4545
description: Kubernetes Exploration
4646
signs:
47-
- artifacts: checksum
4847
- id: notarization
48+
# This is going to produce empty ".sig" files that will need to be manually removed from the GitHub release
4949
cmd: hack/notarize.sh
50-
args: ["${artifact}"]
50+
args: ["${artifact}", "${signature}"]
5151
artifacts: all

hack/notarize.sh

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

98
FILE="${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")"
1937
WORKDIR="$(mktemp -d)"
2038
function removeWorkdir()
2139
{
2240
rm -rf "$WORKDIR"
2341
}
2442
trap 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`)
2745
mkdir "$WORKDIR/$NAME"
2846
tar -xf "$FILE" -C "$WORKDIR/$NAME"
2947
ditto -c -k "$WORKDIR/$NAME" "$WORKDIR/$NAME.zip"
@@ -40,8 +58,8 @@ doNotarizeInfo() {
4058

4159
# Submit the Zip file for notarization, retain the request identifier
4260
REQUEST_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
4765
SLEEP_TIME=10

0 commit comments

Comments
 (0)