#!/bin/bash set -euo pipefail cd "$(dirname "$0")" if [ "$#" -ne 1 ]; then echo "usage: $0 e.g. ./release.sh 0.1.0" >&2 exit 1 fi VERSION="$1" # Notarization credentials. Configure once, e.g. in ~/.zshrc: # export SIMPLETOPBAR_NOTARY_ASC_PROVIDER="" # export SIMPLETOPBAR_NOTARY_API_KEY_PATH="$HOME/.config/simpletopbar/AuthKey_XXXX.p8" # export SIMPLETOPBAR_NOTARY_API_KEY_ID="" # export SIMPLETOPBAR_NOTARY_API_ISSUER="" # If these are unset (or SIMPLETOPBAR_SKIP_NOTARY=1), release.sh builds, zips, # and stops there — the zip is signed but NOT notarized. ./build-app.sh "$VERSION" mkdir -p dist rm -f dist/SimpleTopBar.zip ditto -c -k --keepParent SimpleTopBar.app dist/SimpleTopBar.zip if [ -n "${SIMPLETOPBAR_SKIP_NOTARY:-}" ]; then echo echo "Skipping notarization (SIMPLETOPBAR_SKIP_NOTARY set)." shasum -a 256 dist/SimpleTopBar.zip exit 0 fi REQUIRED_VARS="SIMPLETOPBAR_NOTARY_ASC_PROVIDER SIMPLETOPBAR_NOTARY_API_KEY_PATH SIMPLETOPBAR_NOTARY_API_KEY_ID SIMPLETOPBAR_NOTARY_API_ISSUER" MISSING="" for v in $REQUIRED_VARS; do if [ -z "${!v:-}" ]; then MISSING="$MISSING $v" fi done if [ -n "$MISSING" ]; then echo "Notarization skipped — missing env var(s):$MISSING (see header comments)." >&2 shasum -a 256 dist/SimpleTopBar.zip exit 0 fi if ! command -v xcrun >/dev/null 2>&1 || ! xcrun --find notarytool >/dev/null 2>&1; then echo "Notarization skipped — xcrun notarytool not found (requires Xcode 13+)." >&2 shasum -a 256 dist/SimpleTopBar.zip exit 0 fi echo "Submitting to Apple for notarization (first run can take minutes)..." xcrun notarytool submit dist/SimpleTopBar.zip \ --key "$SIMPLETOPBAR_NOTARY_API_KEY_PATH" \ --key-id "$SIMPLETOPBAR_NOTARY_API_KEY_ID" \ --issuer "$SIMPLETOPBAR_NOTARY_API_ISSUER" \ --wait \ --output-format json > notary-result.json STATUS=$(jq -r '.status' notary-result.json 2>/dev/null || echo "unknown") if [ "$STATUS" != "Accepted" ]; then echo "Notarization failed with status: $STATUS" >&2 cat notary-result.json >&2 || true rm -f notary-result.json exit 1 fi rm -f notary-result.json echo "Notarization accepted — stapling ticket onto the app..." xcrun stapler staple SimpleTopBar.app xcrun stapler validate SimpleTopBar.app rm -f dist/SimpleTopBar.zip ditto -c -k --keepParent SimpleTopBar.app dist/SimpleTopBar.zip echo echo "Done — notarized." shasum -a 256 dist/SimpleTopBar.zip