Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update ReadMe.md and add workflow dispatch #14

Merged
merged 8 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 72 additions & 53 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,36 @@ name: Unity Actions
on:
pull_request: {}
push: {}
workflow_dispatch: {}

env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
PROJECT_PATH: .

### Refer to https://game.ci/docs/github/getting-started
jobs:
checklicense:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a job that we recommend? It feels like something you check once on setup rather than incur the cost for every CI run. It also doesn't capture the other complexities like using a serial number or licensing server instead of a license file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I don't think we should recommend that they run this job every time.
On the game.ci docs website, we have activation as a separate workflow.
I think the goal for this repo is just to provide a very concise example, where a user could just clone the repo and quickly get a basic understanding of how to use the unity actions.

name: check if UNITY_LICENSE is set in github secrets
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
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
run: |
echo "Skip activation job: ${{ env.UNITY_LICENSE != '' }}"
echo "::set-output name=is_unity_license_set::${{ env.UNITY_LICENSE != '' }}"
export is_unity_license_set="${{ env.UNITY_LICENSE != '' }}"
echo "is_unity_license_set=$is_unity_license_set" >> $GITHUB_OUTPUT

activation:
needs: [checklicense]
if: needs.checklicense.outputs.is_unity_license_set == 'false'
name: Request activation file 🔑
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
Expand All @@ -43,7 +44,7 @@ jobs:
test:
needs: [checklicense]
if: needs.checklicense.outputs.is_unity_license_set == 'true'
name: Test all modes
name: Run all tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -52,25 +53,22 @@ jobs:
- 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/
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 }}
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:
Expand All @@ -87,24 +85,22 @@ 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: 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: 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:
Expand All @@ -113,30 +109,56 @@ 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-
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 }}
- name: Upload Build
uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v3
with:
name: Build-${{ matrix.targetPlatform }}
path: build

buildWithWindows:
needs: [build, buildWithMac]
if: needs.checklicense.outputs.is_unity_license_set == 'true'
needs: build
name: Build for ${{ matrix.targetPlatform }}
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
targetPlatform:
- WSAPlayer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is WSA player getting a separate workflow from the rest?

Copy link
Member

@GabLeRoux GabLeRoux Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of the runs-on? I'm not sure but I think that's the reason. edit: I scrolled a bit more and now I don't see why either 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember running into the license limitations with my paid license, when I would try running StandaloneWindows, StandaloneWindows64, and WSAPlayer in parallel.
I split off WSAPlayer from the other 2 in my personal workflow to avoid that issue, but maybe that's not necessary for a free license?

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

buildWithWindows2:
needs: buildWithWindows
name: Build for ${{ matrix.targetPlatform }}
runs-on: windows-2019
strategy:
Expand All @@ -145,25 +167,22 @@ jobs:
targetPlatform:
- StandaloneWindows
- 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: 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 }}
- name: Upload Build
uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v3
with:
name: Build-${{ matrix.targetPlatform }}
path: build
2 changes: 1 addition & 1 deletion ProjectSettings/RiderScriptEditorPersistedState.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ MonoBehaviour:
m_Script: {fileID: 0}
m_Name:
m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState
lastWriteTicks: -8585491470484541603
lastWriteTicks: -8585194918909323212
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
@@ -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/)

Expand Down