78 lines
2.4 KiB
Bash
Executable File
78 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "usage: $0 <version> 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="<TeamID>"
|
|
# export SIMPLETOPBAR_NOTARY_API_KEY_PATH="$HOME/.config/simpletopbar/AuthKey_XXXX.p8"
|
|
# export SIMPLETOPBAR_NOTARY_API_KEY_ID="<KeyID>"
|
|
# export SIMPLETOPBAR_NOTARY_API_ISSUER="<IssuerID>"
|
|
# 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
|