mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-02-03 23:49:08 +08:00
Compare commits
18 Commits
v1.3
...
v2.0-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e2a1b2d35 | ||
|
|
471bf0bdf0 | ||
|
|
6c2fbff839 | ||
|
|
17c28995b2 | ||
|
|
72ab50499d | ||
|
|
9269fba307 | ||
|
|
dc54ae10a5 | ||
|
|
5417369dba | ||
|
|
21c985b8e9 | ||
|
|
483b784253 | ||
|
|
e6d3daedbe | ||
|
|
046ab3a72d | ||
|
|
ec0baa5d7b | ||
|
|
5b8f3cf342 | ||
|
|
ef74241772 | ||
|
|
3d7e4a8018 | ||
|
|
91da660786 | ||
|
|
f42f7923ed |
13
.github/workflows/cleanup.yml
vendored
Normal file
13
.github/workflows/cleanup.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: Delete old artifacts
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '30 10 * * *' # every day at 10:30
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
delete-artifacts:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: kolpav/purge-artifacts-action@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
expire-in: 21 days
|
||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -2,7 +2,7 @@ name: Actions
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request: {}
|
pull_request: {}
|
||||||
push: { branches: [master] }
|
push: { branches: [main] }
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CODECOV_TOKEN: '2f2eb890-30e2-4724-83eb-7633832cf0de'
|
CODECOV_TOKEN: '2f2eb890-30e2-4724-83eb-7633832cf0de'
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
ARG IMAGE
|
ARG IMAGE
|
||||||
FROM $IMAGE
|
FROM $IMAGE
|
||||||
|
|
||||||
ARG UNAME=runner
|
|
||||||
ARG UID=1000
|
|
||||||
ARG GID=1000
|
|
||||||
|
|
||||||
LABEL "com.github.actions.name"="Unity - Builder"
|
LABEL "com.github.actions.name"="Unity - Builder"
|
||||||
LABEL "com.github.actions.description"="Build Unity projects for different platforms."
|
LABEL "com.github.actions.description"="Build Unity projects for different platforms."
|
||||||
LABEL "com.github.actions.icon"="box"
|
LABEL "com.github.actions.icon"="box"
|
||||||
@@ -14,15 +10,9 @@ LABEL "repository"="http://github.com/webbertakken/unity-actions"
|
|||||||
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
|
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
|
||||||
LABEL "maintainer"="Webber Takken <webber@takken.io>"
|
LABEL "maintainer"="Webber Takken <webber@takken.io>"
|
||||||
|
|
||||||
RUN bash -c 'mkdir -p /github/{home,workflow,workspace}' && chown $UID:$GID -R /github/
|
|
||||||
RUN getent group $GID || groupadd -g $GID $UNAME
|
|
||||||
RUN id -u $UID &>/dev/null || useradd -m -u $UID -g $GID -s /bin/bash -d /github/home $UNAME
|
|
||||||
|
|
||||||
ADD default-build-script /UnityBuilderAction
|
ADD default-build-script /UnityBuilderAction
|
||||||
ADD steps /steps
|
ADD steps /steps
|
||||||
RUN chmod -R +x /steps
|
RUN chmod -R +x /steps
|
||||||
ADD entrypoint.sh /entrypoint.sh
|
ADD entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
||||||
USER $UID:$GID
|
|
||||||
|
|||||||
17
action/entrypoint.sh
Normal file → Executable file
17
action/entrypoint.sh
Normal file → Executable file
@@ -8,6 +8,23 @@ source /steps/activate.sh
|
|||||||
source /steps/build.sh
|
source /steps/build.sh
|
||||||
source /steps/return_license.sh
|
source /steps/return_license.sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Instructions for debugging
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ $BUILD_EXIT_CODE -gt 0 ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "###########################"
|
||||||
|
echo "# Failure #"
|
||||||
|
echo "###########################"
|
||||||
|
echo ""
|
||||||
|
echo "Please note that the exit code is not very descriptive."
|
||||||
|
echo "Most likely it will not help you solve the issue."
|
||||||
|
echo ""
|
||||||
|
echo "To find the reason for failure: please search for errors in the log above."
|
||||||
|
echo ""
|
||||||
|
fi;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Exit with code from the build step.
|
# Exit with code from the build step.
|
||||||
#
|
#
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
21
action/steps/activate.sh
Normal file → Executable file
21
action/steps/activate.sh
Normal file → Executable file
@@ -24,9 +24,7 @@ if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Activate license
|
# Activate license
|
||||||
ACTIVATION_OUTPUT=$(xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
ACTIVATION_OUTPUT=$(unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
|
||||||
-batchmode \
|
|
||||||
-nographics \
|
-nographics \
|
||||||
-logFile /dev/stdout \
|
-logFile /dev/stdout \
|
||||||
-quit \
|
-quit \
|
||||||
@@ -63,15 +61,14 @@ elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
|
|||||||
echo "Requesting activation (professional license)"
|
echo "Requesting activation (professional license)"
|
||||||
|
|
||||||
# Activate license
|
# Activate license
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-batchmode \
|
||||||
-batchmode \
|
-nographics \
|
||||||
-nographics \
|
-logFile /dev/stdout \
|
||||||
-logFile /dev/stdout \
|
-quit \
|
||||||
-quit \
|
-serial "$UNITY_SERIAL" \
|
||||||
-serial "$UNITY_SERIAL" \
|
-username "$UNITY_EMAIL" \
|
||||||
-username "$UNITY_EMAIL" \
|
-password "$UNITY_PASSWORD"
|
||||||
-password "$UNITY_PASSWORD"
|
|
||||||
|
|
||||||
# Store the exit code from the verify command
|
# Store the exit code from the verify command
|
||||||
UNITY_EXIT_CODE=$?
|
UNITY_EXIT_CODE=$?
|
||||||
|
|||||||
37
action/steps/build.sh
Normal file → Executable file
37
action/steps/build.sh
Normal file → Executable file
@@ -48,7 +48,7 @@ if [ -z "$BUILD_METHOD" ]; then
|
|||||||
# Create Editor directory if it does not exist
|
# Create Editor directory if it does not exist
|
||||||
mkdir -p "$UNITY_PROJECT_PATH/Assets/Editor/"
|
mkdir -p "$UNITY_PROJECT_PATH/Assets/Editor/"
|
||||||
# Copy the build script of Unity Builder action
|
# Copy the build script of Unity Builder action
|
||||||
cp -r "/UnityBuilderAction/Assets/Editor" "$UNITY_PROJECT_PATH/Assets/Editor/"
|
cp -R "/UnityBuilderAction/Assets/Editor/" "$UNITY_PROJECT_PATH/Assets/Editor/"
|
||||||
# Set the Build method to that of UnityBuilder Action
|
# Set the Build method to that of UnityBuilder Action
|
||||||
BUILD_METHOD="UnityBuilderAction.Builder.BuildProject"
|
BUILD_METHOD="UnityBuilderAction.Builder.BuildProject"
|
||||||
# Verify recursive paths
|
# Verify recursive paths
|
||||||
@@ -108,24 +108,23 @@ echo "# Building platform #"
|
|||||||
echo "###########################"
|
echo "###########################"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-nographics \
|
||||||
-batchmode \
|
-logfile /dev/stdout \
|
||||||
-logfile /dev/stdout \
|
-quit \
|
||||||
-quit \
|
-customBuildName "$BUILD_NAME" \
|
||||||
-customBuildName "$BUILD_NAME" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-buildTarget "$BUILD_TARGET" \
|
||||||
-buildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
-executeMethod "$BUILD_METHOD" \
|
||||||
-executeMethod "$BUILD_METHOD" \
|
-buildVersion "$VERSION" \
|
||||||
-buildVersion "$VERSION" \
|
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
-androidKeystoreName "$ANDROID_KEYSTORE_NAME" \
|
||||||
-androidKeystoreName "$ANDROID_KEYSTORE_NAME" \
|
-androidKeystorePass "$ANDROID_KEYSTORE_PASS" \
|
||||||
-androidKeystorePass "$ANDROID_KEYSTORE_PASS" \
|
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
|
||||||
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
|
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
|
||||||
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
|
$CUSTOM_PARAMETERS
|
||||||
$CUSTOM_PARAMETERS
|
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
BUILD_EXIT_CODE=$?
|
BUILD_EXIT_CODE=$?
|
||||||
|
|||||||
12
action/steps/return_license.sh
Normal file → Executable file
12
action/steps/return_license.sh
Normal file → Executable file
@@ -6,11 +6,9 @@ if [[ -n "$UNITY_SERIAL" ]]; then
|
|||||||
#
|
#
|
||||||
# This will return the license that is currently in use.
|
# This will return the license that is currently in use.
|
||||||
#
|
#
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
unity-editor \
|
||||||
/opt/Unity/Editor/Unity \
|
-nographics \
|
||||||
-batchmode \
|
-logFile /dev/stdout \
|
||||||
-nographics \
|
-quit \
|
||||||
-logFile /dev/stdout \
|
-returnlicense
|
||||||
-quit \
|
|
||||||
-returnlicense
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.4",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "1.0.4",
|
"@actions/exec": "1.0.4",
|
||||||
"@actions/github": "^2.1.1",
|
"@actions/github": "^2.1.1",
|
||||||
"base-64": "^0.1.0",
|
"base-64": "^0.1.0",
|
||||||
|
|||||||
@@ -16,13 +16,7 @@ async function action() {
|
|||||||
} else {
|
} else {
|
||||||
// Build docker image
|
// Build docker image
|
||||||
// TODO: No image required (instead use a version published to dockerhub for the action, supply credentials for github cloning)
|
// TODO: No image required (instead use a version published to dockerhub for the action, supply credentials for github cloning)
|
||||||
const builtImage = await Docker.build({
|
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
path: actionFolder,
|
|
||||||
dockerfile,
|
|
||||||
baseImage,
|
|
||||||
uid: buildParameters.uid,
|
|
||||||
gid: buildParameters.gid,
|
|
||||||
});
|
|
||||||
await Docker.run(builtImage, { workspace, ...buildParameters });
|
await Docker.run(builtImage, { workspace, ...buildParameters });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import os from 'os';
|
|
||||||
import AndroidVersioning from './android-versioning';
|
import AndroidVersioning from './android-versioning';
|
||||||
import Input from './input';
|
import Input from './input';
|
||||||
import Platform from './platform';
|
import Platform from './platform';
|
||||||
@@ -21,13 +20,10 @@ class BuildParameters {
|
|||||||
Input.androidVersionCode,
|
Input.androidVersionCode,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { uid, gid } = os.userInfo();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: Input.unityVersion,
|
version: Input.unityVersion,
|
||||||
customImage: Input.customImage,
|
customImage: Input.customImage,
|
||||||
uid,
|
|
||||||
gid,
|
|
||||||
runnerTempPath: process.env.RUNNER_TEMP,
|
runnerTempPath: process.env.RUNNER_TEMP,
|
||||||
platform: Input.targetPlatform,
|
platform: Input.targetPlatform,
|
||||||
projectPath: Input.projectPath,
|
projectPath: Input.projectPath,
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
import fs from 'fs';
|
|
||||||
import { exec } from '@actions/exec';
|
import { exec } from '@actions/exec';
|
||||||
import ImageTag from './image-tag';
|
import ImageTag from './image-tag';
|
||||||
|
|
||||||
class Docker {
|
class Docker {
|
||||||
static async build(buildParameters, silent = false) {
|
static async build(buildParameters, silent = false) {
|
||||||
const { path, dockerfile, baseImage, uid, gid } = buildParameters;
|
const { path, dockerfile, baseImage } = buildParameters;
|
||||||
const { version, platform } = baseImage;
|
const { version, platform } = baseImage;
|
||||||
|
|
||||||
const tag = new ImageTag({ repository: '', name: 'unity-builder', version, platform });
|
const tag = new ImageTag({ repository: '', name: 'unity-builder', version, platform });
|
||||||
const command = `docker build ${path} \
|
const command = `docker build ${path} \
|
||||||
--file ${dockerfile} \
|
--file ${dockerfile} \
|
||||||
--build-arg IMAGE=${baseImage} \
|
--build-arg IMAGE=${baseImage} \
|
||||||
--build-arg UID=${uid} \
|
|
||||||
--build-arg GID=${gid} \
|
|
||||||
--tag ${tag}`;
|
--tag ${tag}`;
|
||||||
|
|
||||||
await exec(command, undefined, { silent });
|
await exec(command, undefined, { silent });
|
||||||
@@ -86,9 +83,6 @@ class Docker {
|
|||||||
--volume "${workspace}":"/github/workspace" \
|
--volume "${workspace}":"/github/workspace" \
|
||||||
${image}`;
|
${image}`;
|
||||||
|
|
||||||
fs.mkdirSync(`${runnerTempPath}/_github_home`, { recursive: true });
|
|
||||||
fs.mkdirSync(`${runnerTempPath}/_github_workflow`, { recursive: true });
|
|
||||||
|
|
||||||
await exec(command, undefined, { silent });
|
await exec(command, undefined, { silent });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import Platform from './platform';
|
|||||||
class ImageTag {
|
class ImageTag {
|
||||||
constructor(imageProperties) {
|
constructor(imageProperties) {
|
||||||
const {
|
const {
|
||||||
repository = 'gableroux',
|
repository = 'unityci',
|
||||||
name = 'unity3d',
|
name = 'editor',
|
||||||
version = '2019.2.11f1',
|
version = '2019.2.11f1',
|
||||||
platform,
|
platform,
|
||||||
customImage,
|
customImage,
|
||||||
@@ -36,8 +36,9 @@ class ImageTag {
|
|||||||
return {
|
return {
|
||||||
generic: '',
|
generic: '',
|
||||||
webgl: 'webgl',
|
webgl: 'webgl',
|
||||||
mac: 'mac',
|
mac: 'mac-mono',
|
||||||
windows: 'windows',
|
windows: 'windows-mono',
|
||||||
|
linux: 'base',
|
||||||
android: 'android',
|
android: 'android',
|
||||||
ios: 'ios',
|
ios: 'ios',
|
||||||
facebook: 'facebook',
|
facebook: 'facebook',
|
||||||
@@ -45,14 +46,14 @@ class ImageTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static get targetPlatformToImageSuffixMap() {
|
static get targetPlatformToImageSuffixMap() {
|
||||||
const { generic, webgl, mac, windows, android, ios, facebook } = ImageTag.imageSuffixes;
|
const { generic, webgl, mac, windows, linux, android, ios, facebook } = ImageTag.imageSuffixes;
|
||||||
|
|
||||||
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
||||||
return {
|
return {
|
||||||
[Platform.types.StandaloneOSX]: mac,
|
[Platform.types.StandaloneOSX]: mac,
|
||||||
[Platform.types.StandaloneWindows]: windows,
|
[Platform.types.StandaloneWindows]: windows,
|
||||||
[Platform.types.StandaloneWindows64]: windows,
|
[Platform.types.StandaloneWindows64]: windows,
|
||||||
[Platform.types.StandaloneLinux64]: windows,
|
[Platform.types.StandaloneLinux64]: linux,
|
||||||
[Platform.types.iOS]: ios,
|
[Platform.types.iOS]: ios,
|
||||||
[Platform.types.Android]: android,
|
[Platform.types.Android]: android,
|
||||||
[Platform.types.WebGL]: webgl,
|
[Platform.types.WebGL]: webgl,
|
||||||
@@ -87,7 +88,7 @@ class ImageTag {
|
|||||||
return this.customImage;
|
return this.customImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${image}:${tag}`;
|
return `${image}:${tag}-0`; // '0' here represents the docker repo version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ describe('UnityImageVersion', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const defaults = {
|
const defaults = {
|
||||||
repository: 'gableroux',
|
repository: 'unityci',
|
||||||
name: 'unity3d',
|
name: 'editor',
|
||||||
image: 'gableroux/unity3d',
|
image: 'unityci/editor',
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('constructor', () => {
|
describe('constructor', () => {
|
||||||
@@ -49,7 +49,7 @@ describe('UnityImageVersion', () => {
|
|||||||
it('returns the correct version', () => {
|
it('returns the correct version', () => {
|
||||||
const image = new ImageTag({ version: '2099.1.1111', platform: some.platform });
|
const image = new ImageTag({ version: '2099.1.1111', platform: some.platform });
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2099.1.1111`);
|
expect(image.toString()).toStrictEqual(`${defaults.image}:2099.1.1111-0`);
|
||||||
});
|
});
|
||||||
it('returns customImage if given', () => {
|
it('returns customImage if given', () => {
|
||||||
const image = new ImageTag({
|
const image = new ImageTag({
|
||||||
@@ -64,13 +64,13 @@ describe('UnityImageVersion', () => {
|
|||||||
it('returns the specific build platform', () => {
|
it('returns the specific build platform', () => {
|
||||||
const image = new ImageTag({ version: '2019.2.11f1', platform: 'WebGL' });
|
const image = new ImageTag({ version: '2019.2.11f1', platform: 'WebGL' });
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-webgl`);
|
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-webgl-0`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns no specific build platform for generic targetPlatforms', () => {
|
it('returns no specific build platform for generic targetPlatforms', () => {
|
||||||
const image = new ImageTag({ platform: 'NoTarget' });
|
const image = new ImageTag({ platform: 'NoTarget' });
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1`);
|
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-0`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
"@actions/core@^1.2.4":
|
"@actions/core@^1.2.6":
|
||||||
version "1.2.4"
|
version "1.2.6"
|
||||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.4.tgz#96179dbf9f8d951dd74b40a0dbd5c22555d186ab"
|
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
|
||||||
|
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
|
||||||
|
|
||||||
"@actions/exec@1.0.4":
|
"@actions/exec@1.0.4":
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user