Skip to content

Commit

Permalink
Create a DMG for Mac Monoscopic (#625)
Browse files Browse the repository at this point in the history
* Create DMG and notarize it

* Move Support/ to OpenBrush*.app/Contents/ on Mac

* Remove empty Contents/PlugIns/UnityFbxSdkNative.bundle directory

* Add a gradient so text lanels are more readable

---------

Co-authored-by: Andy Baker <andy@andybak.net>
  • Loading branch information
mikeage and andybak committed Feb 24, 2024
1 parent 9936916 commit 9c611fa
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 8 deletions.
111 changes: 109 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ jobs:
- name: Prepare for packaging (permissions and compression, OSX only)
if: matrix.targetPlatform == 'StandaloneOSX'
run: |
mv build/${{ matrix.vrsdk }}/${{ matrix.targetPlatform }}/Support "build/${{ matrix.vrsdk }}/${{ matrix.targetPlatform }}/${{ env.filename }}/Contents/"
find build -name 'UnityFbxSdkNative.bundle' -delete
# Compress, but skip the top directories
tar -c -v -z -f OpenBrush.tgz -C build/${{ matrix.vrsdk }} ${{ matrix.targetPlatform}}
rm -rf build/${{ matrix.vrsdk }}/*
Expand Down Expand Up @@ -561,9 +563,107 @@ jobs:
# Some platforms share a cache; it's not a 1:1 mapping of either targetPlatform or vrsdk, so we have a distinct variable for which cache to use
key: Library_${{ matrix.cache }}_${{ env.UNITY_VERSION }}

createdmg:
name: Create and Notarize DMG
needs: [configuration, build]
if: |
github.event_name == 'push' &&
github.repository == 'icosa-foundation/open-brush' &&
(github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
runs-on: macos-latest # the ovr-platform-util tool is only available for Mac and Windows
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true # We don't use LFS, but it adds no time, and leave it here in case we do at some point later
sparse-checkout: |
Support/macos
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: MacOS Monoscopic
path: build_macos_monoscopic

# See https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_BUILD_CERTIFICATE_BASE64 }}
INSTALL_CERTIFICATE_BASE64: ${{ secrets.APPLE_INSTALL_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.APPLE_P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.APPLE_BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
run: |
BUILD_CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
INSTALL_CERTIFICATE_PATH=$RUNNER_TEMP/install_certificate.p12
PP_PATH=$RUNNER_TEMP/openbrushmac.provisionprofile
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $BUILD_CERTIFICATE_PATH
echo -n "$INSTALL_CERTIFICATE_BASE64" | base64 --decode -o $INSTALL_CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $BUILD_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security import $INSTALL_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Sign the release
env:
VERSION: ${{ needs.configuration.outputs.version }}
run: |
tar xvfz build_macos_monoscopic/*tgz
export FILENAME=$(basename $(readlink -f StandaloneOSX/OpenBrush*.app))
cd StandaloneOSX/
codesign --deep --force --verify --verbose --timestamp --options runtime --entitlements ../Support/macos/OpenBrush.entitlements --sign "Developer ID Application: Icosa Gallery Ltd (${{ secrets.APPLE_TEAM_ID }})" $FILENAME/Contents/Support/ThirdParty/ffmpeg/bin/ffmpeg
codesign --deep --force --verify --verbose --timestamp --options runtime --entitlements ../Support/macos/OpenBrush.entitlements --sign "Developer ID Application: Icosa Gallery Ltd (${{ secrets.APPLE_TEAM_ID }})" $FILENAME
- name: Create a notarized DMG
env:
VERSION: ${{ needs.configuration.outputs.version }}
run: |
export FILENAME=$(basename $(readlink -f StandaloneOSX/OpenBrush*.app))
mkdir dist
cp Support/macos/background.png StandaloneOSX/
cp Support/macos/background@2x.png StandaloneOSX/
pip install jinjanator
jinjanate Support/macos/openbrush-dmg.json.j2 > StandaloneOSX/openbrush-dmg.json
pushd StandaloneOSX/
npx appdmg openbrush-dmg.json ../dist/OpenBrush.dmg
popd
xcrun notarytool submit \
--team-id ${{ secrets.APPLE_TEAM_ID }} \
--apple-id ${{ secrets.APPLE_ID }} \
--password ${{ secrets.APPLE_APPLICATION_SPECIFIC_PASSWORD }} \
--wait \
dist/OpenBrush.dmg
xcrun stapler staple dist/OpenBrush.dmg
- name: Upload notarized dmg
uses: actions/upload-artifact@v4
with:
name: MacOS Monoscopic (DMG)
path: |
dist/OpenBrush.dmg
release:
name: Create Github Release
needs: [configuration, build]
needs: [configuration, build, createdmg]
runs-on: ubuntu-latest
if: |
github.event_name == 'push' &&
Expand Down Expand Up @@ -645,6 +745,12 @@ jobs:
name: Android Pico
path: build_android_pico

- name: Download Build Artifacts (Mac)
uses: actions/download-artifact@v4
with:
name: MacOS Monoscopic (DMG)
path: build_monoscopic_macos

- name: Package Artifacts for release
env:
VERSION: ${{ needs.configuration.outputs.version }}
Expand All @@ -656,6 +762,7 @@ jobs:
mv build_windows_openxr/StandaloneWindows64/ releases/OpenBrush_Desktop_$VERSION/
mv build_windows_rift/StandaloneWindows64/ releases/OpenBrush_Rift_$VERSION/
mv build_windows_mono/StandaloneWindows64/ releases/OpenBrush_Mono_$VERSION/
mv build_monoscopic_macos/*.dmg releases/OpenBrush_Mac_Mono_$VERSION.dmg
cd releases
zip -r OpenBrush_Desktop_$VERSION.zip OpenBrush_Desktop_$VERSION/
zip -r OpenBrush_Rift_$VERSION.zip OpenBrush_Rift_$VERSION/
Expand Down Expand Up @@ -740,7 +847,7 @@ jobs:

publish_steam:
name: Publish Steam Release
needs: [configuration, build]
needs: [configuration, build, createdmg]
if: |
github.event_name == 'push' &&
github.repository == 'icosa-foundation/open-brush' &&
Expand Down
8 changes: 2 additions & 6 deletions Assets/Scripts/Rendering/FfmpegPipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,10 @@ class FfmpegPipe

public static string GetFfmpegExe()
{
// Editor, Mac builds and Windows builds have different paths
// Editor and Windows builds have different paths
// between Application.dataPath and the actual executable
string traverseToApp = "";
if (Application.platform == RuntimePlatform.OSXPlayer)
{
traverseToApp = "../../";
}
else if (Application.platform == RuntimePlatform.WindowsPlayer || Application.isEditor)
if (Application.platform == RuntimePlatform.WindowsPlayer || Application.isEditor)
{
traverseToApp = "../";
}
Expand Down
10 changes: 10 additions & 0 deletions Support/macos/OpenBrush.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
</dict>
</plist>
Binary file added Support/macos/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Support/macos/background@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions Support/macos/openbrush-dmg.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"title": "Open Brush {{ VERSION }}",
"icon": "{{ FILENAME }}/Contents/Resources/PlayerIcon.icns",
"background": "background.png",
"icon-size": 160,
"format": "ULFO",
"filesystem": "APFS",
"window": {
"size": {
"width": 620,
"height": 349
}
},
"contents": [
{
"x": 160,
"y": 160,
"type": "file",
"path": "{{ FILENAME }}"
},
{
"x": 460,
"y": 160,
"type": "link",
"path": "/Applications"
}
]
}

0 comments on commit 9c611fa

Please sign in to comment.