ã¯ããã«
å æ¥ååã Unity ã® CI ç°å¢ãæ§ç¯ããããã®ã©ã€ãã©ãªã§ãã GameCI ã«ã€ããŠæããŠãããŸãããæ©é GameCI ã® GitHub Actions ãå©çšããŠããµã³ãã«ãããžã§ã¯ãã§è²ã åäœæ€èšŒããŠã¿ããšãããUnity ã® CI ç°å¢ã楜ã«æ§ç¯ã§ããããšãåãããŸããã
ãã¡ãããUnity Cloud Build ãå©çšããã° CI ç°å¢ã®æ§ç¯ã¯ä»¥åãã楜ã«ã§ããŸãããããããéžæè¢ã® 1 ã€ãšã㊠GameCI ãæã£ãŠããããšã§ããµã¯ããš GitHub Actions ã«çµ±åãã圢㧠Unity ã® CI ç°å¢ãå°å ¥ã§ããã®ã¯ä»ã«ã¯ç¡ãã¡ãªãããæããŸããã
æ¬èšäºã§çŽ¹ä»ããŠãããœãŒã¹ã³ãŒããåã³æ€èšŒæã«å©çšãããããžã§ã¯ã㯠GitHub ã«ã¢ããæžã¿ã§ãã®ã§ãæã£åãæ©ãå 容ãææ¡ããããæ¹ã¯äžèšããåç §ãã ãããŸãã
https://github.com/nikaera/Unity-GameCI-Sample
æ¥åã§ãå©çšã§ããããªã®ã§ãGameCI ãå©çšã㊠CI ç°å¢ãæ§ç¯ããæé ãèšäºã§ãŸãšããŸããã
GameCI ã«åãã£ãŠããæ©èœçŽ¹ä»
GameCI ã«ã¯çŸç¶äžèšã® GitHub Actions ãçšæãããŠããããã§ãã
æ©èœ | æŠèŠ |
---|---|
Activation | Unity ã©ã€ã»ã³ã¹ãä»»æã® Unity ããŒãžã§ã³ã§çºè¡ãã |
Test runner | Unity ã® PlayMode åã³ EditMode ã®ãã¹ããå®è¡ãã (ãã¹ãçµæã®åºåã«ã察å¿) |
Builder | ä»»æã® Platform ãã«ããå®è¡ãã (ã¢ãŒãã£ãã¡ã¯ã å©çšã§ããŠã³ããŒããå¯èœ) |
Returning a license | Unity ã©ã€ã»ã³ã¹ã®è¿åŽãã§ãã (Professional License ã®ã¿å¯Ÿå¿) |
Remote builder | GitHub Actions ã®ã¹ããã¯ã§ã¯æºè¶³ã®ãããã«ããã§ããªãéã« AWS ç°å¢ã§ãã€ã¹ããã¯ãªãã·ã³ãçšæããŠãã«ãã§ããããã«ãã®ããã®ã€ã³ãã©æ§ç¯ã«ã¯ AWS CloudFormation ã䜿çšããŠãã (çŸåšã¯ AWS ã®ã¿å¯Ÿå¿ãä»åŸ GCP, Azure ã«ã察å¿äºå®ãšã®ããš) |
Deployment | Unity ãã«ããåçš® Platform åãã«ãããã€ãã (iOS åã³ Android ã®ã¿èšèŒãããå³å¯ã«èšããš Builder ã§ãã«ãåºåããå
容ã fastlane ãçšããŠãããã€ããããã®ã¯ãŒã¯ãããŒçŽ¹ä»ã«ãªã£ãŠãã) |
äžèšãèŠããšæ¢ã« GameCI ã«ã¯éçºè ãšã㊠Unity CI ã«æ¬²ããæ©èœã¯æäœéæã£ãŠããããã«èŠåããããŸããã ãŸãæ¬èšäºã§ã¯ãä»åŸæ©äŒãããã°è©ŠããŠã¿ãããšèããŠããŸãã Remote builder åã³ Deployment ã«ã€ããŠã¯èšåããŠããŸããã
ä»åã¯å®äŸã亀ããªãã Activation åã³ Test runnerãBuilderãReturning a license ã®äœ¿çšæ¹æ³ã«ã€ããŠçŽ¹ä»ããŠãããŸãã
Activation: GameCI ã§å¿ èŠãšãªã Unity License ã®ã¢ã¯ãã£ããŒã·ã§ã³ãè¡ã
GameCI 㧠Unity ã©ã€ã»ã³ã¹ãã¢ã¯ãã£ããŒãããã«ã¯ Activation ãå©çšããŸããæ©éããã¥ã¡ã³ãã®æé ã«æ²¿ã£ãŠäœæ¥ãé²ããŠãããŸãã
ãŸã CI ãå°å
¥ããã GitHub äžã® Unity ãããžã§ã¯ãã® .github/workflows
å
ã« Unity ã©ã€ã»ã³ã¹ã¢ã¯ãã£ããŒãçšã®ã¯ãŒã¯ãããŒãã¡ã€ã«ãäœæããŸãã
name: Acquire activation file
on:
workflow_dispatch: {}
jobs:
activation:
name: Request manual activation file ð
runs-on: ubuntu-latest
steps:
# GameCI ã® Activation ãå©çšã㊠alf ãã¡ã€ã«ãçºè¡ãã
- name: Request manual activation file
id: getManualLicenseFile
uses: game-ci/unity-request-activation-file@v2
with:
# Unity ãããžã§ã¯ãã®ããŒãžã§ã³ãæå®ãã
# ProjectSettings/ProjectVersion.txt ã«èšèŒãããŠããããŒãžã§ã³ãå
¥åããã° OK
unityVersion: 2020.3.5f1
# 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 }}
ãã®åŸãããã©ã«ããã©ã³ã ã«ããã·ã¥ã㊠GitHub Actions ã§å®è¡å¯èœã«ããããäžèšæé ã«åŸã Unity ã©ã€ã»ã³ã¹ãã¡ã€ã«ã®ã¢ã¯ãã£ããŒãåã³ããŠã³ããŒããè¡ããŸãã
1. ãã©ãŠã¶ãã GitHub ãªããžããªã«ã¢ã¯ã»ã¹ããŠãUnity ã©ã€ã»ã³ã¹ã¢ã¯ãã£ããŒãçšã®ã¯ãŒã¯ãããŒãå®è¡ã㊠alf
ãã¡ã€ã«ãçæãã
2. ã¯ãŒã¯ãããŒã®å®è¡ã«æåãããã該åœé ç®ãã¯ãªãã¯ããŠè©³çŽ°ç»é¢ã«é·ç§»ãã
3. Artifacts
ã®é
ç®ãã alf
ãã¡ã€ã«ãããŠã³ããŒããã
4. Unity license manual activation webpage ãããã°ã€ã³ã㊠alf
ãã¡ã€ã«ãã¢ããããŒããã
5. Unity ã©ã€ã»ã³ã¹ã®å©çšçšéã«å¿ããŠé©åãªéžæè¢ãå ¥åãã (æ¬èšäºã§ã¯ Personal ã©ã€ã»ã³ã¹ãéžæ)
6. Download license
ãã¿ã³ãã¯ãªãã¯ã㊠ulf
ãã¡ã€ã«ãããŠã³ããŒããã
ãã㧠Unity ã©ã€ã»ã³ã¹ãã¡ã€ã«ã®ã¢ã¯ãã£ããŒãã¯å®äºã§ãã次ã«ã¢ã¯ãã£ããŒãããã©ã€ã»ã³ã¹ãã¡ã€ã«ã GitHub ãªããžããªã® Secrets ã«ç»é²ããŠãGameCI 㧠PlayMode åã³ EditMode ã®ãã¹ããå®è¡ã§ããããã«ããŠãããŸãã
::: message
alf
æ¡åŒµåã®ãã¡ã€ã«ãã©ã€ã»ã³ã¹ãªã¯ãšã¹ããã¡ã€ã«ãæããŠããŠãUnity ã©ã€ã»ã³ã¹ã®çºè¡ã«å¿
èŠãšãªããã¡ã€ã«ã§ããulf
æ¡åŒµåã®ãã¡ã€ã«ã Unity ã©ã€ã»ã³ã¹ã®ãã¡ã€ã«ã§ãã1
:::
Test runner: PlayMode åã³ EditMode ãã¹ããå®è¡ããŠçµæãåç §ãã
GitHub Actions äžã§ãã¹ããå®è¡ããããã«ãå
ã»ã©ã¢ã¯ãã£ããŒããã Unity ã©ã€ã»ã³ã¹ã®æ
å ±ã ã¯ãŒã¯ãããŒäžã§æ±ããããã«ããå¿
èŠããããŸãããã®ããããŸã㯠Secrets ã« ulf
ãã¡ã€ã«ã®å
容ãç»é²ããããšããå§ããŸãã
1. Unity ã©ã€ã»ã³ã¹ã®æ
å ±ç»é²ã®ãããGithub ãªããžããªã® Secrets
ç»é²ç»é¢ã«é·ç§»ãã
2. GameCI ã¯ã©ã€ã»ã³ã¹æ
å ±åç
§ã®ãããããã©ã«ãèšå®ã§ã¯ Secrets
ã® UNITY_LICENSE
ãåç
§ããããã®ãããName
ã UNITY_LICENSE
ãValue
ã«ã¯ ulf
ãã¡ã€ã«ã®äžèº«ãç»é²ãã2
äžèšäœæ¥ã§ GameCI ã§ãã¹ãããã«ãå®è¡ãè¡ããç°å¢ãæŽã£ãã®ã§ãåäœæ€èšŒã®ãããã¹ãå®è¡çšã®ã¯ãŒã¯ãããŒãã¡ã€ã«ãäœæããŸãã
name: Run EditMode and PlayMode Test
on:
workflow_dispatch: {}
jobs:
test:
name: Run EditMode and PlayMode Test
runs-on: ubuntu-latest
steps:
# actions/checkout@v2 ãå©çšããŠäœæ¥ãã£ã¬ã¯ããªã«
# Unity ãããžã§ã¯ãã®äžèº«ãããŠã³ããŒãããŠãã
- name: Check out my unity project.
uses: actions/checkout@v2
# GameCI ã® Test runner ãå©çšããŠ
# EditMode åã³ PlayMode ã®ãã¹ããå®è¡ãã
- name: Run EditMode and PlayMode Test
uses: game-ci/unity-test-runner@v2
env:
# 2. ã®æé 㧠Secrets ã«ç»é²ãã Unity ã©ã€ã»ã³ã¹ã®æ
å ±ãæå®ãã
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
# ãã Professional license ã䜿ãããå Žåã¯ã
# ã¡ãŒã«ã¢ãã¬ã¹ããã¹ã¯ãŒããã·ãªã¢ã«ãã³ããŒãå
¥åããå¿
èŠããã
# ref: https://game.ci/docs/github/test-runner#professional-license
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
projectPath: .
# ãã¹ãã®å®è¡çµæãã¿ããå Žå㯠githubToken ãæå®ãã
# secrets.GITHUB_TOKEN 㯠Secrets æªç»é²ã§ãå©çšå¯èœ
githubToken: ${{ secrets.GITHUB_TOKEN }}
# Unity ãããžã§ã¯ãã®ããŒãžã§ã³ãæå®ãã
# ProjectSettings/ProjectVersion.txt ã«èšèŒãããŠããããŒãžã§ã³ãå
¥åããã° OK
unityVersion: 2020.3.5f1
# å®è¡ããããã¹ãã®çš®é¡ãæå®ã§ãã
# æå®å¯èœãªå€ã¯ All, PlayMode, EditMode
# testMode: All
# ãã¹ãå®è¡æã«å©çšããã Docker ã€ã¡ãŒãžãæ瀺çã«æå®ã§ãã
# customImage: 'unityci/editor:2020.1.14f1-base-0'
# ãã¹ãã®å®è¡çµæãã¢ãŒãã£ãã¡ã¯ãã«ã¢ããããŒãããŠããŠã³ããŒãããŠåç
§ã§ããããã«ãã
- uses: actions/upload-artifact@v2
if: always()
with:
name: Test results
path: artifacts
äžèšã®ã¯ãŒã¯ãããŒãã¡ã€ã«ã GitHub Actions äžã§åäœæ€èšŒããéã®æé ã¯äžèšã«ãªããŸãã
1. Unity ã®ãã¹ããå®è¡ããããã®ã¯ãŒã¯ãããŒãéžæããŠå®è¡ãã
2. ã¯ãŒã¯ãããŒã®å®è¡ãæåãããã詳现ç»é¢ã«é·ç§»ããåŸãTest Results
ã®é
ç®ãããã¹ãã®å®è¡çµæã確èªãã
ãã¹ãå®è¡çšã®ã¯ãŒã¯ãããŒãã¡ã€ã«ã§ã¯ workflow_dispatch
ã§å®è¡å¯èœã«ããŠããŸãããpull_request
ãå©çšããã°ãã«ãªã¯æã«ãã¹ããå®è¡ãããããšãå¯èœã«ãªããŸãã
Builder: ãããžã§ã¯ãã®ãã«ããå®è¡ããŠåºåçµæã確èªãã
GameCI ã«ã¯ãããžã§ã¯ãã®ãã«ããè¡ãããã® GitHub Actions ãçšæãããŠããŸããå®éã« GameCI 㧠WebGL ãã«ããè¡ããã®å 容ã GitHub Pages ã§ç¢ºèªã§ããããã«ããŠåäœæ€èšŒããŠãããŸãã
æ©é WebGL ãã«ããè¡ãããã®ã¯ãŒã¯ãããŒãã¡ã€ã«ãäœæããŠãããŸãã
name: Run the WebGL build
on:
workflow_dispatch: {}
jobs:
build:
name: Run the WebGL build
runs-on: ubuntu-latest
steps:
# actions/checkout@v2 ãå©çšããŠäœæ¥ãã£ã¬ã¯ããªã«
# Unity ãããžã§ã¯ãã®äžèº«ãããŠã³ããŒãããŠãã
- name: Check out my unity project.
uses: actions/checkout@v2
# GameCI ã® Builder ãå©çšããŠã
# Unity ãããžã§ã¯ãã®ãã«ããå®è¡ãã
- name: Run the WebGL build
uses: game-ci/unity-builder@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
# ä»å㯠WebGL ãã«ããè¡ããããã WebGL ãæå®ãã
# WebGL 以å€ã®æå®å¯èœãªå€ã¯äžèšã«èšèŒã®å€ãå©çšå¯èœ
# ref: https://docs.unity3d.com/ScriptReference/BuildTarget.html
targetPlatform: WebGL
unityVersion: 2020.3.5f1
# Builder ã§åºåãã WebGL ãã«ãã GitHub Pages ã«ãããã€ãã
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.3
with:
# GitHub Pages ãããã€çšã® Orphan ãã©ã³ãåãæå®ãã
branch: gh-pages
# ãããã€çšãã«ããã©ã«ããã¹ãæå®ãã
# GameCI ã® Builder ã¯ããã©ã«ãã§ã¯ build ãã©ã«ãã«ãã«ãå
容ãåºåãã
folder: build
# Builder ã§åºåãã WebGL ãã«ããã¢ãŒãã£ãã¡ã¯ãã§ããŠã³ããŒãå¯èœã«ãã
- name: Upload the WebGL Build
uses: actions/upload-artifact@v2
with:
name: Build
path: build
äžèšã®ã¯ãŒã¯ãããŒãã¡ã€ã«ã GitHub Actions äžã§åäœæ€èšŒããéã®æé ã¯äžèšã«ãªããŸãã
1. Unity ã® WebGL ãã«ããå®è¡ããããã®ã¯ãŒã¯ãããŒãå®è¡ãã
2. ã¯ãŒã¯ãããŒã®å®è¡ãæåãããã詳现ç»é¢ã«é·ç§»ããåŸããã«ãå 容ãæ£åžžããã確èªãã
3. ãã«ãå 容ã確èªããããã® GitHub Pages ã®èšå®ã Settings ããè¡ã
4. GitHub Pages ã§ãã©ãŠã¶ãã WebGL ãã«ãã®åäœç¢ºèªããã
äžèšã®ããã« Builder ãå©çšããããšã§ WebGL ãã«ãã®æåŠåã³ãææ°ã®ãã«ãå 容ãåžžã« GitHub Pages ã§èŠãããããã«ã§ããŸãã ãããš WebGL ãã«ããæ£åžžãã©ããã®ç¢ºèªãåžžã« GitHub Pages ãèŠãã°ææ¡ã§ããããã«ãªããããUnity1 é±éã²ãŒã ãžã£ã ãªã©ã«åå ããéã§äŸ¿å©ã«æŽ»çšã§ãããã§ãã
:::message
WebGL ãã«ããè¡ãéãUnity ããŒãžã§ã³ãã¢ã»ããã®å¯Ÿå¿ç¶æ³ã«ãã£ãŠã¯æ£ãããã©ãŠã¶äžã§åäœããªããã«ããåºåãããŸãããã ãããã©ãŠã¶ã§çºçãããšã©ãŒå
容ã«ãã£ãŠã¯ WebGL ã®ãã«ãèšå®ãèŠçŽãã ãã§è§£æ±ºã§ããå ŽåããããŸãã äŸãã° unityframework is not defined
ãšãããšã©ãŒãçºçããéã¯ããã®èšäº ã®ããã« WebGL ã® Build Settings
ãèŠçŽãããšã§è§£æ±ºã§ããå ŽåããããŸãã
:::
:::message
ç§ã®ç°å¢ã§ã¯ JamesIves/github-pages-deploy-action
㧠GitHub Pages ãžã®ãããã€ãè¡ã£ãéãããã©ã«ãã§ã¯ /WebGL/WebGL
ãã©ã«ãã«ãã«ãå
容ãåºåãããŸããããã®ããããã©ãŠã¶ãã WebGL ãã«ãã«ã¢ã¯ã»ã¹ããéã<GitHub Pages ã® URL>/WebGL/WebGL
ã®ãã㪠URL ã«ã¢ã¯ã»ã¹ããå¿
èŠããããŸããã
:::
Returning a license: GameCI ã§å©çšããŠãã Unity License ãè¿åŽãã
éåžžå©çšããããšã¯ç¡ããšå ¬åŒãµã€ãã«ãæžãããŠããŸãããProfessional License ã®è¿åŽã GameCI ã§è¡ãããšãå¯èœã§ãã ä»å㯠Personal License ãå©çšãããã䜿çšããŸããã§ããããäžèšãã¯ãŒã¯ãããŒã®ã¹ãããã«çµã¿èŸŒãããšã§ Professional License ãè¿åŽã§ããããã§ãã
# ...
# ã©ããã®ã¿ã€ãã³ã°ã§ã©ã€ã»ã³ã¹ã®ã¢ã¯ãã£ããŒããè¡ã
- name: Activate Unity
uses: game-ci/unity-activate@v1
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
#...
# ã¹ãããã®æåŸãªã©ã« game-ci/unity-return-license@v1 ãåŒã³åºããŠ
# ã¢ã¯ãã£ããŒãæžã¿ã®ã©ã€ã»ã³ã¹ãè¿åŽãã
- name: Return license
uses: game-ci/unity-return-license@v1
if: always()
ãããã«
以å Unity ã³ãã³ããé§äœ¿ããŠèªå㧠CI ç°å¢ãæ§ç¯ããçµéšãããã®ã§ããã GameCI ãå©çšããæ¹ãå šç¶æ¥œã« Unity CI ç°å¢æ§ç¯ã GitHub Actions äžã§è¡ããŸããã
ã¡ãªã¿ã« GameCI ã§å©çšãããŠãã Docker ã€ã¡ãŒãž ã¯ä»¥åãããã䜿ãããŠãã gableroux/unity3d ãå ã«ãªã£ãŠããããã§ãããã£ãŠã GabLeRoux ããã®ããŒã ããŒãž ãèŠãããGameCI ã®éçºãå§ããæ¹ã®ããã§ããããããã
æ¬èšäºã GitHub Actions 㧠Unity CI ç°å¢æ§ç¯ãå§ããããšããŠããæ¹ã®å©ãã«ãªããã°å¹žãã§ãã
åèãªã³ã¯
- GameCI - The fastest and easiest way to automatically test and build your game projects
- Services - Cloud Build - Unity
- AWS CloudFormationïŒãã³ãã¬ãŒãã䜿ã£ããªãœãŒã¹ã®ã¢ãã«åãšç®¡çïŒ| AWS
- fastlane - App automation done right
- ãªããžããªã®ããã©ã«ããã©ã³ãåã管çãã - GitHub Docs
- Unity ã§ããŒãœãã«ã©ã€ã»ã³ã¹ã®ã·ãªã¢ã«ãã³ããŒãçºè¡ãã | Yucchiy’s Note
- Unity license manual activation webpage
- æå·åãããã·ãŒã¯ã¬ãã - GitHub Docs
- Unity - Scripting API: BuildTarget
- Unity 1 é±éã²ãŒã ãžã£ã | ããªãŒã²ãŒã æçš¿ãµã€ã unityroom
- Unity2020 WebGL 9 å²ãŸã§èªã¿èŸŒãããã¢ããªãèµ·åããªãäžå ·åã®è§£æ±ºæ¹æ³ - Qiita
- Deploy to GitHub Pages · Actions · GitHub Marketplace