mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-01-29 12:19:06 +08:00
Compare commits
5 Commits
check-inte
...
v1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3523c6a934 | ||
|
|
bf702784d2 | ||
|
|
bdc3a88d22 | ||
|
|
401ddcaae0 | ||
|
|
1245bfefc8 |
29
.github/workflows/activation.yml
vendored
29
.github/workflows/activation.yml
vendored
@@ -1,29 +0,0 @@
|
|||||||
#name: Acquire activation file
|
|
||||||
#
|
|
||||||
#on: [push]
|
|
||||||
#
|
|
||||||
#jobs:
|
|
||||||
# activation:
|
|
||||||
# name: Request manual activation file (${{ matrix.unityVersion }}) 🔑
|
|
||||||
# runs-on: ubuntu-latest
|
|
||||||
# strategy:
|
|
||||||
# fail-fast: false
|
|
||||||
# matrix:
|
|
||||||
# unityVersion:
|
|
||||||
# - 2019.2.11f1
|
|
||||||
# - 2019.3.15f1
|
|
||||||
#
|
|
||||||
# steps:
|
|
||||||
# # Request manual activation file
|
|
||||||
# - name: Request manual activation file
|
|
||||||
# id: getManualLicenseFile
|
|
||||||
# uses: webbertakken/unity-request-manual-activation-file@v1.1
|
|
||||||
# with:
|
|
||||||
# unityVersion: ${{ matrix.unityVersion }}
|
|
||||||
#
|
|
||||||
# # Upload artifact (Unity_v20XX.X.XXXX.alf)
|
|
||||||
# - name: Expose as artifact
|
|
||||||
# uses: actions/upload-artifact@v1
|
|
||||||
# with:
|
|
||||||
# name: ${{ steps.getManualLicenseFile.outputs.filePath }}
|
|
||||||
# path: ${{ steps.getManualLicenseFile.outputs.filePath }}
|
|
||||||
31
.github/workflows/main.yml
vendored
31
.github/workflows/main.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Actions 😎
|
name: Actions
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request: {}
|
pull_request: {}
|
||||||
@@ -44,11 +44,11 @@ jobs:
|
|||||||
license: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>\n <License id=\"Terms\">\n <MachineBindings>\n <Binding Key=\"1\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n <Binding Key=\"2\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n </MachineBindings>\n <MachineID Value=\"xWka2iXdDJejhZdi/zU2RUeXUi4=\"/>\n <SerialHash Value=\"1efd68fa935192b6090ac03c77d289a9f588c55a\"/>\n <Features>\n <Feature Value=\"33\"/>\n <Feature Value=\"1\"/>\n <Feature Value=\"12\"/>\n <Feature Value=\"2\"/>\n <Feature Value=\"24\"/>\n <Feature Value=\"3\"/>\n <Feature Value=\"36\"/>\n <Feature Value=\"17\"/>\n <Feature Value=\"19\"/>\n <Feature Value=\"62\"/>\n </Features>\n <DeveloperData Value=\"AQAAAEY0LUg2WFMtUE00NS1SM0M4LUUyWlotWkdWOA==\"/>\n <SerialMasked Value=\"F4-H6XS-PM45-R3C8-E2ZZ-XXXX\"/>\n <StartDate Value=\"2018-05-02T00:00:00\"/>\n <UpdateDate Value=\"2020-06-14T13:49:47\"/>\n <InitialActivationDate Value=\"2018-05-02T14:21:28\"/>\n <LicenseVersion Value=\"6.x\"/>\n <ClientProvidedVersion Value=\"2019.3.15f1\"/>\n <AlwaysOnline Value=\"false\"/>\n <Entitlements>\n <Entitlement Ns=\"unity_editor\" Tag=\"UnityPersonal\" Type=\"EDITOR\" ValidTo=\"9999-12-31T00:00:00\"/>\n </Entitlements>\n </License>\n<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\"/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><Reference URI=\"#Terms\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>bpzWx3PZ0lqWDo1m9aLQuZ4cweo=</DigestValue></Reference></SignedInfo><SignatureValue>QcDm4/qAXZuUMQbUVk63vO6u66Bp8PnqqWQcZZOcym/rGUZLj1sr66EquF3X3w1L7aqiwMGtbY2b\nkPttcalFeaBkc5NsJMrexWjuBCxQvhbmVFQnTjvC6vNS+k1wrkz7If1oPkz/XaDtCfUs8oxc9iPe\nPzzUJIVYLZoDtpPq2XbgVn9/TiVb3Zu6ldKgvtNRYUjrB3KywtvL9OcIFll3htRcBZPG43kxryJc\nDD2TL5Nw1JuX6MejBBuYTZsZNpGX9Pjop9+uFUZ4GI9h8a5g6wJUfXzsGw7j4gkvDkC9MvyWiksi\n2hNXw1QNeB6JfQsd4sAuhYh/CqTm2gCz9i9ZpA==</SignatureValue></Signature></root>"
|
license: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>\n <License id=\"Terms\">\n <MachineBindings>\n <Binding Key=\"1\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n <Binding Key=\"2\" Value=\"33bf639e81e54693a8f9bf57c8900e5a\"/>\n </MachineBindings>\n <MachineID Value=\"xWka2iXdDJejhZdi/zU2RUeXUi4=\"/>\n <SerialHash Value=\"1efd68fa935192b6090ac03c77d289a9f588c55a\"/>\n <Features>\n <Feature Value=\"33\"/>\n <Feature Value=\"1\"/>\n <Feature Value=\"12\"/>\n <Feature Value=\"2\"/>\n <Feature Value=\"24\"/>\n <Feature Value=\"3\"/>\n <Feature Value=\"36\"/>\n <Feature Value=\"17\"/>\n <Feature Value=\"19\"/>\n <Feature Value=\"62\"/>\n </Features>\n <DeveloperData Value=\"AQAAAEY0LUg2WFMtUE00NS1SM0M4LUUyWlotWkdWOA==\"/>\n <SerialMasked Value=\"F4-H6XS-PM45-R3C8-E2ZZ-XXXX\"/>\n <StartDate Value=\"2018-05-02T00:00:00\"/>\n <UpdateDate Value=\"2020-06-14T13:49:47\"/>\n <InitialActivationDate Value=\"2018-05-02T14:21:28\"/>\n <LicenseVersion Value=\"6.x\"/>\n <ClientProvidedVersion Value=\"2019.3.15f1\"/>\n <AlwaysOnline Value=\"false\"/>\n <Entitlements>\n <Entitlement Ns=\"unity_editor\" Tag=\"UnityPersonal\" Type=\"EDITOR\" ValidTo=\"9999-12-31T00:00:00\"/>\n </Entitlements>\n </License>\n<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\"/><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/><Reference URI=\"#Terms\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>bpzWx3PZ0lqWDo1m9aLQuZ4cweo=</DigestValue></Reference></SignedInfo><SignatureValue>QcDm4/qAXZuUMQbUVk63vO6u66Bp8PnqqWQcZZOcym/rGUZLj1sr66EquF3X3w1L7aqiwMGtbY2b\nkPttcalFeaBkc5NsJMrexWjuBCxQvhbmVFQnTjvC6vNS+k1wrkz7If1oPkz/XaDtCfUs8oxc9iPe\nPzzUJIVYLZoDtpPq2XbgVn9/TiVb3Zu6ldKgvtNRYUjrB3KywtvL9OcIFll3htRcBZPG43kxryJc\nDD2TL5Nw1JuX6MejBBuYTZsZNpGX9Pjop9+uFUZ4GI9h8a5g6wJUfXzsGw7j4gkvDkC9MvyWiksi\n2hNXw1QNeB6JfQsd4sAuhYh/CqTm2gCz9i9ZpA==</SignatureValue></Signature></root>"
|
||||||
targetPlatform:
|
targetPlatform:
|
||||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
||||||
- StandaloneWindows # Build a Windows standalone.
|
|
||||||
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
||||||
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
||||||
- iOS # Build an iOS player.
|
- iOS # Build an iOS player.
|
||||||
# - Android # Build an Android .apk standalone app.
|
- Android # Build an Android .apk.
|
||||||
|
# - StandaloneWindows # Build a Windows standalone.
|
||||||
# - WebGL # WebGL.
|
# - WebGL # WebGL.
|
||||||
# - WSAPlayer # Build an Windows Store Apps player.
|
# - WSAPlayer # Build an Windows Store Apps player.
|
||||||
# - PS4 # Build a PS4 Standalone.
|
# - PS4 # Build a PS4 Standalone.
|
||||||
@@ -74,8 +74,33 @@ jobs:
|
|||||||
projectPath: ${{ matrix.projectPath }}
|
projectPath: ${{ matrix.projectPath }}
|
||||||
unityVersion: ${{ matrix.unityVersion }}
|
unityVersion: ${{ matrix.unityVersion }}
|
||||||
targetPlatform: ${{ matrix.targetPlatform }}
|
targetPlatform: ${{ matrix.targetPlatform }}
|
||||||
|
androidVersionCode: ${{ github.run_number }}
|
||||||
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
|
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: Build (${{ matrix.unityVersion }})
|
name: Build (${{ matrix.unityVersion }})
|
||||||
path: build
|
path: build
|
||||||
|
# activation:
|
||||||
|
# name: Request manual activation file (${{ matrix.unityVersion }}) 🔑
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# strategy:
|
||||||
|
# fail-fast: false
|
||||||
|
# matrix:
|
||||||
|
# unityVersion:
|
||||||
|
# - 2019.2.11f1
|
||||||
|
# - 2019.3.15f1
|
||||||
|
#
|
||||||
|
# steps:
|
||||||
|
# # Request manual activation file
|
||||||
|
# - name: Request manual activation file
|
||||||
|
# id: getManualLicenseFile
|
||||||
|
# uses: webbertakken/unity-request-manual-activation-file@v1.1
|
||||||
|
# with:
|
||||||
|
# unityVersion: ${{ matrix.unityVersion }}
|
||||||
|
#
|
||||||
|
# # Upload artifact (Unity_v20XX.X.XXXX.alf)
|
||||||
|
# - name: Expose as artifact
|
||||||
|
# uses: actions/upload-artifact@v1
|
||||||
|
# with:
|
||||||
|
# name: ${{ steps.getManualLicenseFile.outputs.filePath }}
|
||||||
|
# path: ${{ steps.getManualLicenseFile.outputs.filePath }}
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Unity - Builder
|
# Unity - Builder
|
||||||
|
|
||||||
[](https://github.com/webbertakken/unity-builder/actions?query=branch%3Amaster+event%3Apush+workflow%3A%22Actions+%F0%9F%98%8E%22)
|
[](https://github.com/webbertakken/unity-builder/actions?query=branch%3Amaster+event%3Apush+workflow%3A%22Actions)
|
||||||
[](https://lgtm.com/projects/g/webbertakken/unity-builder/context:javascript)
|
[](https://lgtm.com/projects/g/webbertakken/unity-builder/context:javascript)
|
||||||
[](https://codecov.io/gh/webbertakken/unity-builder)
|
[](https://codecov.io/gh/webbertakken/unity-builder)
|
||||||
|
|
||||||
@@ -268,15 +268,15 @@ Find the available strategies below:
|
|||||||
|
|
||||||
Versioning out of the box! **(recommended)**
|
Versioning out of the box! **(recommended)**
|
||||||
|
|
||||||
> Compatible with **all platforms**.
|
> Compatible with **all platforms**.
|
||||||
> Does **not** modify your repository.
|
> Does **not** modify your repository.
|
||||||
> Requires **zero configuration**.
|
> Requires **zero configuration**.
|
||||||
|
|
||||||
How it works:
|
How it works:
|
||||||
|
|
||||||
> Generates a version based on [semantic versioning](https://semver.org/).
|
> Generates a version based on [semantic versioning](https://semver.org/).
|
||||||
> Follows `<major>.<minor>.<patch>` for example `0.17.2`.
|
> Follows `<major>.<minor>.<patch>` for example `0.17.2`.
|
||||||
> The latest tag dictates `<major>.<minor>` (defaults to 0.0 for no tag).
|
> The latest tag dictates `<major>.<minor>` (defaults to 0.0 for no tag).
|
||||||
> The number of commits (since the last tag, if any) is used for `<patch>`.
|
> The number of commits (since the last tag, if any) is used for `<patch>`.
|
||||||
|
|
||||||
No configuration required.
|
No configuration required.
|
||||||
@@ -295,6 +295,12 @@ No version will be set by Builder. **(not recommended)**
|
|||||||
> Not recommended unless you generate a new version in a pre-commit hook. Manually
|
> Not recommended unless you generate a new version in a pre-commit hook. Manually
|
||||||
> setting versions is error-prone.
|
> setting versions is error-prone.
|
||||||
|
|
||||||
|
#### androidVersionCode
|
||||||
|
|
||||||
|
Configure the android `versionCode`.
|
||||||
|
|
||||||
|
When not specified, the version code is generated from the version using the `major * 1000000 + minor * 1000 + patch` scheme;
|
||||||
|
|
||||||
#### allowDirtyBuild
|
#### allowDirtyBuild
|
||||||
|
|
||||||
Allows the branch of the build to be dirty, and still generate the build.
|
Allows the branch of the build to be dirty, and still generate the build.
|
||||||
|
|||||||
20
action.yml
20
action.yml
@@ -26,6 +26,26 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.'
|
description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.'
|
||||||
|
versioning:
|
||||||
|
required: false
|
||||||
|
default: 'Semantic'
|
||||||
|
description: 'The versioning scheme to use when building the project'
|
||||||
|
version:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: 'The version, when used with the "Custom" versioning scheme'
|
||||||
|
androidVersionCode:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: 'The android versionCode'
|
||||||
|
customParameters:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: >
|
||||||
|
Custom parameters to configure the build.
|
||||||
|
|
||||||
|
Parameters must start with a hyphen (-) and may be followed by a value (without hyphen).
|
||||||
|
Parameters without a value will be considered booleans (with a value of true).
|
||||||
outputs: {}
|
outputs: {}
|
||||||
branding:
|
branding:
|
||||||
icon: 'box'
|
icon: 'box'
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace UnityBuilderAction
|
|||||||
|
|
||||||
// Set version for this build
|
// Set version for this build
|
||||||
VersionApplicator.SetVersion(options["version"]);
|
VersionApplicator.SetVersion(options["version"]);
|
||||||
|
VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);
|
||||||
|
|
||||||
// Perform build
|
// Perform build
|
||||||
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
|
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
namespace UnityBuilderAction.Versioning
|
namespace UnityBuilderAction.Versioning
|
||||||
@@ -11,10 +10,14 @@ namespace UnityBuilderAction.Versioning
|
|||||||
if (version == "none") {
|
if (version == "none") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Apply(version);
|
Apply(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetAndroidVersionCode(string androidVersionCode) {
|
||||||
|
PlayerSettings.Android.bundleVersionCode = Int32.Parse(androidVersionCode);
|
||||||
|
}
|
||||||
|
|
||||||
static void Apply(string version)
|
static void Apply(string version)
|
||||||
{
|
{
|
||||||
PlayerSettings.bundleVersion = version;
|
PlayerSettings.bundleVersion = version;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -109,8 +109,8 @@ xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
|||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||||
-executeMethod "$BUILD_METHOD" \
|
-executeMethod "$BUILD_METHOD" \
|
||||||
-versioning "$VERSIONING" \
|
|
||||||
-version "$VERSION" \
|
-version "$VERSION" \
|
||||||
|
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||||
$CUSTOM_PARAMETERS
|
$CUSTOM_PARAMETERS
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
|
|||||||
@@ -10,12 +10,14 @@
|
|||||||
"prebuild": "yarn",
|
"prebuild": "yarn",
|
||||||
"build": "ncc build src --out action --minify",
|
"build": "ncc build src --out action --minify",
|
||||||
"lint": "prettier --check \"src/**/*.js\" && eslint src",
|
"lint": "prettier --check \"src/**/*.js\" && eslint src",
|
||||||
|
"format": "prettier --write \"src/**/*.js\"",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.4",
|
"@actions/core": "^1.2.4",
|
||||||
"@actions/exec": "1.0.4",
|
"@actions/exec": "1.0.4",
|
||||||
"@actions/github": "^2.1.1"
|
"@actions/github": "^2.1.1",
|
||||||
|
"semver": "^7.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "7.8.4",
|
"@babel/cli": "7.8.4",
|
||||||
|
|||||||
33
src/model/android-versioning.js
Normal file
33
src/model/android-versioning.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as semver from 'semver';
|
||||||
|
|
||||||
|
export default class AndroidVersioning {
|
||||||
|
static determineVersionCode(version, inputVersionCode) {
|
||||||
|
if (!inputVersionCode) {
|
||||||
|
return AndroidVersioning.versionToVersionCode(version);
|
||||||
|
}
|
||||||
|
return inputVersionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static versionToVersionCode(version) {
|
||||||
|
const parsedVersion = semver.parse(version);
|
||||||
|
|
||||||
|
if (!parsedVersion) {
|
||||||
|
core.warning(`Could not parse "${version}" to semver, defaulting android version code to 1`);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The greatest value Google Plays allows is 2100000000.
|
||||||
|
// Allow for 3 patch digits, 3 minor digits and 3 major digits.
|
||||||
|
const versionCode =
|
||||||
|
parsedVersion.major * 1000000 + parsedVersion.minor * 1000 + parsedVersion.patch;
|
||||||
|
|
||||||
|
if (versionCode >= 1000000000) {
|
||||||
|
throw new Error(
|
||||||
|
`Generated versionCode ${versionCode} is dangerously close to the maximum allowed number 2100000000. Consider a different versioning scheme to be able to continue updating your application.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
core.info(`Using android versionCode ${versionCode}`);
|
||||||
|
return versionCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
27
src/model/android-versioning.test.js
Normal file
27
src/model/android-versioning.test.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import AndroidVersioning from './android-versioning';
|
||||||
|
|
||||||
|
describe('Android Versioning', () => {
|
||||||
|
describe('versionToVersionCode', () => {
|
||||||
|
it('defaults to 1 when version is not a valid semver', () => {
|
||||||
|
expect(AndroidVersioning.versionToVersionCode('abcd')).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a number', () => {
|
||||||
|
expect(AndroidVersioning.versionToVersionCode('123.456.789')).toBe(123456789);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throw when generated version code is too large', () => {
|
||||||
|
expect(() => AndroidVersioning.versionToVersionCode('1234.0.0')).toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('determineVersionCode', () => {
|
||||||
|
it('defaults to parsed version', () => {
|
||||||
|
expect(AndroidVersioning.determineVersionCode('1.2.3', '')).toBe(1002003);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('use specified code', () => {
|
||||||
|
expect(AndroidVersioning.determineVersionCode('1.2.3', 2)).toBe(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import AndroidVersioning from './android-versioning';
|
||||||
import Input from './input';
|
import Input from './input';
|
||||||
import Platform from './platform';
|
import Platform from './platform';
|
||||||
import Versioning from './versioning';
|
import Versioning from './versioning';
|
||||||
@@ -10,6 +11,11 @@ class BuildParameters {
|
|||||||
Input.specifiedVersion,
|
Input.specifiedVersion,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const androidVersionCode = AndroidVersioning.determineVersionCode(
|
||||||
|
buildVersion,
|
||||||
|
Input.androidVersionCode,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: Input.unityVersion,
|
version: Input.unityVersion,
|
||||||
platform: Input.targetPlatform,
|
platform: Input.targetPlatform,
|
||||||
@@ -19,6 +25,7 @@ class BuildParameters {
|
|||||||
buildFile,
|
buildFile,
|
||||||
buildMethod: Input.buildMethod,
|
buildMethod: Input.buildMethod,
|
||||||
buildVersion,
|
buildVersion,
|
||||||
|
androidVersionCode,
|
||||||
customParameters: Input.customParameters,
|
customParameters: Input.customParameters,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,22 @@ describe('BuildParameters', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns the android version code with provided input', async () => {
|
||||||
|
const mockValue = '42';
|
||||||
|
jest.spyOn(Input, 'androidVersionCode', 'get').mockReturnValue(mockValue);
|
||||||
|
await expect(BuildParameters.create()).resolves.toEqual(
|
||||||
|
expect.objectContaining({ androidVersionCode: mockValue }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the android version code from version by default', async () => {
|
||||||
|
const mockValue = '';
|
||||||
|
jest.spyOn(Input, 'androidVersionCode', 'get').mockReturnValue(mockValue);
|
||||||
|
await expect(BuildParameters.create()).resolves.toEqual(
|
||||||
|
expect.objectContaining({ androidVersionCode: 1003037 }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('returns the platform', async () => {
|
it('returns the platform', async () => {
|
||||||
const mockValue = 'somePlatform';
|
const mockValue = 'somePlatform';
|
||||||
jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(mockValue);
|
jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(mockValue);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class Docker {
|
|||||||
buildMethod,
|
buildMethod,
|
||||||
buildVersion,
|
buildVersion,
|
||||||
customParameters,
|
customParameters,
|
||||||
|
androidVersionCode,
|
||||||
} = parameters;
|
} = parameters;
|
||||||
|
|
||||||
const command = `docker run \
|
const command = `docker run \
|
||||||
@@ -47,6 +48,7 @@ class Docker {
|
|||||||
--env BUILD_FILE="${buildFile}" \
|
--env BUILD_FILE="${buildFile}" \
|
||||||
--env BUILD_METHOD="${buildMethod}" \
|
--env BUILD_METHOD="${buildMethod}" \
|
||||||
--env VERSION="${buildVersion}" \
|
--env VERSION="${buildVersion}" \
|
||||||
|
--env ANDROID_VERSION_CODE="${androidVersionCode}" \
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env HOME=/github/home \
|
--env HOME=/github/home \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe('Docker', () => {
|
|||||||
const parameters = {
|
const parameters = {
|
||||||
workspace: Action.rootFolder,
|
workspace: Action.rootFolder,
|
||||||
projectPath: `${Action.rootFolder}/test-project`,
|
projectPath: `${Action.rootFolder}/test-project`,
|
||||||
buildName: 'someBulidName',
|
buildName: 'someBuildName',
|
||||||
buildsPath: 'build',
|
buildsPath: 'build',
|
||||||
method: '',
|
method: '',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class Input {
|
|||||||
return core.getInput('version') || '';
|
return core.getInput('version') || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get androidVersionCode() {
|
||||||
|
return core.getInput('androidVersionCode');
|
||||||
|
}
|
||||||
|
|
||||||
static get allowDirtyBuild() {
|
static get allowDirtyBuild() {
|
||||||
const input = core.getInput('allowDirtyBuild') || 'false';
|
const input = core.getInput('allowDirtyBuild') || 'false';
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,19 @@ describe('Input', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('androidVersionCode', () => {
|
||||||
|
it('defaults to null', () => {
|
||||||
|
expect(Input.androidVersionCode).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes input from the users workflow', () => {
|
||||||
|
const mockValue = '42';
|
||||||
|
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
|
||||||
|
expect(Input.androidVersionCode).toStrictEqual(mockValue);
|
||||||
|
expect(spy).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('allowDirtyBuild', () => {
|
describe('allowDirtyBuild', () => {
|
||||||
it('returns the default value', () => {
|
it('returns the default value', () => {
|
||||||
expect(Input.allowDirtyBuild).toStrictEqual('false');
|
expect(Input.allowDirtyBuild).toStrictEqual('false');
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ export default class Versioning {
|
|||||||
return process.env.GITHUB_REF;
|
return process.env.GITHUB_REF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The commit SHA that triggered the workflow run.
|
||||||
|
*/
|
||||||
|
static get sha() {
|
||||||
|
return process.env.GITHUB_SHA;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regex to parse version description into separate fields
|
* Regex to parse version description into separate fields
|
||||||
*/
|
*/
|
||||||
@@ -162,8 +169,7 @@ export default class Versioning {
|
|||||||
* identifies the current commit.
|
* identifies the current commit.
|
||||||
*/
|
*/
|
||||||
static async getVersionDescription() {
|
static async getVersionDescription() {
|
||||||
const commitIsh = (await this.getTag()) ? 'HEAD' : `origin/${this.branch}`;
|
return this.git(['describe', '--long', '--tags', '--always', '--debug', this.sha]);
|
||||||
return this.git(['describe', '--long', '--tags', '--always', '--debug', commitIsh]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,11 +208,7 @@ export default class Versioning {
|
|||||||
* Note: HEAD should not be used, as it may be detached, resulting in an additional count.
|
* Note: HEAD should not be used, as it may be detached, resulting in an additional count.
|
||||||
*/
|
*/
|
||||||
static async getTotalNumberOfCommits() {
|
static async getTotalNumberOfCommits() {
|
||||||
const numberOfCommitsAsString = await this.git([
|
const numberOfCommitsAsString = await this.git(['rev-list', '--count', this.sha]);
|
||||||
'rev-list',
|
|
||||||
'--count',
|
|
||||||
`origin/${this.branch}`,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return Number.parseInt(numberOfCommitsAsString, 10);
|
return Number.parseInt(numberOfCommitsAsString, 10);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5045,7 +5045,7 @@ semver@^6.0.0, semver@^6.1.2, semver@^6.3.0:
|
|||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||||
|
|
||||||
semver@^7.1.3:
|
semver@^7.1.3, semver@^7.3.2:
|
||||||
version "7.3.2"
|
version "7.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
|
||||||
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
|
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
|
||||||
|
|||||||
Reference in New Issue
Block a user