Skip to content

Commit 43ac784

Browse files
committed
feat: add skip_build option to macOS workflow for faster universal binary creation
- Add workflow_dispatch inputs to skip build and use previous artifacts - Add conditional logic to download artifacts from previous runs - Support both specific run_id and latest successful run - Significantly reduces build time when only universal binary is needed
1 parent 9f280fc commit 43ac784

1 file changed

Lines changed: 61 additions & 9 deletions

File tree

.github/workflows/build-macos.yml

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ name: Build macOS
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
skip_build:
7+
description: 'Skip build and use artifacts from a previous run'
8+
required: false
9+
default: false
10+
type: boolean
11+
run_id:
12+
description: 'Run ID to download artifacts from (leave empty for latest)'
13+
required: false
14+
type: string
515
push:
616
branches: [main, test-linux-workflow]
717

818
jobs:
919
build:
1020
name: Build macOS ${{ matrix.target }}
21+
if: ${{ !inputs.skip_build }}
1122
runs-on: ${{ matrix.os }}
1223
strategy:
1324
matrix:
@@ -73,17 +84,47 @@ jobs:
7384

7485
universal:
7586
name: Create Universal Binary
76-
needs: build
87+
needs: [build]
88+
if: ${{ !cancelled() && (needs.build.result == 'success' || needs.build.result == 'skipped') }}
7789
runs-on: macos-latest
7890
steps:
7991
- uses: actions/checkout@v4
8092

81-
- name: Download artifacts
93+
- name: Download artifacts from current workflow
94+
if: ${{ !inputs.skip_build }}
8295
uses: actions/download-artifact@v4
8396
with:
8497
pattern: macos-*
8598
path: artifacts
8699

100+
- name: Download artifacts from specific run
101+
if: ${{ inputs.skip_build && inputs.run_id != '' }}
102+
uses: dawidd6/action-download-artifact@v3
103+
with:
104+
workflow: build-macos.yml
105+
run_id: ${{ inputs.run_id }}
106+
name: macos-*
107+
path: artifacts
108+
109+
- name: Download artifacts from latest run
110+
if: ${{ inputs.skip_build && inputs.run_id == '' }}
111+
uses: dawidd6/action-download-artifact@v3
112+
with:
113+
workflow: build-macos.yml
114+
workflow_conclusion: success
115+
name: macos-*
116+
path: artifacts
117+
118+
- name: List downloaded artifacts
119+
run: |
120+
echo "📁 Artifact structure:"
121+
find artifacts -type f -name "*.app" -o -name "*.dmg" | head -20
122+
echo ""
123+
echo "📁 Full directory structure:"
124+
ls -la artifacts/
125+
ls -la artifacts/macos-aarch64/ || echo "macos-aarch64 directory not found"
126+
ls -la artifacts/macos-x86_64/ || echo "macos-x86_64 directory not found"
127+
87128
- name: Import Apple certificates
88129
env:
89130
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
@@ -112,17 +153,28 @@ jobs:
112153
# Create temp directory
113154
mkdir -p dmg_temp
114155
115-
# Extract both app bundles
116-
cp -R artifacts/macos-aarch64/Claudia.app dmg_temp/
156+
# Find the actual app paths
157+
AARCH64_APP=$(find artifacts/macos-aarch64 -name "Claudia.app" -type d | head -1)
158+
X86_64_APP=$(find artifacts/macos-x86_64 -name "Claudia.app" -type d | head -1)
159+
160+
if [ -z "$AARCH64_APP" ] || [ -z "$X86_64_APP" ]; then
161+
echo "❌ Could not find app bundles"
162+
echo "AARCH64_APP: $AARCH64_APP"
163+
echo "X86_64_APP: $X86_64_APP"
164+
exit 1
165+
fi
166+
167+
echo "✅ Found app bundles:"
168+
echo " ARM64: $AARCH64_APP"
169+
echo " x86_64: $X86_64_APP"
117170
118-
# Extract x86_64 binary
119-
mkdir -p temp_x86
120-
cp -R artifacts/macos-x86_64/Claudia.app temp_x86/
171+
# Copy ARM64 app as base
172+
cp -R "$AARCH64_APP" dmg_temp/
121173
122174
# Create universal binary using lipo
123175
lipo -create -output dmg_temp/Claudia.app/Contents/MacOS/claudia \
124-
dmg_temp/Claudia.app/Contents/MacOS/claudia \
125-
temp_x86/Claudia.app/Contents/MacOS/claudia
176+
"$AARCH64_APP/Contents/MacOS/claudia" \
177+
"$X86_64_APP/Contents/MacOS/claudia"
126178
127179
echo "✅ Universal binary created"
128180
lipo -info dmg_temp/Claudia.app/Contents/MacOS/claudia

0 commit comments

Comments
 (0)