Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : ORIX Cosmos8# File : Scripts/package.sh9# Description : Builds dist/ORIX-Cosmos-<version>.zip (ditto) and .dmg10# (drag-to-install) from the stapled app, signs the DMG with11# the app's identity and writes SHA-256 checksums.12# Module : Scripts13# Repository : https://git.spboucher.ai/orix-cosmos14# Project Website : https://www.orixlab.dev15# Created : 2026-11-2416# Last Modified : 2026-11-2417#18# Author : Simon-Pierre Boucher19# Position : Professor of Finance20# Institution : Université du Québec en Outaouais (UQO)21# Organization : SP Boucher22# Website : https://spboucher.ai23# Git : https://git.spboucher.ai24#25# Preferred Contact: support@spboucher.ai26# Technical Contact: dev@spboucher.ai27# Security/Admin : admin@spboucher.ai28#29# Copyright (c) 202630# Simon-Pierre Boucher31# All rights reserved where applicable. This file is governed by the32# applicable project license, copyright notices and relevant law.33# Existing third-party rights and notices remain unaffected.34#35# License : None specified (no license file in this repository)36#37# Do not embed credentials, private keys, access tokens,38# certificates or confidential personal information.39#40# =============================================================================41# END OF SP BOUCHER SOURCE HEADER42# =============================================================================4344set -euo pipefail45cd "$(dirname "$0")/.."46source Scripts/release-config.sh47[[ -d "$APP" ]] || { echo "ERROR: $APP not found." >&2; exit 1; }48VERSION="$(app_version)"49DMG="dist/$ARTIFACT_PREFIX-$VERSION.dmg"; ZIP="dist/$ARTIFACT_PREFIX-$VERSION.zip"50IDENTITY="${SIGN_IDENTITY:-$(codesign -dvv "$APP" 2>&1 | sed -n 's/^Authority=\(Developer ID Application: .*\)$/\1/p' | head -1)}"51[[ -n "$IDENTITY" ]] || { echo "ERROR: the app is not signed with a Developer ID identity." >&2; exit 1; }52make_zip() { rm -f "$ZIP"; ditto -c -k --keepParent "$APP" "$ZIP"; echo "built $ZIP"; }53make_dmg() {54 local stage; stage="$(mktemp -d)"55 ditto "$APP" "$stage/$APP_NAME.app"; ln -s /Applications "$stage/Applications"56 rm -f "$DMG"57 hdiutil create -volname "$APP_NAME $VERSION" -srcfolder "$stage" -fs APFS -format ULFO -quiet "$DMG"58 rm -rf "$stage"59 codesign --force --timestamp --sign "$IDENTITY" "$DMG"60 codesign --verify --verbose=2 "$DMG" 2>&1 | tail -1; echo "built and signed $DMG"61}62make_checksums() { ( cd dist && shasum -a 256 "$(basename "$DMG")" "$(basename "$ZIP")" | tee SHA256SUMS.txt ); }63case "${1:-all}" in64 zip) make_zip ;;65 dmg) make_dmg ;;66 checksums) make_checksums ;;67 all) make_zip; make_dmg; make_checksums ;;68 *) echo "usage: $0 zip|dmg|checksums|all" >&2; exit 2 ;;69esac70