Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

v4.4.1

tilakpatel22c388a881628c
diff --git a/.github/scripts/macos_codesign.sh b/.github/scripts/macos_codesign.sh
new file mode 100644
index 000000000..865946c28
--- /dev/null
+++ b/.github/scripts/macos_codesign.sh
@@ -0,0 +1,117 @@
+#!/usr/bin/env bash
+# macos_codesign.sh — shared signing helpers for the macOS release job.
+#
+# SOURCE this file, don't execute it:
+# source "$GITHUB_WORKSPACE/.github/scripts/macos_codesign.sh"
+#
+# WHY THIS EXISTS
+#
+# Every `codesign --sign` call in release.yml runs under `set -e` and is
+# unguarded, so a single failure ends the release job — roughly 35 minutes in,
+# after the build, the self-tests, the bundle staging and macdeployqt have all
+# succeeded. Two failure modes account for essentially all of those:
+#
+# 1. Apple's timestamp service (timestamp.apple.com) rate-limits or 5xx's.
+# `--timestamp` is mandatory for notarization, and codesign treats a TSA
+# hiccup as a hard error. It is transient and retryable, but nothing
+# retried it, so the job died and the release never published.
+#
+# 2. The Developer ID identity is not actually usable — expired cert,
+# rotated MACOS_SIGNING_IDENTITY secret, a p12 that imported without its
+# private key. The import step LOOKED fine because
+# `security find-identity -v -p codesigning` prints "0 valid identities
+# found" and still EXITS 0, so the first real failure surfaced several
+# steps later as an opaque "Process completed with exit code 1".
+#
+# Both are addressed here: assert_signing_identity turns (2) into a named
+# error at import time, and codesign_retry absorbs (1).
+
+# assert_signing_identity <keychain-path> <signing-identity>
+#
+# Fails loudly when the keychain holds no usable codesigning identity, or when
+# the identity the workflow is about to sign with isn't among them. Never
+# echoes the identity itself (it is a repository secret; Actions masks it, but
+# there is no reason to push it through an extra pipe).
+assert_signing_identity() {
+ local keychain="$1"
+ local identity="$2"
+ local listing count
+
+ if [ -z "${identity}" ]; then
+ echo "::error::MACOS_SIGNING_IDENTITY is empty. Set the repository secret to the full" \
+ "certificate name, e.g. 'Developer ID Application: Your Org (TEAMID)', or its SHA-1 hash." >&2
+ return 1
+ fi
+
+ listing="$(security find-identity -v -p codesigning "${keychain}" 2>&1 || true)"
+ echo "${listing}"
+
+ # `find-identity -v` lists only valid identities — an expired or untrusted
+ # certificate simply doesn't appear, so a zero count covers expiry too.
+ count="$(printf '%s\n' "${listing}" | grep -cE '^[[:space:]]*[0-9]+\)' || true)"
+ if [ "${count}" -eq 0 ]; then
+ echo "::error::No valid codesigning identity in the build keychain. The Developer ID" \
+ "certificate in MACOS_CERT_P12_BASE64 is missing, expired, untrusted, or was exported" \
+ "without its private key. Re-export it from Keychain Access as a .p12 INCLUDING the" \
+ "private key, base64 it, and update MACOS_CERT_P12_BASE64 + MACOS_CERT_PASSWORD." >&2
+ return 1
+ fi
+
+ if ! printf '%s\n' "${listing}" | grep -qF -- "${identity}"; then
+ echo "::error::MACOS_SIGNING_IDENTITY does not match any identity in the keychain" \
+ "(${count} valid identit(y/ies) present — see the list above). The secret and the" \
+ "certificate have drifted apart; copy the exact name from the listing." >&2
+ return 1
+ fi
+
+ echo "Signing identity resolved (${count} valid identit(y/ies) in keychain)."
+}
+
+# codesign_retry <codesign args...>
+#
+# codesign with bounded retries and exponential backoff. Retries every failure
+# rather than pattern-matching the timestamp error: codesign's wording varies
+# across Xcode versions ("The timestamp service is not available", "Timestamp
+# service did not respond", plain -1 from cssm), and a genuinely broken input
+# just fails five times a few seconds apart and then reports normally. The
+# final attempt's stderr is printed verbatim so the log still names the file
+# and the real reason.
+codesign_retry() {
+ local attempt=1
+ local max="${CODESIGN_MAX_ATTEMPTS:-5}"
+ local delay="${CODESIGN_RETRY_DELAY:-5}"
+ local out rc target
+
+ # Last positional arg = the path being signed, for the error message.
+ # Kept in a variable rather than read as ${*: -1} because the runners'
+ # /bin/bash is 3.2 and this must not depend on newer expansions.
+ for target in "$@"; do :; done
+
+ while :; do
+ # `x=$(cmd) && rc=0 || rc=$?` instead of toggling `set +e`/`set -e`:
+ # `set` is process-global, not function-local (and `local -` needs
+ # bash 4.4, newer than the runners' 3.2), so toggling it here would
+ # leak errexit back to a caller that had deliberately disabled it.
+ out="$(codesign "$@" 2>&1)" && rc=0 || rc=$?
+
+ if [ "${rc}" -eq 0 ]; then
+ if [ -n "${out}" ]; then
+ printf '%s\n' "${out}"
+ fi
+ return 0
+ fi
+
+ if [ "${attempt}" -ge "${max}" ]; then
+ printf '%s\n' "${out}" >&2
+ # stderr, not stdout: two call sites send this command's stdout to
+ # /dev/null, and an annotation nobody sees is worse than none.
+ echo "::error::codesign failed after ${max} attempts (last exit ${rc}). Target: ${target}" >&2
+ return "${rc}"
+ fi
+
+ echo "codesign attempt ${attempt}/${max} failed (exit ${rc}), retrying in ${delay}s: ${out}" >&2
+ sleep "${delay}"
+ attempt=$((attempt + 1))
+ delay=$((delay * 2))
+ done
+}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 44e41b726..a9ea7fcfe 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1817,6 +1817,7 @@ jobs:
env:
P12_BASE64: ${{ secrets.MACOS_CERT_P12_BASE64 }}
P12_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }}
+ SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
run: |
set -euo pipefail
KEYCHAIN_PATH="$RUNNER_TEMP/build.keychain-db"
@@ -1828,9 +1829,16 @@ jobs:
security import "$P12_PATH" -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
security list-keychains -d user -s "$KEYCHAIN_PATH" $(security list-keychains -d user | sed 's/"//g')
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$P12_PASSWORD" "$KEYCHAIN_PATH" >/dev/null
- security find-identity -v -p codesigning "$KEYCHAIN_PATH"
rm -f "$P12_PATH"
+ # `security find-identity` EXITS 0 while printing "0 valid identities
+ # found", so calling it bare proved nothing: an expired certificate or
+ # a rotated MACOS_SIGNING_IDENTITY sailed through this step and died
+ # ~35 minutes later inside the codesign step as an opaque
+ # "Process completed with exit code 1". Assert instead.
+ source "$GITHUB_WORKSPACE/.github/scripts/macos_codesign.sh"
+ assert_signing_identity "$KEYCHAIN_PATH" "$SIGNING_IDENTITY"
+
# ── Deep re-sign the entire bundle with Developer ID ─────────────────
# macdeployqt's nested-framework signing is unreliable, so we strip
# every existing signature and re-sign the bundle leaves-to-root with
@@ -1914,6 +1922,14 @@ jobs:
SIGN_FLAGS=(--force --options runtime --timestamp --sign "$SIGNING_IDENTITY")
+ # codesign_retry: `--timestamp` contacts Apple's TSA on EVERY call,
+ # and this step makes hundreds of them (one per Mach-O). A single
+ # rate-limit or 5xx from timestamp.apple.com is a hard codesign
+ # error, and under `set -e` that ends the release job — after the
+ # build, self-tests, staging and macdeployqt have all passed. Retry
+ # with backoff instead of throwing ~35 minutes of work away.
+ source "$GITHUB_WORKSPACE/.github/scripts/macos_codesign.sh"
+
# ── Enumerate every Mach-O via `file -h`, not by filename ────────
# Previously we filtered on `*.dylib | *.so | -perm +111`. That
# misses three real-world cases:
@@ -1961,7 +1977,7 @@ jobs:
echo "Signing every Mach-O with hardened runtime + timestamp..."
while IFS= read -r f; do
- codesign "${SIGN_FLAGS[@]}" "$f" >/dev/null
+ codesign_retry "${SIGN_FLAGS[@]}" "$f" >/dev/null
done < "${MACHO_LIST}"
echo "Signing nested frameworks and .app bundles (deepest-first)..."
@@ -1971,14 +1987,14 @@ jobs:
# framework is signed before the top-level .app below.
BUNDLE_COUNT=0
while IFS= read -r d; do
- codesign "${SIGN_FLAGS[@]}" "$d" >/dev/null
+ codesign_retry "${SIGN_FLAGS[@]}" "$d" >/dev/null
BUNDLE_COUNT=$((BUNDLE_COUNT + 1))
done < <(find "${APP_BUNDLE}/Contents" -mindepth 1 -depth -type d \
\( -name "*.framework" -o -name "*.app" \) 2>/dev/null)
echo " signed ${BUNDLE_COUNT} nested bundles"
echo "Signing top-level bundle with entitlements..."
- codesign --force --options runtime --timestamp \
+ codesign_retry --force --options runtime --timestamp \
--entitlements "$ENT" \
--sign "$SIGNING_IDENTITY" \
"${APP_BUNDLE}"
@@ -2262,12 +2278,18 @@ jobs:
exit 0
fi
+ source "$GITHUB_WORKSPACE/.github/scripts/macos_codesign.sh"
+
# Sign the installer app's own Mach-Os leaf-first (the payload is an
# embedded archive that is already signed+notarized+stapled).
+ # Retried like everywhere else: the trailing `|| true` keeps a leaf
+ # failure non-fatal, but without the retry a transient TSA error
+ # left an unsigned Mach-O behind that the notary rejected minutes
+ # later — a silent skip turning into a confusing downstream failure.
while IFS= read -r m; do
- codesign --force --options runtime --timestamp --sign "$SIGNING_IDENTITY" "$m" || true
+ codesign_retry --force --options runtime --timestamp --sign "$SIGNING_IDENTITY" "$m" || true
done < <(find "${WIZ_APP}" -type f \( -perm -u+x -o -name "*.dylib" \) 2>/dev/null)
- codesign --force --options runtime --timestamp --sign "$SIGNING_IDENTITY" "${WIZ_APP}"
+ codesign_retry --force --options runtime --timestamp --sign "$SIGNING_IDENTITY" "${WIZ_APP}"
# Notarize a zip of the installer app, then staple. (For production,
# adopt the submit/poll/staple loop used by the DMG step — --wait has
@@ -2335,7 +2357,8 @@ jobs:
set -euo pipefail
DMG=$(ls build/FinceptTerminal-*-macos-arm64-setup.dmg | head -1)
echo "Signing DMG: ${DMG}"
- codesign --force --sign "$SIGNING_IDENTITY" --timestamp "$DMG"
+ source "$GITHUB_WORKSPACE/.github/scripts/macos_codesign.sh"
+ codesign_retry --force --sign "$SIGNING_IDENTITY" --timestamp "$DMG"
# Same submit-then-poll pattern as the .app step: --wait has no
# retry on transient network errors (NSURLErrorDomain -1009 from