Skip to content

Commit 033a792

Browse files
author
tom
committed
build mac? test
1 parent 787d201 commit 033a792

2 files changed

Lines changed: 105 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,92 @@ jobs:
130130
with:
131131
name: PyCronVideoAlarm_Windows
132132
path: dist/PyCronVideoAlarm_Windows.exe
133+
134+
build-macos:
135+
runs-on: macos-latest
136+
needs: check-trigger
137+
if: needs.check-trigger.outputs.should_build == 'true'
138+
steps:
139+
- uses: actions/checkout@v3
140+
141+
- name: Set up Python 3.11
142+
uses: actions/setup-python@v4
143+
with:
144+
python-version: "3.11"
145+
146+
- name: Install dependencies
147+
run: |
148+
python -m pip install --upgrade pip
149+
pip install -r requirements.txt
150+
pip install pyinstaller
151+
152+
- name: Generate macOS .icns file
153+
run: |
154+
mkdir -p build_tmp/icon.iconset
155+
sips -z 16 16 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_16x16.png
156+
sips -z 32 32 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_16x16@2x.png
157+
sips -z 32 32 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_32x32.png
158+
sips -z 64 64 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_32x32@2x.png
159+
sips -z 128 128 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_128x128.png
160+
sips -z 256 256 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_128x128@2x.png
161+
sips -z 256 256 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_256x256.png
162+
sips -z 512 512 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_256x256@2x.png
163+
sips -z 512 512 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_512x512.png
164+
sips -z 1024 1024 icons/alarm_icon7.png --out build_tmp/icon.iconset/icon_512x512@2x.png
165+
iconutil -c icns build_tmp/icon.iconset
166+
mv build_tmp/icon.icns icons/alarm_icon7.icns
167+
rm -rf build_tmp
168+
169+
- name: Build with PyInstaller
170+
run: |
171+
export TZ='America/New_York'
172+
TS=$(date +'%Y-%m-%d_%H%M')
173+
BUILD_DATE=$(date +'%Y-%m-%d %H:%M EST')
174+
echo "Built: $BUILD_DATE" > version.txt
175+
echo "Archive: ${TS}_PyCronVideoAlarm_macOS" >> version.txt
176+
177+
pyinstaller --noconfirm --onefile --windowed \
178+
--name "PyCronVideoAlarm" \
179+
--icon "icons/alarm_icon7.icns" \
180+
--osx-bundle-identifier "com.juke32.pycronvideoalarm" \
181+
--add-data "src:src" \
182+
--add-data "icons/alarm_icon7.icns:." \
183+
--add-data "icons/alarm_icon7.png:." \
184+
--add-data "version.txt:." \
185+
--add-data "LICENSE:." \
186+
--exclude-module=cv2 \
187+
--exclude-module=numpy \
188+
--exclude-module=scipy \
189+
--exclude-module=pandas \
190+
--exclude-module=matplotlib \
191+
--exclude-module=sounddevice \
192+
src/main.py
193+
194+
- name: Inject macOS Permissions into Info.plist
195+
run: |
196+
PLIST="dist/PyCronVideoAlarm.app/Contents/Info.plist"
197+
if [ -f "$PLIST" ]; then
198+
plutil -insert NSAppleEventsUsageDescription -string "PyCron Video Alarm needs to control the system to execute alarm sequences." "$PLIST"
199+
plutil -insert NSCalendarsUsageDescription -string "PyCron Video Alarm needs to schedule alarms." "$PLIST"
200+
plutil -insert NSRemindersUsageDescription -string "PyCron Video Alarm needs to integrate with reminders." "$PLIST"
201+
plutil -insert NSDesktopFolderUsageDescription -string "PyCron Video Alarm needs to access desktop media for your alarms." "$PLIST"
202+
plutil -insert NSDocumentsFolderUsageDescription -string "PyCron Video Alarm needs to access documents media for your alarms." "$PLIST"
203+
plutil -insert NSDownloadsFolderUsageDescription -string "PyCron Video Alarm needs to access downloaded media for your alarms." "$PLIST"
204+
plutil -insert NSMicrophoneUsageDescription -string "PyCron Video Alarm occasionally requires audio capture if custom actions require it." "$PLIST"
205+
plutil -insert NSScreenCaptureDescription -string "PyCron Video Alarm requires screen capture to perform screenshot sequences." "$PLIST"
206+
echo "Permissions successfully added"
207+
else
208+
echo "Error: Info.plist not found!"
209+
exit 1
210+
fi
211+
212+
- name: Zip macOS App Bundle
213+
run: |
214+
cd dist
215+
zip -r PyCronVideoAlarm_macOS.zip PyCronVideoAlarm.app
216+
217+
- name: Upload Artifact
218+
uses: actions/upload-artifact@v4
219+
with:
220+
name: PyCronVideoAlarm_macOS
221+
path: dist/PyCronVideoAlarm_macOS.zip

README_macOS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,19 @@ On macOS, scheduling relies on the underlying `cron` daemon.
5959
| Video won't play | Ensure MPV or VLC is installed via Homebrew. |
6060

6161
Enable **Settings → Logging** and check the logs folder for detailed error output.
62+
63+
---
64+
65+
## 🏗️ Building a Native .app Bundle
66+
67+
You can build a native `.app` bundle from your Mac (or trigger GitHub Actions by pushing a commit starting with `build`):
68+
69+
```bash
70+
chmod +x build_macos.sh
71+
./build_macos.sh
72+
```
73+
74+
This will automatically:
75+
1. Compile the icons into an `.icns` file
76+
2. Bundle the application into `dist/PyCronVideoAlarm.app`
77+
3. Inject the necessary macOS Privacy Permissions (`Info.plist`) so the app can request access to your files.

0 commit comments

Comments
 (0)