ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Github Action + Unity
    Back-End/ETC 2021. 11. 21. 12:40

    1. Github Action 

    - 사용 이유 : Jenkins를 시도해보기 전에 Github에서 무료로 바로 쓸 수 있는 Action으로 테스트

    - Jenkins대비 장점 : Jenkins는 Cloud 환경이나, Local환경을 따로 구축해야하지만 따로 구축 없이 사용 가능하고, Github와 연동 용이

    - 단점 : output 으로 만들어지는 Artifact 기준 누적 billing이여서 게임 빌드시 쉽게 Free 용량 초과

    - Billing (https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions)

    About billing for GitHub Actions

    2. 구축

    - 사전 준비 : Unity Project가 올라간 Github Repo

     

    2-1 Github Actions 탭에서  set up a workflow yourself를 누르면 `.github/workflows/`에 yml 파일을 만들어 셋팅할 수 있다. 

     Console창이 아닌 Project commit 시에 해당 위치에 파일 추가시 Action workflow가 생성된다.

    Github Actions
    workflows .yml file

    2-2 GameCi Action 을 활용 (https://game.ci/docs/github/getting-started)
    Activation.yml을 만들어 Unity License를 얻는다

    ## .github/workflows/activation.yml
    
    name: Acquire activation file
    on:
      push: { branches: [release] }
    jobs:
      activation:
        name: Request manual activation file 🔑
        runs-on: ubuntu-latest
        steps:
          # Request manual activation file
          - name: Request manual activation file
            id: getManualLicenseFile
            uses: game-ci/unity-request-activation-file@v2
            with: 
              unityVersion: "2021.2.1f1"
          # 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 }}

    workflow를 돌린후 나온 alf파일을

    license.unity3d.com 에서 ulf파일로 변환하여 받은후

    Github > <Your repository> > Settings > Secrets. 에서 UNITY_LICENSE 로 키값을 추가한다.

     

    Window64 Build

    ## window64.yml
    
    name: Unity Actions
    
    on:
      push: { branches: [release] }
    
    env:
      UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
    
    jobs:
      buildWindow:
        name: Build for ${{ matrix.targetPlatform }}
        runs-on: ubuntu-latest
        strategy:
          fail-fast: false
          matrix:
            unityVersion:
              - 2021.2.1f1
            targetPlatform:
              - StandaloneWindows64 # Build a Windows 64-bit standalone.
        steps:
          - uses: actions/checkout@v2
            with:
              fetch-depth: 0
              lfs: true
          - uses: actions/cache@v2
            with:
              path: Library
              key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
              restore-keys: |
                Library-
          - uses: game-ci/unity-builder@v2
            env:
              UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
            with:
              unityVersion: ${{ matrix.unityVersion }}
              targetPlatform: ${{ matrix.targetPlatform }}
          - uses: actions/upload-artifact@v2
            with:
              name: Build-Window
              path: build/Window

     

    Android Build

    ## https://game.ci/docs/github/builder#androidappbundle
    ## androidKeystoreBase64 cmd $ openssl base64 -A -in user.keystore
    ## andoroid.yml
    
    name: Unity Actions
    
    on:
      push: { branches: [release] }
    
    env:
      UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
    
    jobs:
      buildForAndroidPlatform:
        name: Build For Android Platform
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          - uses: actions/cache@v2
            with:
              path: Library
              key: Library-Android
          - uses: game-ci/unity-builder@v2
            with:
              targetPlatform: Android
              androidAppBundle: false
              androidKeystoreName: user.keystore
              androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
              androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
              androidKeyaliasName: ${{ secrets.ANDROID_KEYALIAS_NAME }}
              androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}
              unityVersion: 2021.2.1f1
          - uses: actions/upload-artifact@v2
            with:
              name: build-Android
              path: build/Android

    'Back-End > ETC' 카테고리의 다른 글

    Jenkins + Unity  (0) 2022.01.09
    Jenkins + GitHub  (0) 2022.01.08
    Chat Server 분석  (0) 2021.09.07
    리더보드 (Ranking) 서버  (0) 2021.08.26
    Serverless.yml simple example  (0) 2021.08.21
Designed by Tistory.