Refactor main workflow

This commit is contained in:
David Finol 2023-04-21 18:22:13 -05:00
parent 529186880e
commit 50a3b40614

View File

@ -12,39 +12,26 @@ env:
PROJECT_PATH: . PROJECT_PATH: .
jobs: jobs:
checklicense: ### See https://game.ci/docs/github/getting-started
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 != '' }}"
activation: activation:
needs: [checklicense] if: ${{ env.UNITY_LICENSE == '' }}
if: needs.checklicense.outputs.is_unity_license_set == 'false' name: Request manual activation file 🔑
name: Request activation file 🔑
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# Request manual activation file # Request manual activation file
- name: Request manual activation file - name: Request manual activation file
id: getManualLicenseFile id: getManualLicenseFile
# https://github.com/game-ci/unity-request-activation-file/releases/
uses: game-ci/unity-request-activation-file@v2 uses: game-ci/unity-request-activation-file@v2
# Upload artifact (Unity_v20XX.X.XXXX.alf) # Upload artifact (Unity_v20XX.X.XXXX.alf)
- name: Expose as artifact - name: Expose as artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v2
with: with:
name: ${{ steps.getManualLicenseFile.outputs.filePath }} name: ${{ steps.getManualLicenseFile.outputs.filePath }}
path: ${{ steps.getManualLicenseFile.outputs.filePath }} path: ${{ steps.getManualLicenseFile.outputs.filePath }}
test: test:
needs: [checklicense] if: ${{ env.UNITY_LICENSE != '' }}
if: needs.checklicense.outputs.is_unity_license_set == 'true' name: Run all tests ✨
name: Test all modes ✨
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -52,26 +39,20 @@ jobs:
lfs: true lfs: true
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: Library path: ${{ env.projectPath }}/Library
key: Library-test-project-${{ matrix.targetPlatform }} key: Library-test
restore-keys: |
Library-test-project-
Library-
# https://github.com/game-ci/unity-test-runner/releases/
- uses: game-ci/unity-test-runner@v2 - uses: game-ci/unity-test-runner@v2
id: testRunner id: testRunner
with: with:
projectPath: ${{ env.PROJECT_PATH }} projectPath: ${{ env.PROJECT_PATH }}
testMode: all githubToken: ${{ secrets.GITHUB_TOKEN }}
customParameters: "-nographics"
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: Test results (all modes) name: Test results (all modes)
path: ${{ steps.testRunner.outputs.artifactsPath }} path: ${{ steps.testRunner.outputs.artifactsPath }}
build: build:
needs: [checklicense] needs: [test]
if: needs.checklicense.outputs.is_unity_license_set == 'true'
name: Build for ${{ matrix.targetPlatform }} name: Build for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@ -88,12 +69,8 @@ jobs:
lfs: true lfs: true
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ env.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
# https://github.com/game-ci/unity-builder/releases/
- uses: game-ci/unity-builder@v2 - uses: game-ci/unity-builder@v2
with: with:
projectPath: ${{ env.PROJECT_PATH }} projectPath: ${{ env.PROJECT_PATH }}
@ -101,11 +78,10 @@ jobs:
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: Build-${{ matrix.targetPlatform }} name: Build-${{ matrix.targetPlatform }}
path: build path: ${{ env.PROJECT_PATH }}/build
buildWithMac: buildWithMac:
needs: [checklicense] needs: [build]
if: needs.checklicense.outputs.is_unity_license_set == 'true'
name: Build for ${{ matrix.targetPlatform }} name: Build for ${{ matrix.targetPlatform }}
runs-on: macos-latest runs-on: macos-latest
strategy: strategy:
@ -114,30 +90,24 @@ jobs:
targetPlatform: targetPlatform:
- StandaloneOSX - StandaloneOSX
steps: steps:
- name: Checkout Repository - uses: actions/checkout@v3
uses: actions/checkout@v3
with: with:
lfs: true lfs: true
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
- uses: game-ci/unity-builder@v2 - uses: game-ci/unity-builder@v2
with: with:
projectPath: ${{ env.PROJECT_PATH }} projectPath: ${{ env.PROJECT_PATH }}
targetPlatform: ${{ matrix.targetPlatform }} targetPlatform: ${{ matrix.targetPlatform }}
- name: Upload Build - uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v3
with: with:
name: Build-${{ matrix.targetPlatform }} name: Build-${{ matrix.targetPlatform }}
path: build path: ${{ env.PROJECT_PATH }}/build
buildWithWindows: buildWithWindows:
needs: [build, buildWithMac] needs: [buildWithMac]
if: needs.checklicense.outputs.is_unity_license_set == 'true'
name: Build for ${{ matrix.targetPlatform }} name: Build for ${{ matrix.targetPlatform }}
runs-on: windows-2019 runs-on: windows-2019
strategy: strategy:
@ -148,23 +118,18 @@ jobs:
- StandaloneWindows64 - StandaloneWindows64
- WSAPlayer - WSAPlayer
steps: steps:
- name: Checkout Repository - uses: actions/checkout@v3
uses: actions/checkout@v3
with: with:
lfs: true lfs: true
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: ${{ matrix.projectPath }}/Library path: ${{ env.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }} key: Library-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
- uses: game-ci/unity-builder@v2 - uses: game-ci/unity-builder@v2
with: with:
projectPath: ${{ env.PROJECT_PATH }} projectPath: ${{ env.PROJECT_PATH }}
targetPlatform: ${{ matrix.targetPlatform }} targetPlatform: ${{ matrix.targetPlatform }}
- name: Upload Build - uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v3
with: with:
name: Build-${{ matrix.targetPlatform }} name: Build-${{ matrix.targetPlatform }}
path: build path: ${{ env.PROJECT_PATH }}/build