From 529186880ecaceaffb5593f760a67db2f1162c44 Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 21 Apr 2023 17:38:57 -0500 Subject: [PATCH 1/8] Update ReadMe.md and add workflow dispatch --- .github/workflows/main.yml | 1 + ProjectSettings/RiderScriptEditorPersistedState.asset | 2 +- ReadMe.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c010d1..5797ced 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,7 @@ name: Unity Actions on: pull_request: {} push: {} + workflow_dispatch: {} env: UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} diff --git a/ProjectSettings/RiderScriptEditorPersistedState.asset b/ProjectSettings/RiderScriptEditorPersistedState.asset index f47e027..176d73f 100644 --- a/ProjectSettings/RiderScriptEditorPersistedState.asset +++ b/ProjectSettings/RiderScriptEditorPersistedState.asset @@ -12,4 +12,4 @@ MonoBehaviour: m_Script: {fileID: 0} m_Name: m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState - lastWriteTicks: -8585491470484541603 + lastWriteTicks: -8585194918909323212 diff --git a/ReadMe.md b/ReadMe.md index 44c45c8..4c0478f 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,6 +1,6 @@ # unity-actions example -[![Actions 😎](https://github.com/GabLeRoux/unity-actions-example/workflows/Actions%20%F0%9F%98%8E/badge.svg)](https://github.com/GabLeRoux/unity-actions-example/actions) +[![Unity Actions](https://github.com/game-ci/unity-actions-example/actions/workflows/main.yml/badge.svg)](https://github.com/game-ci/unity-actions-example/actions/workflows/main.yml) Example using unity-actions to test and build a unity project. More information at [game.ci](https://game.ci/) From 50a3b4061497ed4f239ab6ac1ff61c494e3fe9c9 Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 21 Apr 2023 18:22:13 -0500 Subject: [PATCH 2/8] Refactor main workflow --- .github/workflows/main.yml | 83 +++++++++++--------------------------- 1 file changed, 24 insertions(+), 59 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5797ced..3e4d845 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,39 +12,26 @@ env: PROJECT_PATH: . jobs: - checklicense: - name: check if UNITY_LICENSE is set in github secrets - runs-on: ubuntu-latest - outputs: - is_unity_license_set: ${{ steps.checklicense_job.outputs.is_unity_license_set }} - steps: - - name: Check whether unity activation requests should be done - id: checklicense_job - run: | - echo "Skip activation job: ${{ env.UNITY_LICENSE != '' }}" - echo "::set-output name=is_unity_license_set::${{ env.UNITY_LICENSE != '' }}" +### See https://game.ci/docs/github/getting-started activation: - needs: [checklicense] - if: needs.checklicense.outputs.is_unity_license_set == 'false' - name: Request activation file 🔑 + if: ${{ env.UNITY_LICENSE == '' }} + name: Request manual activation file 🔑 runs-on: ubuntu-latest steps: # Request manual activation file - name: Request manual activation file id: getManualLicenseFile - # https://github.com/game-ci/unity-request-activation-file/releases/ uses: game-ci/unity-request-activation-file@v2 # Upload artifact (Unity_v20XX.X.XXXX.alf) - name: Expose as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v2 with: name: ${{ steps.getManualLicenseFile.outputs.filePath }} path: ${{ steps.getManualLicenseFile.outputs.filePath }} test: - needs: [checklicense] - if: needs.checklicense.outputs.is_unity_license_set == 'true' - name: Test all modes ✨ + if: ${{ env.UNITY_LICENSE != '' }} + name: Run all tests ✨ runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -52,26 +39,20 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: Library - key: Library-test-project-${{ matrix.targetPlatform }} - restore-keys: | - Library-test-project- - Library- - # https://github.com/game-ci/unity-test-runner/releases/ + path: ${{ env.projectPath }}/Library + key: Library-test - uses: game-ci/unity-test-runner@v2 id: testRunner with: projectPath: ${{ env.PROJECT_PATH }} - testMode: all - customParameters: "-nographics" + githubToken: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v3 with: name: Test results (all modes) path: ${{ steps.testRunner.outputs.artifactsPath }} build: - needs: [checklicense] - if: needs.checklicense.outputs.is_unity_license_set == 'true' + needs: [test] name: Build for ${{ matrix.targetPlatform }} runs-on: ubuntu-latest strategy: @@ -88,12 +69,8 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} - restore-keys: | - Library-${{ matrix.projectPath }}- - Library- - # https://github.com/game-ci/unity-builder/releases/ + path: ${{ env.projectPath }}/Library + key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 with: projectPath: ${{ env.PROJECT_PATH }} @@ -101,11 +78,10 @@ jobs: - uses: actions/upload-artifact@v3 with: name: Build-${{ matrix.targetPlatform }} - path: build + path: ${{ env.PROJECT_PATH }}/build buildWithMac: - needs: [checklicense] - if: needs.checklicense.outputs.is_unity_license_set == 'true' + needs: [build] name: Build for ${{ matrix.targetPlatform }} runs-on: macos-latest strategy: @@ -114,30 +90,24 @@ jobs: targetPlatform: - StandaloneOSX steps: - - name: Checkout Repository - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: lfs: true - uses: actions/cache@v3 with: path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} - restore-keys: | - Library-${{ matrix.projectPath }}- - Library- + key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 with: projectPath: ${{ env.PROJECT_PATH }} targetPlatform: ${{ matrix.targetPlatform }} - - name: Upload Build - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v3 with: name: Build-${{ matrix.targetPlatform }} - path: build + path: ${{ env.PROJECT_PATH }}/build buildWithWindows: - needs: [build, buildWithMac] - if: needs.checklicense.outputs.is_unity_license_set == 'true' + needs: [buildWithMac] name: Build for ${{ matrix.targetPlatform }} runs-on: windows-2019 strategy: @@ -148,23 +118,18 @@ jobs: - StandaloneWindows64 - WSAPlayer steps: - - name: Checkout Repository - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: lfs: true - uses: actions/cache@v3 with: - path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} - restore-keys: | - Library-${{ matrix.projectPath }}- - Library- + path: ${{ env.projectPath }}/Library + key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 with: projectPath: ${{ env.PROJECT_PATH }} targetPlatform: ${{ matrix.targetPlatform }} - - name: Upload Build - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v3 with: name: Build-${{ matrix.targetPlatform }} - path: build + path: ${{ env.PROJECT_PATH }}/build From 916f5c617cc7832a1d85d1c4127ad2a0fe6d6d45 Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 21 Apr 2023 18:39:45 -0500 Subject: [PATCH 3/8] Refactor main workflow --- .github/workflows/main.yml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e4d845..5b35a87 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,9 +12,22 @@ env: PROJECT_PATH: . jobs: -### See https://game.ci/docs/github/getting-started + checklicense: + name: Check for UNITY_LICENSE in GitHub Secrets + runs-on: ubuntu-latest + outputs: + is_unity_license_set: ${{ steps.checklicense_job.outputs.is_unity_license_set }} + steps: + - name: Check whether unity activation requests should be done + id: checklicense_job + run: | + echo "Skip activation job: ${{ env.UNITY_LICENSE != '' }}" + export is_unity_license_set="${{ env.UNITY_LICENSE != '' }}" + echo "is_unity_license_set=$is_unity_license_set" >> $GITHUB_OUTPUT + activation: - if: ${{ env.UNITY_LICENSE == '' }} + needs: [checklicense] + if: needs.checklicense.outputs.is_unity_license_set == 'false' name: Request manual activation file 🔑 runs-on: ubuntu-latest steps: @@ -30,7 +43,8 @@ jobs: path: ${{ steps.getManualLicenseFile.outputs.filePath }} test: - if: ${{ env.UNITY_LICENSE != '' }} + needs: [checklicense] + if: needs.checklicense.outputs.is_unity_license_set == 'true' name: Run all tests ✨ runs-on: ubuntu-latest steps: @@ -39,7 +53,7 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ env.projectPath }}/Library + path: ${{ env.PROJECT_PATH }}/Library key: Library-test - uses: game-ci/unity-test-runner@v2 id: testRunner @@ -69,7 +83,7 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ env.projectPath }}/Library + path: ${{ env.PROJECT_PATH }}/Library key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 with: @@ -95,7 +109,7 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ matrix.projectPath }}/Library + path: ${{ env.PROJECT_PATH }}/Library key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 with: @@ -123,7 +137,7 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ env.projectPath }}/Library + path: ${{ env.PROJECT_PATH }}/Library key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 with: From 75deb2d5a96350f2114966837d98b99a3c500665 Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 21 Apr 2023 18:46:07 -0500 Subject: [PATCH 4/8] Refactor main workflow --- .github/workflows/main.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b35a87..69a5ac5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,14 +5,10 @@ on: push: {} workflow_dispatch: {} -env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - PROJECT_PATH: . - jobs: checklicense: + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} name: Check for UNITY_LICENSE in GitHub Secrets runs-on: ubuntu-latest outputs: @@ -47,6 +43,11 @@ jobs: if: needs.checklicense.outputs.is_unity_license_set == 'true' name: Run all tests ✨ runs-on: ubuntu-latest + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + PROJECT_PATH: . steps: - uses: actions/checkout@v3 with: @@ -69,6 +70,11 @@ jobs: needs: [test] name: Build for ${{ matrix.targetPlatform }} runs-on: ubuntu-latest + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + PROJECT_PATH: . strategy: fail-fast: false matrix: @@ -98,6 +104,11 @@ jobs: needs: [build] name: Build for ${{ matrix.targetPlatform }} runs-on: macos-latest + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + PROJECT_PATH: . strategy: fail-fast: false matrix: @@ -124,6 +135,11 @@ jobs: needs: [buildWithMac] name: Build for ${{ matrix.targetPlatform }} runs-on: windows-2019 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + PROJECT_PATH: . strategy: fail-fast: false matrix: From 3685430cb119c361c7032afb9f04ae9af97e9113 Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 21 Apr 2023 18:54:58 -0500 Subject: [PATCH 5/8] Refactor main workflow --- .github/workflows/main.yml | 61 +++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 69a5ac5..52eeb5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,10 +5,9 @@ on: push: {} workflow_dispatch: {} +### Refer to https://game.ci/docs/github/getting-started jobs: checklicense: - env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} name: Check for UNITY_LICENSE in GitHub Secrets runs-on: ubuntu-latest outputs: @@ -16,6 +15,10 @@ jobs: steps: - name: Check whether unity activation requests should be done id: checklicense_job + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} run: | echo "Skip activation job: ${{ env.UNITY_LICENSE != '' }}" export is_unity_license_set="${{ env.UNITY_LICENSE != '' }}" @@ -43,23 +46,21 @@ jobs: if: needs.checklicense.outputs.is_unity_license_set == 'true' name: Run all tests ✨ runs-on: ubuntu-latest - env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - PROJECT_PATH: . steps: - uses: actions/checkout@v3 with: lfs: true - uses: actions/cache@v3 with: - path: ${{ env.PROJECT_PATH }}/Library + path: Library key: Library-test - uses: game-ci/unity-test-runner@v2 id: testRunner + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: - projectPath: ${{ env.PROJECT_PATH }} githubToken: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v3 with: @@ -70,11 +71,6 @@ jobs: needs: [test] name: Build for ${{ matrix.targetPlatform }} runs-on: ubuntu-latest - env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - PROJECT_PATH: . strategy: fail-fast: false matrix: @@ -89,26 +85,24 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ env.PROJECT_PATH }}/Library + path: Library key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: - projectPath: ${{ env.PROJECT_PATH }} targetPlatform: ${{ matrix.targetPlatform }} - uses: actions/upload-artifact@v3 with: name: Build-${{ matrix.targetPlatform }} - path: ${{ env.PROJECT_PATH }}/build + path: build buildWithMac: needs: [build] name: Build for ${{ matrix.targetPlatform }} runs-on: macos-latest - env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - PROJECT_PATH: . strategy: fail-fast: false matrix: @@ -120,26 +114,24 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ env.PROJECT_PATH }}/Library + path: Library key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: - projectPath: ${{ env.PROJECT_PATH }} targetPlatform: ${{ matrix.targetPlatform }} - uses: actions/upload-artifact@v3 with: name: Build-${{ matrix.targetPlatform }} - path: ${{ env.PROJECT_PATH }}/build + path: build buildWithWindows: needs: [buildWithMac] name: Build for ${{ matrix.targetPlatform }} runs-on: windows-2019 - env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - PROJECT_PATH: . strategy: fail-fast: false matrix: @@ -153,13 +145,16 @@ jobs: lfs: true - uses: actions/cache@v3 with: - path: ${{ env.PROJECT_PATH }}/Library + path: Library key: Library-${{ matrix.targetPlatform }} - uses: game-ci/unity-builder@v2 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: - projectPath: ${{ env.PROJECT_PATH }} targetPlatform: ${{ matrix.targetPlatform }} - uses: actions/upload-artifact@v3 with: name: Build-${{ matrix.targetPlatform }} - path: ${{ env.PROJECT_PATH }}/build + path: build From 1dff1659f480c74e1c14bc8948a6f9ba06f11f1f Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 21 Apr 2023 18:59:22 -0500 Subject: [PATCH 6/8] Refactor main workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 52eeb5e..eec2ee5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: uses: game-ci/unity-request-activation-file@v2 # Upload artifact (Unity_v20XX.X.XXXX.alf) - name: Expose as artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ steps.getManualLicenseFile.outputs.filePath }} path: ${{ steps.getManualLicenseFile.outputs.filePath }} From 5b853f4aaa344f78d2aeea52ba27095ff5a50bcc Mon Sep 17 00:00:00 2001 From: David Finol Date: Fri, 21 Apr 2023 22:24:31 -0500 Subject: [PATCH 7/8] Split windows builds --- .github/workflows/main.yml | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eec2ee5..b0af6d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,15 +129,13 @@ jobs: path: build buildWithWindows: - needs: [buildWithMac] + needs: [build] name: Build for ${{ matrix.targetPlatform }} runs-on: windows-2019 strategy: fail-fast: false matrix: targetPlatform: - - StandaloneWindows - - StandaloneWindows64 - WSAPlayer steps: - uses: actions/checkout@v3 @@ -158,3 +156,33 @@ jobs: with: name: Build-${{ matrix.targetPlatform }} path: build + + buildWithWindows2: + needs: [buildWithWindows] + name: Build for ${{ matrix.targetPlatform }} + runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + targetPlatform: + - StandaloneWindows + - StandaloneWindows64 + steps: + - uses: actions/checkout@v3 + with: + lfs: true + - uses: actions/cache@v3 + with: + path: Library + key: Library-${{ matrix.targetPlatform }} + - uses: game-ci/unity-builder@v2 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} + with: + targetPlatform: ${{ matrix.targetPlatform }} + - uses: actions/upload-artifact@v3 + with: + name: Build-${{ matrix.targetPlatform }} + path: build From d83d8cbd0bbf230d63de38b4c29ee62ef456542d Mon Sep 17 00:00:00 2001 From: David Finol Date: Sat, 22 Apr 2023 08:40:03 -0500 Subject: [PATCH 8/8] Apply suggestions from code review Co-authored-by: Webber Takken --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b0af6d9..7d7111f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,7 +129,7 @@ jobs: path: build buildWithWindows: - needs: [build] + needs: build name: Build for ${{ matrix.targetPlatform }} runs-on: windows-2019 strategy: @@ -158,7 +158,7 @@ jobs: path: build buildWithWindows2: - needs: [buildWithWindows] + needs: buildWithWindows name: Build for ${{ matrix.targetPlatform }} runs-on: windows-2019 strategy: