Skip to content

Commit cd6bad4

Browse files
committed
Workflow overhaul
1 parent fa56fc3 commit cd6bad4

1 file changed

Lines changed: 0 additions & 273 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 273 deletions
Original file line numberDiff line numberDiff line change
@@ -51,281 +51,8 @@ jobs:
5151
mkdir release
5252
cp build/Advancely release/
5353
cp -r resources release/
54-
cp _PLEASE_READ_ME.txt LICENSES.txt README.md release/
55-
cp /usr/local/lib/libSDL3.so.0 release/
56-
cp /usr/local/lib/libSDL3_image.so.0 release/
57-
cp /usr/local/lib/libSDL3_ttf.so.0 release/
5854
- name: Upload Linux Release Artifact
5955
uses: actions/upload-artifact@v4
6056
with:
6157
name: Advancely-v${{ env.PROJECT_VERSION }}-Linux
6258
path: release/
63-
64-
# Job 2: Build, Test, and Bundle the macOS Intel (X64) version
65-
build_macos_intel:
66-
runs-on: macos-14
67-
steps:
68-
- name: Checkout repository
69-
uses: actions/checkout@v4
70-
- name: Install dependencies (macOS)
71-
# 1. Manually install the x86_64 version of Homebrew into /usr/local
72-
# This is required for cross-compiling on an ARM64 runner.
73-
# 2. Use that Homebrew to install the x86_64 dependencies.
74-
run: |
75-
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
76-
/usr/local/bin/brew install sdl3 sdl3_image sdl3_ttf curl jpeg-xl webp
77-
- name: Configure CMake (macOS)
78-
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="13.0" -DCMAKE_OSX_ARCHITECTURES="x86_64"
79-
- name: Build Project
80-
run: cmake --build build --config Release
81-
- name: Install gtimeout (GNU Coreutils)
82-
run: brew install coreutils
83-
- name: Bundle macOS Dependencies
84-
shell: bash
85-
run: |
86-
BUNDLE_PATH="build/Advancely.app"
87-
EXE_PATH="$BUNDLE_PATH/Contents/MacOS/Advancely"
88-
LIBS_DEST_DIR="$BUNDLE_PATH/Contents/MacOS"
89-
BREW_PREFIX="/usr/local" # Hardcode the Intel (x86_64) Homebrew prefix
90-
LIBS_TO_PROCESS=($(otool -L "$EXE_PATH" | grep "$BREW_PREFIX" | awk '{gsub(/:$/, ""); print $1}'))
91-
TEMP_DEPS_LIST=()
92-
i=0
93-
while [ $i -lt ${#LIBS_TO_PROCESS[@]} ]; do
94-
original_lib_path=${LIBS_TO_PROCESS[$i]}
95-
i=$((i+1))
96-
if [[ " ${TEMP_DEPS_LIST[*]} " =~ " ${original_lib_path} " ]]; then continue; fi
97-
TEMP_DEPS_LIST+=("$original_lib_path")
98-
lib_name=$(basename "$original_lib_path")
99-
actual_lib_path="$BREW_PREFIX/lib/$lib_name"
100-
if [ ! -f "$actual_lib_path" ]; then echo "::error::Cannot find '$lib_name'"; exit 1; fi
101-
TRANSITIVE_DEPS=($(otool -L "$actual_lib_path" | grep -E "$BREW_PREFIX|@rpath" | awk '{gsub(/:$/, ""); print $1}'))
102-
for dep in "${TRANSITIVE_DEPS[@]}"; do LIBS_TO_PROCESS+=("$dep"); done
103-
done
104-
UNIQUE_ORIGINAL_PATHS=($(echo "${LIBS_TO_PROCESS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
105-
UNIQUE_BASENAMES=($(for path in "${UNIQUE_ORIGINAL_PATHS[@]}"; do basename "$path"; done | sort -u))
106-
for lib_name in "${UNIQUE_BASENAMES[@]}"; do
107-
cp "$BREW_PREFIX/lib/$lib_name" "$LIBS_DEST_DIR/"
108-
done
109-
for original_lib_path in "${UNIQUE_ORIGINAL_PATHS[@]}"; do
110-
lib_name=$(basename "$original_lib_path")
111-
install_name_tool -change "$original_lib_path" "@executable_path/$lib_name" "$EXE_PATH"
112-
done
113-
for copied_lib_path in "$LIBS_DEST_DIR"/lib*.dylib; do
114-
copied_lib_name=$(basename "$copied_lib_path")
115-
install_name_tool -id "@executable_path/$copied_lib_name" "$copied_lib_path"
116-
for original_lib_path in "${UNIQUE_ORIGINAL_PATHS[@]}"; do
117-
original_lib_name=$(basename "$original_lib_path")
118-
install_name_tool -change "$original_lib_path" "@executable_path/$original_lib_name" "$copied_lib_path"
119-
done
120-
done
121-
codesign --force --sign - "$LIBS_DEST_DIR"/lib*.dylib
122-
codesign --force --deep --sign - "$BUNDLE_PATH"
123-
# Testing
124-
- name: Run Executable Test (macOS Intel)
125-
run: |
126-
echo "Running executable for 5 seconds..."
127-
gtimeout 10s ./build/Advancely.app/Contents/MacOS/Advancely --test-mode > output.txt 2>&1 || true
128-
echo "Executable run finished. Contents of output.txt:"
129-
cat output.txt
130-
- name: Upload Test Output (macOS Intel)
131-
uses: actions/upload-artifact@v4
132-
with:
133-
name: test-output-v${{ env.PROJECT_VERSION }}-macOS-X64
134-
path: output.txt
135-
- name: Upload Intel App Bundle
136-
uses: actions/upload-artifact@v4
137-
with:
138-
name: Advancely-v${{ env.PROJECT_VERSION }}-macOS-X64-app
139-
path: build/Advancely.app
140-
141-
# Job 3: Build, Test, and Bundle the macOS Apple Silicon (ARM64) version
142-
build_macos_arm:
143-
runs-on: macos-latest
144-
steps:
145-
- name: Checkout repository
146-
uses: actions/checkout@v4
147-
- name: Install dependencies (macOS)
148-
run: brew install sdl3 sdl3_image sdl3_ttf curl jpeg-xl webp
149-
- name: Configure CMake (macOS)
150-
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$(brew --prefix) -DCMAKE_OSX_DEPLOYMENT_TARGET="13.0"
151-
- name: Build Project
152-
run: cmake --build build --config Release
153-
- name: Install gtimeout (GNU Coreutils)
154-
run: brew install coreutils
155-
- name: Run Executable Test (macOS ARM)
156-
run: |
157-
echo "Running executable for 5 seconds..."
158-
gtimeout 5s ./build/Advancely.app/Contents/MacOS/Advancely --test-mode > output.txt 2>&1 || true
159-
echo "Executable run finished. Contents of output.txt:"
160-
cat output.txt
161-
- name: Upload Test Output (macOS ARM)
162-
uses: actions/upload-artifact@v4
163-
with:
164-
name: test-output-v${{ env.PROJECT_VERSION }}-macOS-ARM64
165-
path: output.txt
166-
- name: Bundle macOS Dependencies
167-
shell: bash
168-
run: |
169-
BUNDLE_PATH="build/Advancely.app"
170-
EXE_PATH="$BUNDLE_PATH/Contents/MacOS/Advancely"
171-
LIBS_DEST_DIR="$BUNDLE_PATH/Contents/MacOS"
172-
BREW_PREFIX=$(brew --prefix)
173-
LIBS_TO_PROCESS=($(otool -L "$EXE_PATH" | grep "$BREW_PREFIX" | awk '{gsub(/:$/, ""); print $1}'))
174-
TEMP_DEPS_LIST=()
175-
i=0
176-
while [ $i -lt ${#LIBS_TO_PROCESS[@]} ]; do
177-
original_lib_path=${LIBS_TO_PROCESS[$i]}
178-
i=$((i+1))
179-
if [[ " ${TEMP_DEPS_LIST[*]} " =~ " ${original_lib_path} " ]]; then continue; fi
180-
TEMP_DEPS_LIST+=("$original_lib_path")
181-
lib_name=$(basename "$original_lib_path")
182-
actual_lib_path="$BREW_PREFIX/lib/$lib_name"
183-
if [ ! -f "$actual_lib_path" ]; then echo "::error::Cannot find '$lib_name'"; exit 1; fi
184-
TRANSITIVE_DEPS=($(otool -L "$actual_lib_path" | grep -E "$BREW_PREFIX|@rpath" | awk '{gsub(/:$/, ""); print $1}'))
185-
for dep in "${TRANSITIVE_DEPS[@]}"; do LIBS_TO_PROCESS+=("$dep"); done
186-
done
187-
UNIQUE_ORIGINAL_PATHS=($(echo "${LIBS_TO_PROCESS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
188-
UNIQUE_BASENAMES=($(for path in "${UNIQUE_ORIGINAL_PATHS[@]}"; do basename "$path"; done | sort -u))
189-
for lib_name in "${UNIQUE_BASENAMES[@]}"; do
190-
cp "$BREW_PREFIX/lib/$lib_name" "$LIBS_DEST_DIR/"
191-
done
192-
for original_lib_path in "${UNIQUE_ORIGINAL_PATHS[@]}"; do
193-
lib_name=$(basename "$original_lib_path")
194-
install_name_tool -change "$original_lib_path" "@executable_path/$lib_name" "$EXE_PATH"
195-
done
196-
for copied_lib_path in "$LIBS_DEST_DIR"/lib*.dylib; do
197-
copied_lib_name=$(basename "$copied_lib_path")
198-
install_name_tool -id "@executable_path/$copied_lib_name" "$copied_lib_path"
199-
for original_lib_path in "${UNIQUE_ORIGINAL_PATHS[@]}"; do
200-
original_lib_name=$(basename "$original_lib_path")
201-
install_name_tool -change "$original_lib_path" "@executable_path/$original_lib_name" "$copied_lib_path"
202-
done
203-
done
204-
codesign --force --sign - "$LIBS_DEST_DIR"/lib*.dylib
205-
codesign --force --deep --sign - "$BUNDLE_PATH"
206-
- name: Upload ARM App Bundle
207-
uses: actions/upload-artifact@v4
208-
with:
209-
name: Advancely-v${{ env.PROJECT_VERSION }}-macOS-ARM64-app
210-
path: build/Advancely.app
211-
212-
# Job 4: Combine macOS builds into a universal package
213-
package_universal_macos:
214-
runs-on: macos-latest
215-
needs: [ build_macos_intel, build_macos_arm ]
216-
steps:
217-
- name: Checkout repository
218-
uses: actions/checkout@v4
219-
- name: Install dependencies (macOS)
220-
run: brew install sdl3 sdl3_image sdl3_ttf curl jpeg-xl webp
221-
- name: Configure CMake to get version
222-
run: cmake -B build -DCMAKE_PREFIX_PATH=$(brew --prefix)
223-
- name: Download Intel build
224-
uses: actions/download-artifact@v4
225-
with:
226-
name: Advancely-v${{ env.PROJECT_VERSION }}-macOS-X64-app
227-
path: build-x64/Advancely.app
228-
- name: Download ARM build
229-
uses: actions/download-artifact@v4
230-
with:
231-
name: Advancely-v${{ env.PROJECT_VERSION }}-macOS-ARM64-app
232-
path: build-arm64/Advancely.app
233-
- name: Create Universal App from Bundled Artifacts
234-
shell: bash
235-
run: |
236-
INTEL_APP_PATH="build-x64/Advancely.app"
237-
ARM_APP_PATH="build-arm64/Advancely.app"
238-
UNIVERSAL_APP_PATH="release/Advancely.app"
239-
240-
echo "Setting up universal app structure..."
241-
mkdir -p release/
242-
cp -R "$ARM_APP_PATH" "$UNIVERSAL_APP_PATH"
243-
244-
echo "Creating universal executable..."
245-
lipo -create -output "$UNIVERSAL_APP_PATH/Contents/MacOS/Advancely" \
246-
"$INTEL_APP_PATH/Contents/MacOS/Advancely" \
247-
"$ARM_APP_PATH/Contents/MacOS/Advancely"
248-
249-
echo "Creating universal libraries..."
250-
ARM_LIBS_DIR="$UNIVERSAL_APP_PATH/Contents/MacOS"
251-
INTEL_LIBS_DIR="$INTEL_APP_PATH/Contents/MacOS"
252-
253-
for arm_lib_path in $(find "$ARM_LIBS_DIR" -name "*.dylib"); do
254-
lib_name=$(basename "$arm_lib_path")
255-
intel_lib_path="$INTEL_LIBS_DIR/$lib_name"
256-
if [ -f "$intel_lib_path" ]; then
257-
echo "Merging $lib_name..."
258-
lipo -create -output "$arm_lib_path" "$arm_lib_path" "$intel_lib_path"
259-
else
260-
echo "Warning: Could not find matching Intel library for $lib_name."
261-
fi
262-
done
263-
264-
echo "Codesigning final application..."
265-
codesign --force --sign - "$UNIVERSAL_APP_PATH/Contents/MacOS/"*.dylib
266-
codesign --force --deep --sign - "$UNIVERSAL_APP_PATH"
267-
268-
# Set execute permission AFTER codesigning
269-
chmod +x "$UNIVERSAL_APP_PATH/Contents/MacOS/Advancely"
270-
271-
# Debug permissions before uploading
272-
echo "Verifying permissions before upload:"
273-
ls -l "$UNIVERSAL_APP_PATH/Contents/MacOS/Advancely"
274-
- name: Assemble Final Release Package
275-
shell: bash
276-
run: |
277-
cp -r resources release/
278-
cp _PLEASE_READ_ME.txt LICENSES.txt README.md release/
279-
280-
# Manually zip it
281-
- name: Create Zip Archive
282-
shell: bash
283-
run: |
284-
cd release
285-
zip -r ../Advancely-Universal.zip .
286-
287-
- name: Upload Universal macOS Artifact
288-
uses: actions/upload-artifact@v4
289-
with:
290-
name: Advancely-v${{ env.PROJECT_VERSION }}-macOS-Universal
291-
path: Advancely-Universal.zip # Taking the zip file
292-
293-
# Job 5: Test the Universal macOS package
294-
test_universal_macos:
295-
runs-on: macos-latest
296-
needs: [ package_universal_macos ]
297-
steps:
298-
- name: Checkout repository
299-
uses: actions/checkout@v4
300-
- name: Install dependencies (macOS)
301-
run: brew install sdl3 sdl3_image sdl3_ttf curl jpeg-xl webp
302-
- name: Configure CMake to get version
303-
run: cmake -B build -DCMAKE_PREFIX_PATH=$(brew --prefix)
304-
- name: Download Universal macOS Artifact
305-
uses: actions/download-artifact@v4
306-
with:
307-
name: Advancely-v${{ env.PROJECT_VERSION }}-macOS-Universal
308-
# path: universal-build/ # Not needed
309-
# Extracting zip
310-
- name: Extract Zip Archive
311-
run: unzip -o Advancely-Universal.zip
312-
313-
- name: Install gtimeout (GNU Coreutils)
314-
run: brew install coreutils
315-
316-
- name: Run Executable Test (macOS Universal)
317-
run: |
318-
# Debug permissions after downloading
319-
echo "Verifying permissions after download:"
320-
ls -l ./Advancely.app/Contents/MacOS/Advancely
321-
322-
echo "Running universal executable for 5 seconds..."
323-
# The path no longer has 'universal-build/' in it
324-
gtimeout 5s ./Advancely.app/Contents/MacOS/Advancely --test-mode > output.txt 2>&1 || true
325-
echo "Executable run finished. Contents of output.txt:"
326-
cat output.txt
327-
- name: Upload Test Output (macOS Universal)
328-
uses: actions/upload-artifact@v4
329-
with:
330-
name: test-output-v${{ env.PROJECT_VERSION }}-macOS-Universal
331-
path: output.txt

0 commit comments

Comments
 (0)