Skip to content

Commit

Permalink
Fix build target usage
Browse files Browse the repository at this point in the history
  • Loading branch information
KonH committed Jun 6, 2019
1 parent 8bdb399 commit 6c8be1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
13 changes: 8 additions & 5 deletions Assets/Scripts/Editor/CustomBuildPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace UnityCiPipeline {
public class CustomBuildPipeline : MonoBehaviour {
[MenuItem("BuildPipeline/RunBuild")]
public static void RunBuild(BuildTarget target) {
var targetGroup = BuildPipeline.GetBuildTargetGroup(target);
var opts = new BuildPlayerOptions {
Expand All @@ -21,10 +20,7 @@ public static void RunBuild(BuildTarget target) {
public static void RunBuild_WebGL() => RunBuild(BuildTarget.WebGL);

public static void RunBuildForVersion() {
var targetVariable = Environment.GetEnvironmentVariable("BUILD_TARGET");
if ( string.IsNullOrEmpty(targetVariable) ) {
throw new InvalidOperationException("BUILD_TARGET isn't provided!");
}
var targetVariable = GetBuildTarget();
var target = (BuildTarget)Enum.Parse(typeof(BuildTarget), targetVariable);
var commitHash = GetVersion();
Debug.Log($"RunBuildForCommit: version='{commitHash}'");
Expand All @@ -39,6 +35,13 @@ static string GetVersion() {
.First();
}

static string GetBuildTarget() {
return Environment.GetCommandLineArgs()
.Where(a => a.StartsWith("-buildTarget="))
.Select(a => a.Remove(0, "-buildTarget=".Length))
.First();
}

static void PrepareForBuild(string version) {
PlayerSettings.bundleVersion = version;
}
Expand Down
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Task("Build")
if ( string.IsNullOrEmpty(buildTarget) ) {
buildTarget = "WebGL";
}
RunUnity($"-executeMethod UnityCiPipeline.CustomBuildPipeline.RunBuildForVersion -projectPath . -version={version}", false);
RunUnity($"-executeMethod UnityCiPipeline.CustomBuildPipeline.RunBuildForVersion -projectPath . -version={version} -buildTarget={buildTarget}", false);
});

Task("Upload")
Expand Down
6 changes: 2 additions & 4 deletions manual_build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#!/usr/bin/env bash

# env variables
# BUILD_TARGET

# arguments
UNITY_PATH=$1 # path to Unity executable (.../Unity.app/Contents/MacOS/Unity)
ITCH_DESTINATION=$2 # itch.io target like userName/projectName:platform
VERSION=$3 # application version
BUILD_TARGET=$4 # build target

echo "Remove old Build..."
rm -rf Build

echo "Run Unity from $UNITY_PATH..."
${UNITY_PATH} -quit -batchmode -logFile - -executeMethod UnityCiPipeline.CustomBuildPipeline.RunBuildForVersion -projectPath "$(PWD)" -version=${VERSION}
${UNITY_PATH} -quit -batchmode -logFile - -executeMethod UnityCiPipeline.CustomBuildPipeline.RunBuildForVersion -projectPath "$(PWD)" -version=${VERSION} -buildTarget=${BUILD_TARGET}

echo "Push to itch.io..."
butler push --userversion=${VERSION} --verbose Build ${ITCH_DESTINATION}

0 comments on commit 6c8be1f

Please sign in to comment.