我已经找到了一个网站(game.ci),它展示了一个运行Github动作工作流的示例,用于构建和测试Unity。
但是,我只能在Ubuntu (“ubuntu-最新”)上找到一个玩具示例。
对于Windows,我需要一个类似的文件。有人能帮我吗?
上下文:
这就是我当前Ubuntu的..github/工作流脚本的样子:
name: Test
on:
workflow_dispatch: {}
jobs:
build:
name: Build my project ✨
runs-on: ubuntu-latest
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v2
with:
lfs: true
# Cache
- uses: actions/cache@v2
with:
path: MyGame/Library
key: MyGame/Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
# Test
- name: Run tests
uses: game-ci/unity-test-runner@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
projectPath: MyGame/
githubToken: ${{ secrets.GITHUB_TOKEN }}
# Build
- name: Build project
uses: game-ci/unity-builder@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
projectPath: MyGame/
targetPlatform: Android
# Output
- uses: actions/upload-artifact@v2
with:
projectPath: MyGame/
name: Build
path: build发布于 2022-11-24 12:35:48
这是一个玩具解决方案的第一个草稿,我可以在一个虚拟的团结项目上成功地运行。
前提条件:
name: Run Tests on Windows
on:
workflow_call:
secrets:
UNITY_EMAIL:
required: true
UNITY_PASSWORD:
required: true
UNITY_TOTP_KEY:
required: true
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Specify path of Unity project relative to repository root
projectPath:
- ./
os:
- windows-2019
unity:
- { version: "2020.3.36f1", changeset: "71f96b79b9f0" }
steps:
# Install UnityHub
- name: Install UnityHub
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install unity-hub -y
# Install UnityEditor
- name: Install UnityEditor
run: |
Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity Hub\Unity Hub.exe" -ArgumentList "-- --headless install --version ${{ matrix.unity.version }} --changeset ${{ matrix.unity.changeset }}"
exit 0
# Generate license activation file
- name: Generate a license activation file
run: |
Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${{ matrix.unity.version }}\Editor\Unity.exe" -ArgumentList "-quit -batchmode -createManualActivationFile -logfile"
exit 0
# Request Unity license
- name: Request a Unity license file
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_TOTP_KEY: ${{ secrets.UNITY_TOTP_KEY }}
continue-on-error: true # Add this line to get pass the error flag
run: |
npm install -g unity-verify-code
git clone -b ci https://github.com/homuler/unity-license-activate.git
cd unity-license-activate
npm install
cd ..
npm install -g ./unity-license-activate
unity-license-activate "$env:UNITY_EMAIL" "$env:UNITY_PASSWORD" Unity_v${{ matrix.unity.version }}.alf --authenticator-key "$env:UNITY_TOTP_KEY"
# # Upload a screenshot (uncomment in case of error in previous step)
# - name: Upload error screenshot
# uses: actions/upload-artifact@v1
# with:
# name: screenshot_error
# path: error.png
# Use license to activate Unity editor
- name: Activate License
run: |
$ulf_file = Get-Item Unity_*.ulf
$process = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${{ matrix.unity.version }}\Editor\Unity.exe" -ArgumentList "-batchmode -nographics -logFile -quit -manualLicenseFile $ulf_file"
if ($process.ExitCode -ne 1)
{
exit $process.ExitCode
}
# Checkout source code
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
# Cache Library folder
- name: Cache Library folder
uses: actions/cache@v2
with:
path: ${{ matrix.projectPath }}/Library
key:
Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{
hashFiles(matrix.projectPath) }}
restore-keys: |
Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-
Library-${{ matrix.projectPath }}-
Library-
# Run Play Mode Tests
- name: Run play mode tests
env:
ARTIFACTS_PATH: testResults
run: |
$process = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${{ matrix.unity.version }}\Editor\Unity.exe" `
-ArgumentList `
"-batchmode -nographics `
-logFile `
-projectPath ${{ matrix.projectPath }} `
-testResults $env:ARTIFACTS_PATH/results.xml `
-runTests `
-testPlatform PlayMode `
-testCategory !GpuOnly;!SignalAbort"
cat ${{ matrix.projectPath }}/$env:ARTIFACTS_PATH/results.xml
exit $process.ExitCode
# Arguments explained:
# - If using '!MyCategory' then no tests with the 'MyCategory' category will be included in the run
# Upload Test results
- name: Upload test results
uses: actions/upload-artifact@v2
if: always()
with:
name: Test results for ${{ matrix.unity.version }} on ${{ matrix.os }}
path: ${{ matrix.projectPath }}\testResults
# Build
# target platform is specified in "Assets/Editor/Scenes/BuildScript.cs"
- name: Build apk
env:
ARTIFACTS_PATH: APKs
run: |
mkdir $env:ARTIFACTS_PATH
$process = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${{ matrix.unity.version }}\Editor\Unity.exe" `
-ArgumentList `
"-batchmode -nographics `
-logFile $env:ARTIFACTS_PATH/build.log `
-projectPath ${{ matrix.projectPath }} `
-executeMethod BuildScript.PerformBuild"
cat ${{ matrix.projectPath }}\$env:ARTIFACTS_PATH\build.log
exit $process.ExitCode
# Upload apk to Github actions
- name: Upload apk to Github actions
uses: actions/upload-artifact@v2
with:
name: APKs
path: APKs这个脚本的要点来自这里 (我不得不使用黑客,因为我不是来自美国)
问题:
https://stackoverflow.com/questions/74434423
复制相似问题