Skip to content

Commit 31d3254

Browse files
committed
contrib: Sign and notarize all MacOS binaries
Signapple has been updated to sign individual binaries, and notarize app bundles and binaries. When codesigning, all individual binaries will be codesigned, and both the app bundle and individual binaries will be notarized.
1 parent 710d5b5 commit 31d3254

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

contrib/macdeploy/detached-sig-create.sh

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,57 @@
66
export LC_ALL=C
77
set -e
88

9-
ROOTDIR=dist
10-
BUNDLE="${ROOTDIR}/Bitcoin-Qt.app"
11-
BINARY="${BUNDLE}/Contents/MacOS/Bitcoin-Qt"
129
SIGNAPPLE=signapple
1310
TEMPDIR=sign.temp
14-
ARCH=$(${SIGNAPPLE} info ${BINARY} | head -n 1 | cut -d " " -f 1)
11+
12+
BUNDLE_ROOT=dist
13+
BUNDLE_NAME="Bitcoin-Qt.app"
14+
UNSIGNED_BUNDLE="${BUNDLE_ROOT}/${BUNDLE_NAME}"
15+
UNSIGNED_BINARY="${UNSIGNED_BUNDLE}/Contents/MacOS/Bitcoin-Qt"
16+
17+
ARCH=$(${SIGNAPPLE} info ${UNSIGNED_BINARY} | head -n 1 | cut -d " " -f 1)
18+
19+
OUTDIR="osx/${ARCH}-apple-darwin"
20+
OUTROOT="${TEMPDIR}/${OUTDIR}"
21+
1522
OUT="signature-osx-${ARCH}.tar.gz"
16-
OUTROOT=osx/dist
1723

18-
if [ -z "$1" ]; then
19-
echo "usage: $0 <signapple args>"
20-
echo "example: $0 <path to key>"
24+
if [ "$#" -ne 3 ]; then
25+
echo "usage: $0 <path to key> <path to app store connect key> <apple developer team uuid>"
2126
exit 1
2227
fi
2328

2429
rm -rf ${TEMPDIR}
2530
mkdir -p ${TEMPDIR}
2631

27-
${SIGNAPPLE} sign -f --detach "${TEMPDIR}/${OUTROOT}" "$@" "${BUNDLE}" --hardened-runtime
32+
stty -echo
33+
printf "Enter the passphrase for %s: " "$1"
34+
read cs_key_pass
35+
printf "\n"
36+
printf "Enter the passphrase for %s: " "$2"
37+
read api_key_pass
38+
printf "\n"
39+
stty echo
40+
41+
# Sign and notarize app bundle
42+
${SIGNAPPLE} sign -f --hardened-runtime --detach "${OUTROOT}/${BUNDLE_ROOT}" --passphrase "${cs_key_pass}" "$1" "${UNSIGNED_BUNDLE}"
43+
${SIGNAPPLE} apply "${UNSIGNED_BUNDLE}" "${OUTROOT}/${BUNDLE_ROOT}/${BUNDLE_NAME}"
44+
${SIGNAPPLE} notarize --detach "${OUTROOT}/${BUNDLE_ROOT}" --passphrase "${api_key_pass}" "$2" "$3" "${UNSIGNED_BUNDLE}"
45+
46+
# Sign each binary
47+
find . -maxdepth 3 -wholename "*/bin/*" -type f -exec realpath --relative-to=. {} \; | while read -r bin
48+
do
49+
bin_dir=$(dirname "${bin}")
50+
bin_name=$(basename "${bin}")
51+
${SIGNAPPLE} sign -f --hardened-runtime --detach "${OUTROOT}/${bin_dir}" --passphrase "${cs_key_pass}" "$1" "${bin}"
52+
${SIGNAPPLE} apply "${bin}" "${OUTROOT}/${bin_dir}/${bin_name}.${ARCH}sign"
53+
done
54+
55+
# Notarize the binaries
56+
# Binaries cannot have stapled notarizations so this does not actually generate any output
57+
binaries_dir=$(dirname "$(find . -maxdepth 2 -wholename '*/bin' -type d -exec realpath --relative-to=. {} \;)")
58+
${SIGNAPPLE} notarize --passphrase "${api_key_pass}" "$2" "$3" "${binaries_dir}"
2859

29-
tar -C "${TEMPDIR}" -czf "${OUT}" .
60+
tar -C "${TEMPDIR}" -czf "${OUT}" "${OUTDIR}"
3061
rm -rf "${TEMPDIR}"
3162
echo "Created ${OUT}"

doc/release-process.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Then open a Pull Request to the [guix.sigs repository](https://github.com/bitcoi
165165
In the `guix-build-${VERSION}/output/x86_64-apple-darwin` and `guix-build-${VERSION}/output/arm64-apple-darwin` directories:
166166

167167
tar xf bitcoin-${VERSION}-${ARCH}-apple-darwin-codesigning.tar.gz
168-
./detached-sig-create.sh /path/to/codesign.p12
168+
./detached-sig-create.sh /path/to/codesign.p12 /path/to/AuthKey_foo.p8 uuid
169169
Enter the keychain password and authorize the signature
170170
signature-osx.tar.gz will be created
171171

0 commit comments

Comments
 (0)