Skip to content

Commit

Permalink
Merge pull request #2 from DevsOnTheBoard/dev-sagara
Browse files Browse the repository at this point in the history
カスタムビルドのGitHub Actions作成
  • Loading branch information
sgrwaaa committed Nov 8, 2023
2 parents 50efe63 + 1e0fde6 commit eb7d47d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/develop_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Develop Build
on:
workflow_dispatch: {}
jobs:
build:
name: Develop Build my project
runs-on: ubuntu-latest
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v3
with:
lfs: true

# Cache
- uses: actions/cache@v3
with:
path: Library
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
# Develop Build
- name: Develop Build project
uses: game-ci/unity-builder@v3
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: WebGL
unityVersion: 2022.3.12f1
# DevelopBuildForCICDのメソッド呼び出し
buildMethod: ProjectBuilder.DevelopBuildForCICD

# Output
- uses: actions/upload-artifact@v3
with:
name: Build
path: build
38 changes: 38 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release Build
on:
workflow_dispatch: {}
jobs:
build:
name: Release Build my project
runs-on: ubuntu-latest
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v3
with:
lfs: true

# Cache
- uses: actions/cache@v3
with:
path: Library
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}
restore-keys: |
Library-
# Release Build
- name: Release Build project
uses: game-ci/unity-builder@v3
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: WebGL
unityVersion: 2022.3.12f1
# ReleaseBuildForCICDのメソッド呼び出し
buildMethod: ProjectBuilder.ReleaseBuildForCICD

# Output
- uses: actions/upload-artifact@v3
with:
name: Build
path: build
24 changes: 23 additions & 1 deletion Assets/Scripts/Editor/ProjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,23 @@ public static void DevelopBuild()
Build(BuildOptions.Development, BuildTarget.WebGL);
}

private static void Build(BuildOptions buildOptions, BuildTarget buildTarget)
/// <summary>
/// CICDのワークフローからリリースビルドを実行する時はこちらを呼び出す
/// </summary>
private static void ReleaseBuildForCICD()
{
Build(BuildOptions.None, BuildTarget.WebGL, true);
}

/// <summary>
/// CICDのワークフローから開発ビルドを実行する時はこちらを呼び出す
/// </summary>
private static void DevelopBuildForCICD()
{
Build(BuildOptions.Development, BuildTarget.WebGL, true);
}

private static void Build(BuildOptions buildOptions, BuildTarget buildTarget, bool isCICD = false)
{
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
// ビルド出力先
Expand All @@ -45,5 +61,11 @@ private static void Build(BuildOptions buildOptions, BuildTarget buildTarget)
{
Debug.LogError("Build Failed");
}

if (isCICD)
{
//成否に応じてUnityEditorの終了プロセスを決定する
EditorApplication.Exit(summary.result == BuildResult.Succeeded ? 0 : 1);
}
}
}

0 comments on commit eb7d47d

Please sign in to comment.