Skip to content

Commit 7283b80

Browse files
committed
Optimize Release builds and add GitHub Actions CI/CD
Phase 1: Build Size Optimization - Enable DEPLOYMENT_POSTPROCESSING in Release configuration - Enable COPY_PHASE_STRIP to strip symbols during copy - Enable DEAD_CODE_STRIPPING to remove unused code - Results: Binary size reduced from 9.4MB to 3.7MB (~60% reduction) - Total app size reduced from 12MB to 6MB (~51% reduction) Phase 2: GitHub Actions Workflow - Add comprehensive CI/CD pipeline with 5 jobs: * lint: SwiftLint strict validation * prepare-libs: Create universal libmariadb library * build-arm64: Build Apple Silicon binary (parallel) * build-x86_64: Build Intel binary (parallel) * release: Create GitHub Releases for version tags - Implement Homebrew caching for faster builds - Configure artifact retention (7 days for main, 90 days for tags) - Add path ignores to skip builds on documentation changes - Support both push to main and version tag triggers Documentation: - Update BUILD.md with accurate size references (6MB per architecture) - Add build optimization section explaining settings - Update distribution recommendations with correct sizes Closes optimization work for Intel Mac support.
1 parent d0ccd92 commit 7283b80

File tree

3 files changed

+322
-8
lines changed

3 files changed

+322
-8
lines changed

.github/workflows/build.yml

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
name: Build TablePro
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['v*']
7+
paths-ignore:
8+
- '**.md'
9+
- 'docs/**'
10+
- '.github/**'
11+
- '.vscode/**'
12+
pull_request:
13+
branches: [main]
14+
paths-ignore:
15+
- '**.md'
16+
- 'docs/**'
17+
18+
env:
19+
XCODE_PROJECT: TablePro.xcodeproj
20+
XCODE_SCHEME: TablePro
21+
BUILD_CONFIGURATION: Release
22+
23+
jobs:
24+
lint:
25+
name: SwiftLint
26+
runs-on: macos-14
27+
timeout-minutes: 10
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Cache SwiftLint
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/Library/Caches/Homebrew/swiftlint*
37+
key: swiftlint-${{ runner.os }}-${{ hashFiles('.swiftlint.yml') }}
38+
restore-keys: |
39+
swiftlint-${{ runner.os }}-
40+
41+
- name: Install SwiftLint
42+
run: brew install swiftlint
43+
44+
- name: Run SwiftLint
45+
run: swiftlint lint --strict
46+
47+
prepare-libs:
48+
name: Prepare Universal Libraries
49+
runs-on: macos-14
50+
needs: lint
51+
timeout-minutes: 25
52+
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Cache Homebrew packages
58+
uses: actions/cache@v4
59+
with:
60+
path: |
61+
~/Library/Caches/Homebrew
62+
/opt/homebrew/Cellar/mariadb-connector-c
63+
/opt/homebrew/Cellar/libpq
64+
/usr/local/Cellar/mariadb-connector-c
65+
/usr/local/Cellar/libpq
66+
key: brew-deps-${{ runner.os }}-${{ hashFiles('**/build-release.sh') }}
67+
restore-keys: |
68+
brew-deps-${{ runner.os }}-
69+
70+
- name: Install ARM64 Homebrew dependencies
71+
run: |
72+
brew install mariadb-connector-c libpq
73+
74+
- name: Install x86_64 Homebrew
75+
run: |
76+
# Install Rosetta 2 if needed
77+
if ! arch -x86_64 /usr/bin/true 2>/dev/null; then
78+
echo "Installing Rosetta 2..."
79+
softwareupdate --install-rosetta --agree-to-license
80+
fi
81+
82+
# Check if x86_64 Homebrew is already installed
83+
if [ ! -f /usr/local/bin/brew ]; then
84+
echo "Installing x86_64 Homebrew..."
85+
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
86+
else
87+
echo "x86_64 Homebrew already installed"
88+
fi
89+
90+
- name: Install x86_64 Homebrew dependencies
91+
run: |
92+
arch -x86_64 /usr/local/bin/brew install mariadb-connector-c libpq
93+
94+
- name: Create universal libmariadb library
95+
run: |
96+
echo "Creating universal libmariadb.a..."
97+
lipo -create \
98+
/opt/homebrew/opt/mariadb-connector-c/lib/mariadb/libmariadb.a \
99+
/usr/local/opt/mariadb-connector-c/lib/mariadb/libmariadb.a \
100+
-output Libs/libmariadb_universal.a
101+
102+
echo "Verifying universal library:"
103+
lipo -info Libs/libmariadb_universal.a
104+
ls -lh Libs/libmariadb_universal.a
105+
106+
- name: Upload library artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: libs-universal
110+
path: Libs/
111+
retention-days: 1
112+
113+
build-arm64:
114+
name: Build ARM64
115+
runs-on: macos-14
116+
needs: prepare-libs
117+
timeout-minutes: 20
118+
119+
steps:
120+
- name: Checkout code
121+
uses: actions/checkout@v4
122+
123+
- name: Download library artifacts
124+
uses: actions/download-artifact@v4
125+
with:
126+
name: libs-universal
127+
path: Libs/
128+
129+
- name: Cache Homebrew packages
130+
uses: actions/cache@v4
131+
with:
132+
path: |
133+
~/Library/Caches/Homebrew
134+
/opt/homebrew/Cellar/mariadb-connector-c
135+
/opt/homebrew/Cellar/libpq
136+
key: brew-arm64-${{ runner.os }}-${{ hashFiles('**/build-release.sh') }}
137+
restore-keys: |
138+
brew-arm64-${{ runner.os }}-
139+
140+
- name: Install ARM64 dependencies
141+
run: brew install mariadb-connector-c libpq
142+
143+
- name: Build ARM64
144+
run: |
145+
chmod +x build-release.sh
146+
./build-release.sh arm64
147+
148+
- name: Verify build
149+
run: |
150+
echo "Build completed. Binary info:"
151+
ls -lh build/Release/TablePro-arm64.app/Contents/MacOS/TablePro
152+
lipo -info build/Release/TablePro-arm64.app/Contents/MacOS/TablePro
153+
du -sh build/Release/TablePro-arm64.app
154+
155+
- name: Create ZIP archive
156+
run: |
157+
cd build/Release
158+
zip -r TablePro-arm64.zip TablePro-arm64.app
159+
ls -lh TablePro-arm64.zip
160+
161+
- name: Upload artifact
162+
uses: actions/upload-artifact@v4
163+
with:
164+
name: TablePro-arm64-${{ github.sha }}
165+
path: build/Release/TablePro-arm64.zip
166+
retention-days: ${{ startsWith(github.ref, 'refs/tags/v') && 90 || 7 }}
167+
168+
build-x86_64:
169+
name: Build x86_64
170+
runs-on: macos-14
171+
needs: prepare-libs
172+
timeout-minutes: 20
173+
174+
steps:
175+
- name: Checkout code
176+
uses: actions/checkout@v4
177+
178+
- name: Download library artifacts
179+
uses: actions/download-artifact@v4
180+
with:
181+
name: libs-universal
182+
path: Libs/
183+
184+
- name: Cache Homebrew packages
185+
uses: actions/cache@v4
186+
with:
187+
path: |
188+
~/Library/Caches/Homebrew
189+
/usr/local/Cellar/mariadb-connector-c
190+
/usr/local/Cellar/libpq
191+
key: brew-x86_64-${{ runner.os }}-${{ hashFiles('**/build-release.sh') }}
192+
restore-keys: |
193+
brew-x86_64-${{ runner.os }}-
194+
195+
- name: Install Rosetta 2
196+
run: |
197+
if ! arch -x86_64 /usr/bin/true 2>/dev/null; then
198+
softwareupdate --install-rosetta --agree-to-license
199+
fi
200+
201+
- name: Install x86_64 Homebrew
202+
run: |
203+
if [ ! -f /usr/local/bin/brew ]; then
204+
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
205+
fi
206+
207+
- name: Install x86_64 dependencies
208+
run: arch -x86_64 /usr/local/bin/brew install mariadb-connector-c libpq
209+
210+
- name: Build x86_64
211+
run: |
212+
chmod +x build-release.sh
213+
./build-release.sh x86_64
214+
215+
- name: Verify build
216+
run: |
217+
echo "Build completed. Binary info:"
218+
ls -lh build/Release/TablePro-x86_64.app/Contents/MacOS/TablePro
219+
lipo -info build/Release/TablePro-x86_64.app/Contents/MacOS/TablePro
220+
du -sh build/Release/TablePro-x86_64.app
221+
222+
- name: Create ZIP archive
223+
run: |
224+
cd build/Release
225+
zip -r TablePro-x86_64.zip TablePro-x86_64.app
226+
ls -lh TablePro-x86_64.zip
227+
228+
- name: Upload artifact
229+
uses: actions/upload-artifact@v4
230+
with:
231+
name: TablePro-x86_64-${{ github.sha }}
232+
path: build/Release/TablePro-x86_64.zip
233+
retention-days: ${{ startsWith(github.ref, 'refs/tags/v') && 90 || 7 }}
234+
235+
release:
236+
name: Create GitHub Release
237+
runs-on: macos-14
238+
needs: [build-arm64, build-x86_64]
239+
if: startsWith(github.ref, 'refs/tags/v')
240+
timeout-minutes: 10
241+
242+
steps:
243+
- name: Checkout code
244+
uses: actions/checkout@v4
245+
246+
- name: Download ARM64 artifact
247+
uses: actions/download-artifact@v4
248+
with:
249+
name: TablePro-arm64-${{ github.sha }}
250+
path: artifacts/
251+
252+
- name: Download x86_64 artifact
253+
uses: actions/download-artifact@v4
254+
with:
255+
name: TablePro-x86_64-${{ github.sha }}
256+
path: artifacts/
257+
258+
- name: Rename artifacts for release
259+
run: |
260+
VERSION=${GITHUB_REF#refs/tags/}
261+
mv artifacts/TablePro-arm64.zip artifacts/TablePro-${VERSION}-arm64.zip
262+
mv artifacts/TablePro-x86_64.zip artifacts/TablePro-${VERSION}-x86_64.zip
263+
ls -lh artifacts/
264+
265+
- name: Generate release notes
266+
id: release_notes
267+
run: |
268+
VERSION=${GITHUB_REF#refs/tags/}
269+
cat > release_notes.md <<EOF
270+
## TablePro ${VERSION}
271+
272+
### Downloads
273+
274+
Choose the appropriate version for your Mac:
275+
276+
- **Apple Silicon (M1/M2/M3)**: Download \`TablePro-${VERSION}-arm64.zip\`
277+
- **Intel**: Download \`TablePro-${VERSION}-x86_64.zip\`
278+
279+
### Installation
280+
281+
1. Download the appropriate ZIP file for your Mac
282+
2. Unzip the file
283+
3. Move TablePro.app to your Applications folder
284+
4. Right-click and select "Open" on first launch (unsigned app)
285+
286+
### Changes
287+
288+
$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 HEAD^)..HEAD)
289+
EOF
290+
291+
cat release_notes.md
292+
293+
- name: Create GitHub Release
294+
uses: softprops/action-gh-release@v1
295+
with:
296+
files: |
297+
artifacts/*.zip
298+
body_path: release_notes.md
299+
draft: false
300+
prerelease: ${{ contains(github.ref, '-beta') || contains(github.ref, '-alpha') || contains(github.ref, '-rc') }}
301+
env:
302+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

BUILD.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Build architecture-specific binaries to minimize download size:
2626
- `build/Release/TablePro-x86_64.app` - For Intel Macs
2727

2828
**Benefits:**
29-
- ✅ Smaller file size (~9.5MB each vs 19MB universal)
29+
- ✅ Smaller file size (~6MB each vs 12MB universal)
3030
- ✅ Users only download what they need
3131
- ✅ Faster downloads
3232
- ✅ Less disk space
@@ -45,7 +45,7 @@ xcodebuild -project TablePro.xcodeproj \
4545
```
4646

4747
**Output:**
48-
- `TablePro.app` - Runs on both Apple Silicon and Intel (~19MB)
48+
- `TablePro.app` - Runs on both Apple Silicon and Intel (~12MB)
4949

5050
**Benefits:**
5151
- ✅ One download for all users
@@ -56,9 +56,9 @@ xcodebuild -project TablePro.xcodeproj \
5656

5757
| Build Type | Size | Notes |
5858
|------------|------|-------|
59-
| ARM64-only | 9.4MB | Apple Silicon Macs only |
60-
| x86_64-only | 9.5MB | Intel Macs only |
61-
| Universal | 19MB | Both architectures |
59+
| ARM64-only | 5.9MB | Apple Silicon Macs only |
60+
| x86_64-only | 6.0MB | Intel Macs only |
61+
| Universal | ~12MB | Both architectures |
6262

6363
## Dependencies
6464

@@ -89,17 +89,26 @@ To build Intel binaries on an Apple Silicon Mac, you need both Homebrew installa
8989

9090
**For GitHub Releases:**
9191
```
92-
✅ TablePro-v0.1.13-arm64.dmg (Apple Silicon)
93-
✅ TablePro-v0.1.13-x86_64.dmg (Intel)
92+
✅ TablePro-v0.1.13-arm64.zip (~2MB zipped, ~6MB unzipped)
93+
✅ TablePro-v0.1.13-x86_64.zip (~2MB zipped, ~6MB unzipped)
9494
```
9595

9696
**For simple distribution:**
9797
```
98-
✅ TablePro-v0.1.13-universal.dmg (Both architectures)
98+
✅ TablePro-v0.1.13-universal.zip (~4MB zipped, ~12MB unzipped)
9999
```
100100

101101
Most modern apps (Discord, Slack, VSCode) distribute separate builds to save bandwidth.
102102

103+
## Build Optimizations
104+
105+
Release builds are optimized with:
106+
- `DEPLOYMENT_POSTPROCESSING = YES` - Enables symbol stripping
107+
- `COPY_PHASE_STRIP = YES` - Strips symbols during copy
108+
- `DEAD_CODE_STRIPPING = YES` - Removes unused code
109+
110+
These settings reduce binary size by ~60% (from 9.4MB to 3.7MB per architecture).
111+
103112
## Quick Start
104113

105114
```bash

TablePro.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@
341341
AUTOMATION_APPLE_EVENTS = NO;
342342
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
343343
CODE_SIGN_STYLE = Automatic;
344+
COPY_PHASE_STRIP = YES;
344345
CURRENT_PROJECT_VERSION = 13;
346+
DEAD_CODE_STRIPPING = YES;
347+
DEPLOYMENT_POSTPROCESSING = YES;
345348
DEVELOPMENT_TEAM = D7HJ5TFYCU;
346349
ENABLE_APP_SANDBOX = NO;
347350
ENABLE_HARDENED_RUNTIME = NO;

0 commit comments

Comments
 (0)