Skip to content

Commit

Permalink
Merge branch 'develop' into feat/crouch
Browse files Browse the repository at this point in the history
  • Loading branch information
12joan committed Dec 17, 2024
2 parents 8645989 + 436f46f commit 4e5e554
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 12 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ on:
target_platform:
required: true
type: string
initial_scene:
required: true
type: string
branch_name:
required: true
type: string
commit_hash:
required: true
type: string

jobs:
build:
Expand All @@ -29,6 +38,8 @@ jobs:
buildName: 'Pop Pixie'
targetPlatform: ${{ inputs.target_platform }}
versioning: None
buildMethod: DevelopmentBuild.Build
customParameters: ${{ inputs.initial_scene && format('-initialScene {0}', inputs.initial_scene) || '' }} -branchName ${{ inputs.branch_name }} -commitHash ${{ inputs.commit_hash }}

- uses: actions/upload-artifact@v4
with:
Expand Down
31 changes: 30 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
name: Development builds

on: push
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
prepare:
name: 'Prepare'
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.body, 'No build') }}
steps:
- id: initial_scene
run: |
initial_scene=$(echo $PR_DESCRIPTION | grep -Eo 'Initial scene: [A-Za-z ]+' | cut -b 16- | sed -e 's/ /_/g')
echo "initial_scene=$initial_scene" | tee -a $GITHUB_OUTPUT
env:
PR_DESCRIPTION: ${{ github.event.pull_request.body }}
outputs:
initial_scene: ${{ steps.initial_scene.outputs.initial_scene }}

windows_build:
name: 'Build for Windows'
needs: prepare
uses: ./.github/workflows/windows.yml
secrets: inherit
with:
initial_scene: ${{ needs.prepare.outputs.initial_scene }}
branch_name: ${{ github.head_ref || github.ref_name }}
commit_hash: ${{ github.event.pull_request.head.sha || github.sha }}

macos_build:
name: 'Build for macOS'
needs: prepare
uses: ./.github/workflows/macos.yml
secrets: inherit
with:
initial_scene: ${{ needs.prepare.outputs.initial_scene }}
branch_name: ${{ github.head_ref || github.ref_name }}
commit_hash: ${{ github.event.pull_request.head.sha || github.sha }}

steam:
name: 'Upload to Steam'
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,28 @@ name: Build and package macOS
# 3. gh secret set APP_STORE_CONNECT_API_KEY
# 4. base64 -i AuthKey_**********.p8 | gh secret set APP_STORE_CONNECT_PASSWORD

on: workflow_call
on:
workflow_call:
inputs:
initial_scene:
required: true
type: string
branch_name:
required: true
type: string
commit_hash:
required: true
type: string

jobs:
build:
name: 'Build for macOS'
uses: ./.github/workflows/build.yml
with:
target_platform: StandaloneOSX
initial_scene: ${{ inputs.initial_scene }}
branch_name: ${{ inputs.branch_name }}
commit_hash: ${{ inputs.commit_hash }}
secrets: inherit

package_macos:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/steam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name: Upload to Steam
# 4. In Pop Pixie > Steamworks Settings > Installation > General Installation,
# create a launch option each for Windows and macOS. The executables should
# be as follows:
# Windows: Pop Pixie/Pop Pixie.exe
# Windows: Pop Pixie.exe
# macOS: Pop Pixie.app/Contents/MacOS/Pop Pixie
# 5. In Pop Pixie > Associated Packages & DLC, ensure that all packages you
# intend to use include the Pop Pixie app and both depots created in step 1.
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Test

on: push

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
name: Build and package Windows

on: workflow_call
on:
workflow_call:
inputs:
initial_scene:
required: true
type: string
branch_name:
required: true
type: string
commit_hash:
required: true
type: string

jobs:
build:
name: 'Build for Windows'
uses: ./.github/workflows/build.yml
with:
target_platform: StandaloneWindows64
initial_scene: ${{ inputs.initial_scene }}
branch_name: ${{ inputs.branch_name }}
commit_hash: ${{ inputs.commit_hash }}
secrets: inherit

package_windows:
Expand Down
129 changes: 129 additions & 0 deletions Assets/Editor/DevelopmentBuild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* MIT License
*
* Copyright (c) 2020-present GameCI, Anderbell Studios
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Reporting;

public static class DevelopmentBuild {
private const string MetaDataPath = "Assets/src/BuildMetaData.cs";

public static void Build() {
ParseCommandLineArguments(out Dictionary<string, string> options);

BuildTarget buildTarget = (BuildTarget) Enum.Parse(
typeof(BuildTarget),
options["buildTarget"]
);

List<string> scenes = EditorBuildSettings.scenes
.Where(scene => scene.enabled)
.Select(scene => scene.path)
.ToList();

// Load a scene that isn't in build settings as the initial scene
if (options.TryGetValue("initialScene", out string name)) {
// Spaces cause issues with shell variables, so encode them as underscores
string nameWithSpaces = name.Replace("_", " ");
string initialScenePath = $"Assets/Unity/Scenes/{nameWithSpaces}.unity";
scenes.Insert(0, initialScenePath);
}

BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions {
scenes = scenes.ToArray(),
locationPathName = options["customBuildPath"],
target = buildTarget,
options = UnityEditor.BuildOptions.Development
};

BuildMetaData.SetBranchName(options["branchName"]);
BuildMetaData.SetCommitHash(options["commitHash"]);

BuildSummary buildSummary;

try {
buildSummary = BuildPipeline.BuildPlayer(buildPlayerOptions).summary;
} finally {
BuildMetaData.Reset();
}

ReportSummary(buildSummary);
ExitWithResult(buildSummary.result);
}

private static void ParseCommandLineArguments(out Dictionary<string, string> providedArguments) {
providedArguments = new Dictionary<string, string>();
string[] args = Environment.GetCommandLineArgs();

// Extract flags with optional values
for (int current = 0; current < args.Length; current++) {
int next = current + 1;

// Ignore arguments not starting with '-'
bool isFlag = args[current].StartsWith("-");
if (!isFlag) continue;

string flag = args[current].TrimStart('-');

// Parse optional value
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
string value = flagHasValue ? args[next].TrimStart('-') : "";

Console.WriteLine($"Found flag \"{flag}\" with value \"{value}\".");
providedArguments.Add(flag, value);
}
}

private static void ReportSummary(BuildSummary summary) {
Console.WriteLine($"Duration: {summary.totalTime.ToString()}");
Console.WriteLine($"Warnings: {summary.totalWarnings.ToString()}");
Console.WriteLine($"Errors: {summary.totalErrors.ToString()}");
Console.WriteLine($"Size: {summary.totalSize.ToString()} bytes");
}

private static void ExitWithResult(BuildResult result) {
switch (result) {
case BuildResult.Succeeded:
Console.WriteLine("Build succeeded!");
EditorApplication.Exit(0);
break;
case BuildResult.Failed:
Console.WriteLine("Build failed!");
EditorApplication.Exit(101);
break;
case BuildResult.Cancelled:
Console.WriteLine("Build cancelled!");
EditorApplication.Exit(102);
break;
case BuildResult.Unknown:
default:
Console.WriteLine("Build result is unknown!");
EditorApplication.Exit(103);
break;
}
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/DevelopmentBuild.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
7 changes: 7 additions & 0 deletions Assets/Resources/branch_name.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
7 changes: 7 additions & 0 deletions Assets/Resources/commit_hash.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/Unity/Scenes/Landing.unity
Original file line number Diff line number Diff line change
Expand Up @@ -4302,8 +4302,8 @@ MonoBehaviour:
CloseMenuControls: []
OptionsMenu: {fileID: 5390937582216238565}
SceneChangeHopper: {fileID: 3703512347334790477}
DebugModeIndicator: {fileID: 1084830647389432198}
EDCIndicatorText: {fileID: 8249008630340236876}
DebugModeIndicator: {fileID: 6834667129251417635}
EDCIndicator: {fileID: 8249008630340236876}
--- !u!114 &5677020614264961516
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
30 changes: 30 additions & 0 deletions Assets/src/BuildMetaData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class BuildMetaData {
public static String BranchName => Read("branch_name");
public static String CommitHash => Read("commit_hash");

public static void SetBranchName(string value)
=> Write("branch_name", value);

public static void SetCommitHash(string value)
=> Write("commit_hash", value);

public static void Reset() {
SetBranchName(null);
SetCommitHash(null);
}

private static void Write(string filename, String value) {
File.WriteAllText($"Assets/Resources/{filename}.txt", value ?? "");
}

private static String Read(string filename) {
string value = (Resources.Load(filename) as TextAsset).text.Trim();
return value == "" ? null : value;
}
}
11 changes: 11 additions & 0 deletions Assets/src/BuildMetaData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4e5e554

Please sign in to comment.