Skip to content

Commit

Permalink
updated mac build
Browse files Browse the repository at this point in the history
  • Loading branch information
labbots committed May 28, 2024
1 parent 9d048c0 commit 80c0309
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/_build-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ jobs:
run: poetry run pyinstaller spec_files/ui_app/NiimPrintX-mac.spec --noconfirm --clean

- name: Avoid a race condition in cpack
if: inputs.os == 'macos-13'
if: ${{ inputs.os == 'macos-13' }}
run: |
# TODO: Replace this with a better solution
# See https://github.com/actions/runner-images/issues/7522
echo Killing XProtect...; sudo pkill -9 XProtect >/dev/null || true;
echo Waiting for XProtect process...; while pgrep XProtect; do sleep 3; done;
echo "Killing XProtect processes..."
sudo pkill -9 XProtect || true
echo "Waiting for XProtect processes to terminate..."
while pgrep XProtect; do sleep 5; done
echo "XProtect processes terminated."
- name: Create DMG package
run: ./.github/workflows/mac-dmg-builder.sh "${{ steps.get_tag_name.outputs.VERSION }}" "${{ steps.get_architecture.outputs.ARCH }}"
Expand Down
45 changes: 30 additions & 15 deletions .github/workflows/mac-dmg-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,34 @@ fi
# Since create-dmg does not clobber, be sure to delete previous DMG
[[ -f "${DMG_FILE_NAME}" ]] && rm "${DMG_FILE_NAME}"

echo killing...; sudo pkill -9 XProtect >/dev/null || true;
echo waiting...; while pgrep XProtect; do sleep 3; done;
# Function to kill and wait for XProtect processes
kill_xprotect() {
echo "Killing XProtect processes..."
sudo pkill -9 XProtect || true
echo "Waiting for XProtect processes to terminate..."
while pgrep XProtect; do sleep 5; done
echo "XProtect processes terminated."
}


# Create the DMG
sudo create-dmg \
--volname "${VOLUME_NAME}" \
--background "../assets/images/niimprintx-background.png" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "${APP_NAME}.app" 200 190 \
--hide-extension "${APP_NAME}.app" \
--app-drop-link 600 185 \
--no-internet-enable \
--hdiutil-verbose \
"${DMG_FILE_NAME}" \
"${SOURCE_FOLDER_PATH}"
# Retry logic to handle resource busy error
for i in {1..5}; do
kill_xprotect
sudo create-dmg \
--volname "${VOLUME_NAME}" \
--background "../assets/images/niimprintx-background.png" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "${APP_NAME}.app" 200 190 \
--hide-extension "${APP_NAME}.app" \
--app-drop-link 600 185 \
--no-internet-enable \
--hdiutil-verbose \
"${DMG_FILE_NAME}" \
"${SOURCE_FOLDER_PATH}" && break

echo "Attempt $i: Resource busy, retrying in 5 seconds..."
sleep 5
done

0 comments on commit 80c0309

Please sign in to comment.