-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-app.sh
More file actions
executable file
·131 lines (115 loc) · 5.56 KB
/
Copy pathbuild-app.sh
File metadata and controls
executable file
·131 lines (115 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# Собирает TermJ.app — настоящий macOS-бандл, готовый к запуску и переносу в /Applications.
set -e
cd "$(dirname "$0")"
echo "==> swift build -c release"
swift build -c release
APP="TermJ.app"
BIN=".build/release/TermJ"
echo "==> Собираю $APP"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS"
mkdir -p "$APP/Contents/Resources"
cp "$BIN" "$APP/Contents/MacOS/TermJ"
# Копируем ресурсный бандл SPM (Localizable.strings, InfoPlist.strings).
# SPM кладёт его в .build/<triple>/release/<Package>_<Target>.bundle.
BUNDLE_SRC=$(find .build -type d -name "TermJ_TermJ.bundle" \
-path "*release*" ! -path "*index-build*" 2>/dev/null | head -1)
if [ -n "$BUNDLE_SRC" ]; then
cp -R "$BUNDLE_SRC" "$APP/Contents/Resources/"
echo "==> Скопирован ресурсный бандл: $(basename "$BUNDLE_SRC")"
else
echo "==> ВНИМАНИЕ: ресурсный бандл TermJ_TermJ.bundle не найден!"
fi
# Копируем иконку приложения.
if [ -f "TermJ.icns" ]; then
cp "TermJ.icns" "$APP/Contents/Resources/TermJ.icns"
fi
# Копируем иконку GitHub для меню статус-бара.
if [ -f "github.svg" ]; then
cp "github.svg" "$APP/Contents/Resources/github.svg"
fi
# Копируем визуализатор (milkdrop.html + presets/) для виджета «Пульсация».
if [ -d "MilkDropResources" ]; then
mkdir -p "$APP/Contents/Resources/MilkDrop/presets"
cp "MilkDropResources/milkdrop.html" "$APP/Contents/Resources/MilkDrop/" 2>/dev/null || true
cp "MilkDropResources/presets/"*.js "$APP/Contents/Resources/MilkDrop/presets/" 2>/dev/null || true
fi
# Копируем README и LICENSE в Resources для удобства пользователя.
cp "README.md" "$APP/Contents/Resources/" 2>/dev/null || true
cp "LICENSE" "$APP/Contents/Resources/" 2>/dev/null || true
# Версия из файла VERSION (CFBundleShortVersionString) и номер сборки
# из количества git-коммитов (CFBundleVersion), чтобы сборки различались.
APP_VERSION=$(grep -v '^[[:space:]]*$' VERSION | head -1 | tr -d '[:space:]')
if [ -z "$APP_VERSION" ]; then APP_VERSION="0.0.0"; fi
BUILD_NUMBER=$(git rev-list --count HEAD 2>/dev/null || echo "1")
cat > "$APP/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>TermJ</string>
<key>CFBundleDisplayName</key>
<string>TermJ</string>
<key>CFBundleIdentifier</key>
<string>com.bayanist.termj</string>
<key>CFBundleVersion</key>
<string>$BUILD_NUMBER</string>
<key>CFBundleShortVersionString</key>
<string>$APP_VERSION</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>TermJ</string>
<key>CFBundleIconFile</key>
<string>TermJ</string>
<key>LSMinimumSystemVersion</key>
<string>13.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSScreenCaptureUsageDescription</key>
<string>TermJ needs Screen Recording access to capture system audio for the Pulse widget. No video is recorded.</string>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>ru</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
</dict>
</plist>
PLIST
# Подпись. TCC (разрешение на запись экрана/звука для визуализатора) привязывается
# к подписи, поэтому нужна СТАБИЛЬНАЯ identity, иначе права слетают при пересборке.
# Ищем в связке ключей: сначала самоподписанный "TermJ Signing", затем Apple Development.
IDENTITY=""
if security find-identity -v -p codesigning 2>/dev/null | grep -q "TermJ Signing"; then
IDENTITY="TermJ Signing"
elif security find-identity -v -p codesigning 2>/dev/null | grep -q "Apple Development"; then
IDENTITY=$(security find-identity -v -p codesigning | grep "Apple Development" | head -1 | sed 's/.*"\(.*\)"/\1/')
fi
if [ -n "$IDENTITY" ]; then
echo "==> Подписываю identity: $IDENTITY"
codesign --force --deep --sign "$IDENTITY" \
--identifier com.bayanist.termj "$APP"
else
echo "==> Identity не найдена, использую ad-hoc подпись."
echo " Внимание: TCC будет заново просить права после каждой пересборки."
echo " Создай сертификат: Keychain Access -> Certificate Assistant ->"
echo " Create a Certificate -> имя 'TermJ Signing', тип 'Code Signing'."
codesign --force --deep --sign - "$APP" 2>/dev/null || echo "(codesign пропущен)"
fi
# Сбрасываем quarantine и расширенные атрибуты.
xattr -cr "$APP" 2>/dev/null || true
# Собираем zip-архив для GitHub Release (ассет автообновления).
ZIP_NAME="TermJ-$APP_VERSION.zip"
rm -f "$ZIP_NAME"
ditto -c -k --keepParent "$APP" "$ZIP_NAME" 2>/dev/null && echo "==> Ассет релиза: $(pwd)/$ZIP_NAME"
echo "==> Готово: $(pwd)/$APP"
echo "Перенеси в /Applications: cp -R $APP /Applications/"
echo "Запуск: open /Applications/$APP"