From 84ffc9ec28e63af7854c4ed28c11b48ecc9b37ee Mon Sep 17 00:00:00 2001 From: Panto! Date: Mon, 15 May 2023 17:25:22 -0300 Subject: [PATCH] Github Actions for building and packing macOS executables (#330) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: browse button not working on standalone mac Apparently, the last official update for the StandaloneFileBrowser was in 2018, before the adoption from Apple to AppleSilicon in 2021. Because of this, it creates a bug when creating a universal build on Unity (Intel + AppleSilicon) making the "Browse" button from the song folder manager not work anymore. This replaces the current StandaloneFileBrowser.bundle and uses a .bundle (+ .meta) created by tonidurans that has added support to AppleSilicon Tested using an Intel-based machine running an Intel + Apple Silicon (universal) build. Still need testing for Apple Silicon. tldr: i just grabbed the .bundle + .meta from this pr (https://github.com/gkngkc/UnityStandaloneFileBrowser/pull/116) and put on the project and now it works 👍 * Update Credits.txt * feat(workflow): request manual activation file * feat(workflow): setup builder * chore(workflow): disable linux test (for now) * chore: remove build.yml + feat: build-mac.yml (12-core) * chore(workflow/mac-builder): remove need for 12-core machine got carried away and got long pickup line * feat(workflow/mac-builder): enable caching workflow takes 15 MINUTES JUST FOR INSTALLING UNITY * fix(workflow/mac-builder): wrong build path * fix(workflow/mac-builder): install missing library * chore(workflow/mac-builder): use latest version for unity-builder * feat(workflow/mac-builder): add names for unamed jobs * feat(workflow/mac-builder): restore nuget packages * fix(workflow/mac-builder): remove double-quotes * test(workflow/mac-builder): check what dotnet version is installed * feat(workflow/mac-builder): merge python commands * ok i don't know how to use it * chore(workflow/mac-builder): change unity-builder version to 2.2.0 * feat(workflow/mac-builder): enable continue-on-error on builder job * chore(workflow/mac-builder): remove python installation it already comes installed in apparently * feat(workflow/mac-builder): merge nuget commands * feat(workflow/mac-builder): add blender installation * fix(workflow/mac-version): using wrong python version * chore(workflow/mac-builder): install an older blender version (3.4.1) * feat(workflow/mac-builder): add compress file * chore(workflow): change mac workflow file name * fix(workflow/mac-builder): use another compressor method * chore(workflow/mac-builder): remove concurrency cancel-in-progress * feat(workflow/mac-builder): add quarantine command * fix(workflow/mac-builder): run quarantine as sudo * chore(workflow/mac-builder): remove quarantine command * feat(workflow/mac-builder): create dmg * fix(workflow/mac-builder): fix wrong extension * chore(workflow/mac-builder): remove retention-days * fix(workflow/mac-builder): missing && on commands end * feat(workflow/mac-builder): add continue-on-error on create dmg * fix(workflow/mac-builder): separate rename dmg to a different job * Revert "feat(workflow/mac-builder): create dmg" Revert "feat(workflow/mac-builder): create dmg" This reverts commit 0bc0e4cd50e530d39d85fd4d26eacd204507b100. * feat(workflow/mac-builder): add caching to git lts * fix(workflow/mac-builder): fix wrong extension (2) * feat(workflow/mac-builder): add caching to blender * fix(workflow/mac-builder): blender cache missing folder * fix(workflow/mac-builder): wrong blenderinstall folder * feat(workflow/mac-builder): add commit blenderinstall * chore(workflow/mac-builder): enable dirty build * fix(workflow/mac-builder): wrong blenderinstall folder * fix(workflow/mac-builder): remove git reset * feat(workflow/mac-builder): remove lfs cache maybe this is causing some errors on build * feat(workflow/mac-builder): add inputs to workflow_dispatch * feat(workflow/mac-builder): change from choice to boolean * feat(workflow/mac-builder): move blenderinstall to temp/ folder * fix(workflow/mac-builder): temp folder not existing when creating blenderinstall folder * feat(workflow/mac-builder): remove write access to blender.dmg after install * feat(workflow/mac-builder): move blenderinstall to runner.temp * feat(workflow/mac-builder): remove job matrix * feat(workflow): new mac fixer workflow * temporary commit: check what files on main folder * chore(workflow/macbuild-fix): change getLatestRelease package * chore(workflow/macbuild-fix): fix find and unzip command * fix(workflow/macbuild-fix): specify type on find and unzip command * chore(workflow/macbuild-fix): remove unzip command * fix(workflow/macbuild-fix): wrong zip destination * chore(workflow/macbuild-fix): remove temporary "ls" command * fix(workflow/macbuild-fix): reorder permission steps * chore(workflow/macbuild-fix): change exec to execdir * chore(workflow/macbuild-fix): remove -print * (workflow/macbuild-fix): remove check for xattr * (workflow/macbuild-fix): apply permission recursivly * feat(workflow/macbuild-fix): add .tar.bz2 type * feat(workflow/macbuild-fix): add quarantine command * feat(workflow/mac-builder): add .tar.bz2 option * fix(workflow/mac-builder): remove unexpected symbol at end of command * feat(workflow/macbuild-fix): change job name --------- Co-authored-by: EliteAsian --- .github/workflows/activation.yml | 20 +++ .github/workflows/build-release-mac.yml | 159 ++++++++++++++++++++++++ .github/workflows/fix-mac-released.yml | 87 +++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 .github/workflows/activation.yml create mode 100644 .github/workflows/build-release-mac.yml create mode 100644 .github/workflows/fix-mac-released.yml diff --git a/.github/workflows/activation.yml b/.github/workflows/activation.yml new file mode 100644 index 000000000..15a5f662e --- /dev/null +++ b/.github/workflows/activation.yml @@ -0,0 +1,20 @@ +name: Acquire activation file +on: + workflow_dispatch: {} +jobs: + activation: + name: Request manual activation file 🔑 + runs-on: ubuntu-latest + steps: + # Request manual activation file + - name: Request manual activation file + id: getManualLicenseFile + uses: game-ci/unity-request-activation-file@v2 + with: + unityVersion: "2021.3.21f1" + # Upload artifact (Unity_v20XX.X.XXXX.alf) + - name: Expose as artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ steps.getManualLicenseFile.outputs.filePath }} + path: ${{ steps.getManualLicenseFile.outputs.filePath }} \ No newline at end of file diff --git a/.github/workflows/build-release-mac.yml b/.github/workflows/build-release-mac.yml new file mode 100644 index 000000000..acfb742b7 --- /dev/null +++ b/.github/workflows/build-release-mac.yml @@ -0,0 +1,159 @@ +name: Builds - MacOS (release) + +on: + workflow_dispatch: + inputs: + version: + description: "Version (x.xx.x)" + required: true + type: string + createZip: + description: "Create .zip file" + default: true + type: boolean + createTar: + description: "Create .tar.bz2 file" + default: true + type: boolean + createDmg: + description: "Create .dmg file" + default: true + type: boolean + +# concurrency: +# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} +# cancel-in-progress: true + +jobs: + macBuilder: + name: Mac Build for v${{ inputs.version }} + runs-on: macos-latest + + steps: + ########################### + # Checkout # + ########################### + - name: "[Pre-install] Pull project" + uses: actions/checkout@v3 + with: + lfs: true + + ########################### + # Cache # + ########################### + - name: "[Pre-install] Restore 'library' cache" + uses: actions/cache@v3 + with: + path: Library + key: YARG-Library-macos-StandaloneOSX + restore-keys: | + YARG-Library-macos- + YARG-Library- + + ########################### + # Install Blender # + ########################### + + + - name: "[Pre-install] Get Blender (3.4.1) from cache" + id: blender + uses: actions/cache@v3 + with: + path: ${{ runner.temp }}/BlenderInstall + key: blender-3.4.1 + restore-keys: blender- + + - if: ${{ steps.blender.outputs.cache-hit != 'true' }} + name: "[Pre-install] Download Blender (3.4.1)" + continue-on-error: true + run: mkdir ${{ runner.temp }}/BlenderInstall && curl -L -o "${{ runner.temp }}/BlenderInstall/blender.dmg" https://download.blender.org/release/Blender3.4/blender-3.4.1-macos-x64.dmg + + # - name: "[Pre-install] Install Blender" + # run: brew install --cask blender + + - name: "[Pre-install] Install Blender (3.4.1)" + run: > + hdiutil attach ${{ runner.temp }}/BlenderInstall/blender.dmg && + cp -R /Volumes/Blender/Blender.app /Applications && + hdiutil unmount /Volumes/Blender + + ########################### + # Install Libraries # + ########################### + - name: "[Pre-install] Install Libraries" + run: pip3 install requests && python3 InstallLibraries/install.py + + ########################### + # Restore Packages # + ########################### + - name: "[Pre-install] Restoring NuGet Packages" + run: dotnet tool install --global NuGetForUnity.Cli && nugetforunity restore + + ########################### + # Build # + ########################### + - name: "[Build] Run Builder" + uses: game-ci/unity-builder@v2.2.0 + continue-on-error: true + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + with: + buildName: YARG + unityVersion: 2021.3.21f1 + targetPlatform: StandaloneOSX + cacheUnityInstallationOnMac: true + + ########################### + # Compress # + ########################### + - if: ${{ inputs.createZip == true }} + name: "[Post-build] Compress to a .zip" + run: ditto -c -k --keepParent build/StandaloneOSX/YARG.app YARG_v${{ inputs.version }}-MacOS-Universal.zip + + - if: ${{ inputs.createZip == true }} + name: "[Post-build] Upload .zip to artifacts" + uses: actions/upload-artifact@v3 + with: + name: YARG_v${{ inputs.version }}-MacOS-Universal.zip + path: YARG_v${{ inputs.version }}-MacOS-Universal.zip + + ########################### + # Compress .tar.bz2 # + ########################### + + - if: ${{ inputs.createTar == true }} + name: "[Post-build] Compress to a .tar.bz2" + run: tar --xattrs -c -j -f YARG_v${{ inputs.version }}-MacOS-Universal.tar.bz2 build/StandaloneOSX/YARG.app + + - if: ${{ inputs.createTar == true }} + name: "[Post-build] Upload .tar.bz2 to artifacts" + uses: actions/upload-artifact@v3 + with: + name: YARG_v${{ inputs.version }}-MacOS-Universal.tar.bz2 + path: YARG_v${{ inputs.version }}-MacOS-Universal.tar.bz2 + + ########################### + # Create .DMG # + ########################### + - if: ${{ inputs.createDmg == true }} + name: "[Post-build] Create .dmg" + continue-on-error: true + run: > + echo "- Installing create-dmg" && + brew install graphicsmagick imagemagick && + npm install --global create-dmg && + echo "- Creating DMG" && + create-dmg build/StandaloneOSX/YARG.app --dmg-title=YARG + + - if: ${{ inputs.createDmg == true }} + name: "[Post-build] Rename .dmg" + run: find . -name *.dmg -print -exec mv {} "YARG_v${{ inputs.version }}-MacOS-Universal.dmg" \; + + - if: ${{ inputs.createDmg == true }} + name: "[Post-build] Upload .dmg to artifacts" + uses: actions/upload-artifact@v3 + with: + name: YARG_v${{ inputs.version }}-MacOS-Universal.dmg + path: YARG_v${{ inputs.version }}-MacOS-Universal.dmg \ No newline at end of file diff --git a/.github/workflows/fix-mac-released.yml b/.github/workflows/fix-mac-released.yml new file mode 100644 index 000000000..c00e3f1e3 --- /dev/null +++ b/.github/workflows/fix-mac-released.yml @@ -0,0 +1,87 @@ +name: Fix macOS permissions on latest released build + +on: + workflow_dispatch: + inputs: + version: + description: "Version (\"vX.XX.X\" or \"latest\")" + default: "latest" + required: true + type: string + createZip: + description: "Create .zip file" + default: true + type: boolean + createTar: + description: "Create .tar.bz2 file" + default: true + type: boolean + createDmg: + description: "Create .dmg file" + default: true + type: boolean + +env: + repository: YARC-Official/YARG + fileName: "*.zip" + extract: true + +jobs: + fixMacBuild: + name: Fixing Mac permissions for ${{ inputs.version }} + runs-on: macos-latest + + steps: + - if: ${{ inputs.version == 'latest' }} + name: Get Latest Release + uses: robinraju/release-downloader@v1.8 + with: + repository: ${{ env.repository }} + fileName: ${{ env.fileName }} + extract: ${{ env.extract }} + token: ${{ secrets.GITHUB_TOKEN }} + latest: true + + - if: ${{ inputs.version != 'latest' }} + name: Get specific release (${{ inputs.version }}) + uses: robinraju/release-downloader@v1.8 + with: + repository: ${{ env.repository }} + fileName: ${{ env.fileName }} + extract: ${{ env.extract }} + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ inputs.version }} + + - name: Fix permissions + run: find . -name *.app -execdir chmod -R +x {}/Contents/MacOS \; + + - name: Fix file attributes + run: find . -name *.app -execdir xattr -cr {} \; -execdir xattr -rd com.apple.quarantine {} \; + + - name: Create Packages folder + run: mkdir Packages + + - if: ${{ inputs.createZip == true }} + name: "Creating .zip" + run: find . -name *.app -execdir ditto -c -k --keepParent {} Packages/{}.zip \; + + - if: ${{ inputs.createTar == true }} + name: "Creating .tar.bz2" + run: find . -name *.app -execdir tar --xattrs -c -j -f Packages/{}.tar.bz2 {} \; + + - name: "Creating .dmg" + if: ${{ inputs.createDmg == true }} + continue-on-error: true + run: > + echo "- Installing create-dmg" && + brew install graphicsmagick imagemagick && + npm install --global create-dmg && + echo "- Creating DMG" && + find . -name *.app -execdir create-dmg --dmg-title=YARG {} Packages \; + + + - name: "Upload pacakges to artifacts" + uses: actions/upload-artifact@v3 + with: + name: Packages + path: Packages \ No newline at end of file