mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-01-29 20:39:07 +08:00
Compare commits
16 Commits
v1.4
...
v2.0-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
471bf0bdf0 | ||
|
|
6c2fbff839 | ||
|
|
17c28995b2 | ||
|
|
72ab50499d | ||
|
|
9269fba307 | ||
|
|
dc54ae10a5 | ||
|
|
5417369dba | ||
|
|
21c985b8e9 | ||
|
|
483b784253 | ||
|
|
e6d3daedbe | ||
|
|
046ab3a72d | ||
|
|
ec0baa5d7b | ||
|
|
5b8f3cf342 | ||
|
|
ef74241772 | ||
|
|
3d7e4a8018 | ||
|
|
91da660786 |
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:
|
||||
pull_request: {}
|
||||
push: { branches: [master] }
|
||||
push: { branches: [main] }
|
||||
|
||||
env:
|
||||
CODECOV_TOKEN: '2f2eb890-30e2-4724-83eb-7633832cf0de'
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
ARG IMAGE
|
||||
FROM $IMAGE
|
||||
|
||||
ARG UNAME=runner
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
LABEL "com.github.actions.name"="Unity - Builder"
|
||||
LABEL "com.github.actions.description"="Build Unity projects for different platforms."
|
||||
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 "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 steps /steps
|
||||
RUN chmod -R +x /steps
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
USER $UID:$GID
|
||||
|
||||
File diff suppressed because one or more lines are too long
20
action/steps/activate.sh
Normal file → Executable file
20
action/steps/activate.sh
Normal file → Executable file
@@ -24,8 +24,7 @@ if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
|
||||
fi
|
||||
|
||||
# Activate license
|
||||
ACTIVATION_OUTPUT=$(xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
ACTIVATION_OUTPUT=$(unity-editor \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
@@ -63,15 +62,14 @@ elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
|
||||
echo "Requesting activation (professional license)"
|
||||
|
||||
# Activate license
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-serial "$UNITY_SERIAL" \
|
||||
-username "$UNITY_EMAIL" \
|
||||
-password "$UNITY_PASSWORD"
|
||||
unity-editor \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-serial "$UNITY_SERIAL" \
|
||||
-username "$UNITY_EMAIL" \
|
||||
-password "$UNITY_PASSWORD"
|
||||
|
||||
# Store the exit code from the verify command
|
||||
UNITY_EXIT_CODE=$?
|
||||
|
||||
38
action/steps/build.sh
Normal file → Executable file
38
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
|
||||
mkdir -p "$UNITY_PROJECT_PATH/Assets/Editor/"
|
||||
# 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
|
||||
BUILD_METHOD="UnityBuilderAction.Builder.BuildProject"
|
||||
# Verify recursive paths
|
||||
@@ -108,24 +108,24 @@ echo "# Building platform #"
|
||||
echo "###########################"
|
||||
echo ""
|
||||
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-logfile /dev/stdout \
|
||||
-quit \
|
||||
-customBuildName "$BUILD_NAME" \
|
||||
-projectPath "$UNITY_PROJECT_PATH" \
|
||||
-buildTarget "$BUILD_TARGET" \
|
||||
-customBuildTarget "$BUILD_TARGET" \
|
||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||
-executeMethod "$BUILD_METHOD" \
|
||||
-buildVersion "$VERSION" \
|
||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||
-androidKeystoreName "$ANDROID_KEYSTORE_NAME" \
|
||||
-androidKeystorePass "$ANDROID_KEYSTORE_PASS" \
|
||||
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
|
||||
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
|
||||
$CUSTOM_PARAMETERS
|
||||
unity-editor \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logfile /dev/stdout \
|
||||
-quit \
|
||||
-customBuildName "$BUILD_NAME" \
|
||||
-projectPath "$UNITY_PROJECT_PATH" \
|
||||
-buildTarget "$BUILD_TARGET" \
|
||||
-customBuildTarget "$BUILD_TARGET" \
|
||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||
-executeMethod "$BUILD_METHOD" \
|
||||
-buildVersion "$VERSION" \
|
||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||
-androidKeystoreName "$ANDROID_KEYSTORE_NAME" \
|
||||
-androidKeystorePass "$ANDROID_KEYSTORE_PASS" \
|
||||
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
|
||||
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
|
||||
$CUSTOM_PARAMETERS
|
||||
|
||||
# Catch exit code
|
||||
BUILD_EXIT_CODE=$?
|
||||
|
||||
13
action/steps/return_license.sh
Normal file → Executable file
13
action/steps/return_license.sh
Normal file → Executable file
@@ -6,11 +6,10 @@ if [[ -n "$UNITY_SERIAL" ]]; then
|
||||
#
|
||||
# This will return the license that is currently in use.
|
||||
#
|
||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
/opt/Unity/Editor/Unity \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-returnlicense
|
||||
unity-editor \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-logFile /dev/stdout \
|
||||
-quit \
|
||||
-returnlicense
|
||||
fi
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "1.0.4",
|
||||
"@actions/github": "^2.1.1",
|
||||
"base-64": "^0.1.0",
|
||||
|
||||
@@ -16,13 +16,7 @@ async function action() {
|
||||
} else {
|
||||
// Build docker image
|
||||
// TODO: No image required (instead use a version published to dockerhub for the action, supply credentials for github cloning)
|
||||
const builtImage = await Docker.build({
|
||||
path: actionFolder,
|
||||
dockerfile,
|
||||
baseImage,
|
||||
uid: buildParameters.uid,
|
||||
gid: buildParameters.gid,
|
||||
});
|
||||
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||
await Docker.run(builtImage, { workspace, ...buildParameters });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import os from 'os';
|
||||
import AndroidVersioning from './android-versioning';
|
||||
import Input from './input';
|
||||
import Platform from './platform';
|
||||
@@ -21,13 +20,10 @@ class BuildParameters {
|
||||
Input.androidVersionCode,
|
||||
);
|
||||
|
||||
const { uid, gid } = os.userInfo();
|
||||
|
||||
return {
|
||||
version: Input.unityVersion,
|
||||
customImage: Input.customImage,
|
||||
uid,
|
||||
gid,
|
||||
|
||||
runnerTempPath: process.env.RUNNER_TEMP,
|
||||
platform: Input.targetPlatform,
|
||||
projectPath: Input.projectPath,
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import fs from 'fs';
|
||||
import { exec } from '@actions/exec';
|
||||
import ImageTag from './image-tag';
|
||||
|
||||
class Docker {
|
||||
static async build(buildParameters, silent = false) {
|
||||
const { path, dockerfile, baseImage, uid, gid } = buildParameters;
|
||||
const { path, dockerfile, baseImage } = buildParameters;
|
||||
const { version, platform } = baseImage;
|
||||
|
||||
const tag = new ImageTag({ repository: '', name: 'unity-builder', version, platform });
|
||||
const command = `docker build ${path} \
|
||||
--file ${dockerfile} \
|
||||
--build-arg IMAGE=${baseImage} \
|
||||
--build-arg UID=${uid} \
|
||||
--build-arg GID=${gid} \
|
||||
--tag ${tag}`;
|
||||
|
||||
await exec(command, undefined, { silent });
|
||||
@@ -86,9 +83,6 @@ class Docker {
|
||||
--volume "${workspace}":"/github/workspace" \
|
||||
${image}`;
|
||||
|
||||
fs.mkdirSync(`${runnerTempPath}/_github_home`, { recursive: true });
|
||||
fs.mkdirSync(`${runnerTempPath}/_github_workflow`, { recursive: true });
|
||||
|
||||
await exec(command, undefined, { silent });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import Platform from './platform';
|
||||
class ImageTag {
|
||||
constructor(imageProperties) {
|
||||
const {
|
||||
repository = 'gableroux',
|
||||
name = 'unity3d',
|
||||
repository = 'unityci',
|
||||
name = 'editor',
|
||||
version = '2019.2.11f1',
|
||||
platform,
|
||||
customImage,
|
||||
@@ -36,8 +36,9 @@ class ImageTag {
|
||||
return {
|
||||
generic: '',
|
||||
webgl: 'webgl',
|
||||
mac: 'mac',
|
||||
windows: 'windows',
|
||||
mac: 'mac-mono',
|
||||
windows: 'windows-mono',
|
||||
linux: 'base',
|
||||
android: 'android',
|
||||
ios: 'ios',
|
||||
facebook: 'facebook',
|
||||
@@ -45,14 +46,14 @@ class ImageTag {
|
||||
}
|
||||
|
||||
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
|
||||
return {
|
||||
[Platform.types.StandaloneOSX]: mac,
|
||||
[Platform.types.StandaloneWindows]: windows,
|
||||
[Platform.types.StandaloneWindows64]: windows,
|
||||
[Platform.types.StandaloneLinux64]: windows,
|
||||
[Platform.types.StandaloneLinux64]: linux,
|
||||
[Platform.types.iOS]: ios,
|
||||
[Platform.types.Android]: android,
|
||||
[Platform.types.WebGL]: webgl,
|
||||
@@ -87,7 +88,7 @@ class ImageTag {
|
||||
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 = {
|
||||
repository: 'gableroux',
|
||||
name: 'unity3d',
|
||||
image: 'gableroux/unity3d',
|
||||
repository: 'unityci',
|
||||
name: 'editor',
|
||||
image: 'unityci/editor',
|
||||
};
|
||||
|
||||
describe('constructor', () => {
|
||||
@@ -49,7 +49,7 @@ describe('UnityImageVersion', () => {
|
||||
it('returns the correct version', () => {
|
||||
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', () => {
|
||||
const image = new ImageTag({
|
||||
@@ -64,13 +64,13 @@ describe('UnityImageVersion', () => {
|
||||
it('returns the specific build platform', () => {
|
||||
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', () => {
|
||||
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
|
||||
|
||||
|
||||
"@actions/core@^1.2.4":
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.4.tgz#96179dbf9f8d951dd74b40a0dbd5c22555d186ab"
|
||||
"@actions/core@^1.2.6":
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
|
||||
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
|
||||
|
||||
"@actions/exec@1.0.4":
|
||||
version "1.0.4"
|
||||
|
||||
Reference in New Issue
Block a user