-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (135 loc) · 4.84 KB
/
build-macos-release.yml
File metadata and controls
161 lines (135 loc) · 4.84 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Build macOS Release
on:
release:
types: [created]
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v0.1.0)'
required: true
default: 'v0.1.0-macos'
permissions:
contents: write
packages: write
jobs:
build-macos:
name: Build macOS Application
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set version from release tag
run: |
if [ "${{ github.event_name }}" == "release" ]; then
# Extract version from release tag (e.g., "v1.0.0" from tag "v1.0.0")
VERSION="${{ github.event.release.tag_name }}"
else
# For workflow_dispatch, use the input version
VERSION="${{ github.event.inputs.version }}"
fi
echo "Setting version to: $VERSION"
echo "$VERSION" > VERSION
cat VERSION
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Display Python version
run: python --version
- name: Install system dependencies for icon generation
run: |
brew install librsvg imagemagick
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_macos.txt
- name: Build frontend
run: |
cd frontend
npm install
npm run build
cd ..
- name: Generate app icon
run: |
chmod +x build/macos/generate_icon.sh
./build/macos/generate_icon.sh
- name: Check build/macos assets (icon, codesign, DMG README)
run: |
if [ ! -f "build/macos/CTFNStudio.icns" ]; then
echo "::error::build/macos/CTFNStudio.icns not found after generation."
exit 1
fi
if [ ! -f "build/macos/codesign.sh" ]; then
echo "::error::build/macos/codesign.sh not found."
exit 1
fi
if [ ! -f ".github/DMG_README.txt" ]; then
echo "::error::.github/DMG_README.txt not found."
exit 1
fi
- name: Clean previous PyInstaller outputs
run: |
rm -rf dist/CTFNStudio.app build/CTFNStudio
- name: Build with PyInstaller
run: |
python -m PyInstaller HeartMuLa.spec --clean --noconfirm
- name: Set up app bundle executable
run: |
# CFBundleExecutable is "CTFNStudio"; PyInstaller produces CTFNStudio_bin
# Copy so the app runs the real binary (native, no terminal)
cp dist/CTFNStudio.app/Contents/MacOS/CTFNStudio_bin dist/CTFNStudio.app/Contents/MacOS/CTFNStudio
chmod +x dist/CTFNStudio.app/Contents/MacOS/CTFNStudio
- name: Code sign the app bundle
run: |
# Run the code signing script with ad-hoc signing (no certificate required for dev builds)
# This prevents the "app is damaged" warning that requires sudo xattr -cr
# For production releases, set MACOS_SIGNING_IDENTITY secret to your Developer ID
chmod +x build/macos/codesign.sh
./build/macos/codesign.sh dist/CTFNStudio.app
env:
MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY || '-' }}
- name: Create DMG (macOS disk image)
run: |
# Create a temporary directory for DMG contents
mkdir -p dmg_temp
cp -R dist/CTFNStudio.app dmg_temp/
# Copy the .command file for easy launching
cp CTFNStudio.command dmg_temp/
chmod +x dmg_temp/CTFNStudio.command
# Create Applications symlink for easy drag-and-drop install
ln -s /Applications dmg_temp/Applications
# Copy README for users
cp .github/DMG_README.txt dmg_temp/README.txt
# Create DMG
hdiutil create -volname "CTFN Studio" \
-srcfolder dmg_temp \
-ov -format UDZO \
CTFNStudio-macOS.dmg
- name: Create ZIP archive (alternative distribution)
run: |
cd dist
zip -r ../CTFNStudio-macOS.zip CTFNStudio.app
cd ..
- name: Calculate checksums
run: |
shasum -a 256 CTFNStudio-macOS.dmg > checksums.txt
shasum -a 256 CTFNStudio-macOS.zip >> checksums.txt
cat checksums.txt
- name: Upload DMG artifact
uses: actions/upload-artifact@v4
with:
name: CTFNStudio-macOS-DMG
path: CTFNStudio-macOS.dmg
- name: Upload ZIP artifact
uses: actions/upload-artifact@v4
with:
name: CTFNStudio-macOS-ZIP
path: CTFNStudio-macOS.zip
- name: Upload to Release (if triggered by release)
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
CTFNStudio-macOS.dmg
CTFNStudio-macOS.zip
checksums.txt