Skip to content

Commit e54cee6

Browse files
committed
feat: add buildProfile parameter
add new `buildProfile` action param, which will be passed into Unity as the `-activeBuildProfile ...` CLI param. closes game-ci#674
1 parent 83c8532 commit e54cee6

File tree

11 files changed

+174
-7
lines changed

11 files changed

+174
-7
lines changed

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ inputs:
1818
projectPath:
1919
required: false
2020
default: ''
21-
description: 'Relative path to the project to be built.'
21+
description: 'Path to the project to be built, relative to the repository root.'
22+
buildProfile:
23+
required: false
24+
default: ''
25+
description: 'Path to the build profile to activate, relative to the project root.'
2226
buildName:
2327
required: false
2428
default: ''

dist/index.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/platforms/mac/steps/build.sh

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ echo "Using build name \"$BUILD_NAME\"."
1919

2020
echo "Using build target \"$BUILD_TARGET\"."
2121

22+
#
23+
# Display the build profile
24+
#
25+
26+
if [ -z "$BUILD_PROFILE" ]; then
27+
# User has not provided a build profile
28+
#
29+
echo "Doing a default \"$BUILD_TARGET\" platform build."
30+
#
31+
else
32+
# User has provided a path to a build profile `.asset` file
33+
#
34+
echo "Using build profile \"$BUILD_PROFILE\" relative to \"$UNITY_PROJECT_PATH\"."
35+
#
36+
fi
37+
38+
2239
#
2340
# Display build path and file
2441
#
@@ -62,6 +79,25 @@ else
6279
#
6380
fi
6481

82+
#
83+
# Assemble the build target or build profile CLI options
84+
#
85+
# The `-buildTarget` and `-activeBuildProfile` are mutually exclusive options.
86+
#
87+
88+
if [ -z "$BUILD_PROFILE" ]; then
89+
# User has not provided a build profile, `-buildTarget` is necessary.
90+
#
91+
BUILD_TARGET_OR_PROFILE="-buildTarget \"$BUILD_TARGET\""
92+
#
93+
else
94+
# User has provided a build profile, `-buildTarget` is not necessary.
95+
#
96+
BUILD_TARGET_OR_PROFILE="-activeBuildProfile \"$BUILD_PROFILE\""
97+
#
98+
fi
99+
100+
65101
#
66102
# Prepare Android keystore and SDK, if needed
67103
#
@@ -89,6 +125,14 @@ fi
89125
# Pre-build debug information
90126
#
91127

128+
echo ""
129+
echo "###########################"
130+
echo "# Build target/prof #"
131+
echo "###########################"
132+
echo ""
133+
134+
echo "$BUILD_TARGET_OR_PROFILE"
135+
92136
echo ""
93137
echo "###########################"
94138
echo "# Custom parameters #"
@@ -136,7 +180,7 @@ echo ""
136180
-password "$UNITY_PASSWORD" \
137181
-customBuildName "$BUILD_NAME" \
138182
-projectPath "$UNITY_PROJECT_PATH" \
139-
-buildTarget "$BUILD_TARGET" \
183+
$BUILD_TARGET_OR_PROFILE \
140184
-customBuildTarget "$BUILD_TARGET" \
141185
-customBuildPath "$CUSTOM_BUILD_PATH" \
142186
-executeMethod "$BUILD_METHOD" \

dist/platforms/ubuntu/steps/build.sh

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ echo "Using build name \"$BUILD_NAME\"."
1919

2020
echo "Using build target \"$BUILD_TARGET\"."
2121

22+
#
23+
# Display the build profile
24+
#
25+
26+
if [ -z "$BUILD_PROFILE" ]; then
27+
# User has not provided a build profile
28+
#
29+
echo "Doing a default \"$BUILD_TARGET\" platform build."
30+
#
31+
else
32+
# User has provided a path to a build profile `.asset` file
33+
#
34+
echo "Using build profile \"$BUILD_PROFILE\" relative to \"$UNITY_PROJECT_PATH\"."
35+
#
36+
fi
37+
2238
#
2339
# Display build path and file
2440
#
@@ -62,10 +78,36 @@ else
6278
#
6379
fi
6480

81+
#
82+
# Assemble the build target or build profile CLI options
83+
#
84+
# The `-buildTarget` and `-activeBuildProfile` are mutually exclusive options.
85+
#
86+
87+
if [ -z "$BUILD_PROFILE" ]; then
88+
# User has not provided a build profile, `-buildTarget` is necessary.
89+
#
90+
BUILD_TARGET_OR_PROFILE="-buildTarget \"$BUILD_TARGET\""
91+
#
92+
else
93+
# User has provided a build profile, `-buildTarget` is not necessary.
94+
#
95+
BUILD_TARGET_OR_PROFILE="-activeBuildProfile \"$BUILD_PROFILE\""
96+
#
97+
fi
98+
6599
#
66100
# Pre-build debug information
67101
#
68102

103+
echo ""
104+
echo "###########################"
105+
echo "# Build target/prof #"
106+
echo "###########################"
107+
echo ""
108+
109+
echo "$BUILD_TARGET_OR_PROFILE"
110+
69111
echo ""
70112
echo "###########################"
71113
echo "# Custom parameters #"
@@ -109,7 +151,7 @@ unity-editor \
109151
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
110152
-customBuildName "$BUILD_NAME" \
111153
-projectPath "$UNITY_PROJECT_PATH" \
112-
-buildTarget "$BUILD_TARGET" \
154+
$BUILD_TARGET_OR_PROFILE \
113155
-customBuildTarget "$BUILD_TARGET" \
114156
-customBuildPath "$CUSTOM_BUILD_PATH" \
115157
-executeMethod "$BUILD_METHOD" \

dist/platforms/windows/build.ps1

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ Write-Output "$('Using build name "')$($Env:BUILD_NAME)$('".')"
1616

1717
Write-Output "$('Using build target "')$($Env:BUILD_TARGET)$('".')"
1818

19+
#
20+
# Display the build profile
21+
#
22+
23+
if ($Env:BUILD_PROFILE)
24+
{
25+
# User has provided a path to a build profile `.asset` file
26+
#
27+
Write-Output "$('Using build profile "')$($Env:BUILD_PROFILE)$('" relative to "')$($Env:UNITY_PROJECT_PATH)$('".')"
28+
#
29+
}
30+
else
31+
{
32+
# User has not provided a build profile
33+
#
34+
Write-Output "$('Doing a default "')$($Env:BUILD_TARGET)$('" platform build.')"
35+
#
36+
}
37+
1938
#
2039
# Display build path and file
2140
#
@@ -86,10 +105,38 @@ else {
86105
Write-Output "Not creating Android keystore."
87106
}
88107

108+
#
109+
# Assemble the build target or build profile CLI options
110+
#
111+
# The `-buildTarget` and `-activeBuildProfile` are mutually exclusive options.
112+
#
113+
114+
if ($Env:$BUILD_PROFILE) {
115+
# User has provided a build profile, `-buildTarget` is not necessary.
116+
#
117+
$buildtargetOrProfile = @("-activeBuildProfile", "`"$Env:BUILD_PROFILE`"")
118+
#
119+
}
120+
else
121+
{
122+
# User has not provided a build profile, `-buildTarget` is necessary.
123+
#
124+
$buildtargetOrProfile = @("-buildTarget", "`"$Env:BUILD_TARGET`"")
125+
#
126+
}
127+
89128
#
90129
# Pre-build debug information
91130
#
92131

132+
Write-Output ""
133+
Write-Output "###########################"
134+
Write-Output "# Build target/prof #"
135+
Write-Output "###########################"
136+
Write-Output ""
137+
138+
Write-Output "$('"')$($buildtargetOrProfile)$('"')"
139+
93140
Write-Output ""
94141
Write-Output "###########################"
95142
Write-Output "# Custom parameters #"
@@ -140,7 +187,6 @@ $unityArgs = @(
140187
"-customBuildName", "`"$Env:BUILD_NAME`"",
141188
"-projectPath", "`"$Env:UNITY_PROJECT_PATH`"",
142189
"-executeMethod", "`"$Env:BUILD_METHOD`"",
143-
"-buildTarget", "`"$Env:BUILD_TARGET`"",
144190
"-customBuildTarget", "`"$Env:BUILD_TARGET`"",
145191
"-customBuildPath", "`"$Env:CUSTOM_BUILD_PATH`"",
146192
"-buildVersion", "`"$Env:VERSION`"",
@@ -152,7 +198,7 @@ $unityArgs = @(
152198
"-androidExportType", "`"$Env:ANDROID_EXPORT_TYPE`"",
153199
"-androidSymbolType", "`"$Env:ANDROID_SYMBOL_TYPE`"",
154200
"-logfile", "-"
155-
) + $customParametersArray
201+
) + $buildtargetOrProfile + $customParametersArray
156202

157203
# Remove null items as that will fail the Start-Process call
158204
$unityArgs = $unityArgs | Where-Object { $_ -ne $null }

src/model/build-parameters.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ describe('BuildParameters', () => {
7171
await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ projectPath: mockValue }));
7272
});
7373

74+
it('returns the build profile', async () => {
75+
const mockValue = 'path/to/build_profile.asset';
76+
jest.spyOn(Input, 'buildProfile', 'get').mockReturnValue(mockValue);
77+
await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ buildProfile: mockValue }));
78+
});
79+
7480
it('returns the build name', async () => {
7581
const mockValue = 'someBuildName';
7682
jest.spyOn(Input, 'buildName', 'get').mockReturnValue(mockValue);

src/model/build-parameters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class BuildParameters {
2626
public runnerTempPath!: string;
2727
public targetPlatform!: string;
2828
public projectPath!: string;
29+
public buildProfile!: string;
2930
public buildName!: string;
3031
public buildPath!: string;
3132
public buildFile!: string;
@@ -152,6 +153,7 @@ class BuildParameters {
152153
runnerTempPath: Input.runnerTempPath,
153154
targetPlatform: Input.targetPlatform,
154155
projectPath: Input.projectPath,
156+
buildProfile: Input.buildProfile,
155157
buildName: Input.buildName,
156158
buildPath: `${Input.buildsPath}/${Input.targetPlatform}`,
157159
buildFile,

src/model/image-environment-factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ImageEnvironmentFactory {
3636
value: process.env.USYM_UPLOAD_AUTH_TOKEN,
3737
},
3838
{ name: 'PROJECT_PATH', value: parameters.projectPath },
39+
{ name: 'BUILD_PROFILE', value: parameters.buildProfile },
3940
{ name: 'BUILD_TARGET', value: parameters.targetPlatform },
4041
{ name: 'BUILD_NAME', value: parameters.buildName },
4142
{ name: 'BUILD_PATH', value: parameters.buildPath },

src/model/input.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ describe('Input', () => {
5959
});
6060
});
6161

62+
describe('buildProfile', () => {
63+
it('returns the default value', () => {
64+
expect(Input.buildProfile).toStrictEqual('');
65+
});
66+
67+
it('takes input from the users workflow', () => {
68+
const mockValue = 'path/to/build_profile.asset';
69+
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
70+
expect(Input.buildProfile).toStrictEqual(mockValue);
71+
expect(spy).toHaveBeenCalledTimes(1);
72+
});
73+
});
74+
6275
describe('buildName', () => {
6376
it('returns the default value', () => {
6477
expect(Input.buildName).toStrictEqual(Input.targetPlatform);

src/model/input.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ class Input {
107107
return rawProjectPath.replace(/\/$/, '');
108108
}
109109

110+
static get buildProfile(): string {
111+
return Input.getInput('buildProfile') ?? '';
112+
}
113+
110114
static get runnerTempPath(): string {
111115
return Input.getInput('RUNNER_TEMP') ?? '';
112116
}

0 commit comments

Comments
 (0)