Skip to content

Screenshots, hung out to dry. A tiny native macOS app that hangs every screenshot on a line at the top of your screen.

Swift

Sign with Developer ID and the hardened runtime; notarize and staple the disk image

Alejandro Bujándb99d2693687
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
index 3241995..04d2c62 100755
--- a/scripts/build-app.sh
+++ b/scripts/build-app.sh
@@ -70,6 +70,15 @@ cat > "$APP/Contents/Info.plist" <<PLIST
</plist>
PLIST
-# Ad-hoc signature so it runs locally. Releases should use a Developer ID.
-codesign --force --deep --sign - "$APP" >/dev/null
+# Sign with a Developer ID when one is in the keychain (or SIGN_IDENTITY is
+# set), with the hardened runtime and a secure timestamp that notarization
+# requires. Without one, sign ad hoc so the app still runs locally.
+IDENTITY="${SIGN_IDENTITY:-$(security find-identity -v -p codesigning 2>/dev/null | awk -F'"' '/Developer ID Application/{print $2; exit}')}"
+if [ -n "$IDENTITY" ]; then
+ codesign --force --options runtime --timestamp --sign "$IDENTITY" "$APP"
+ echo "Signed with $IDENTITY"
+else
+ codesign --force --deep --sign - "$APP" >/dev/null
+ echo "Signed ad hoc (no Developer ID found)"
+fi
echo "Built $APP"
diff --git a/scripts/make-dmg.sh b/scripts/make-dmg.sh
index 5fc72d3..a963a69 100755
--- a/scripts/make-dmg.sh
+++ b/scripts/make-dmg.sh
@@ -66,6 +66,24 @@ hdiutil convert -quiet "$RW" -format UDZO -imagekey zlib-level=9 -o "$DMG"
rm -rf "$WORK"
echo "Built $DMG"
+# Sign the disk image, send it to Apple for notarization and staple the
+# ticket, so it opens without warnings even offline. Needs a Developer ID and
+# notary credentials stored with:
+# xcrun notarytool store-credentials tendedero-notary --apple-id ... --team-id ...
+IDENTITY="${SIGN_IDENTITY:-$(security find-identity -v -p codesigning 2>/dev/null | awk -F'"' '/Developer ID Application/{print $2; exit}')}"
+PROFILE="${NOTARY_PROFILE:-tendedero-notary}"
+if [ -n "$IDENTITY" ]; then
+ codesign --force --timestamp --sign "$IDENTITY" "$DMG"
+ if xcrun notarytool history --keychain-profile "$PROFILE" >/dev/null 2>&1; then
+ echo "Notarizing, this usually takes a few minutes..."
+ xcrun notarytool submit "$DMG" --keychain-profile "$PROFILE" --wait
+ xcrun stapler staple "$DMG"
+ spctl --assess --type open --context context:primary-signature --verbose=2 "$DMG"
+ else
+ echo "No notary credentials in profile $PROFILE: the image is signed but not notarized."
+ fi
+fi
+
# Keep the Homebrew cask in step: new version and the checksum of this image.
# Set TAP_DIR to the tap checkout; nothing is committed or pushed here, so the
# cask never points at a release that is not on GitHub yet.