Move android keystore decode logic to TS
parent
fea34a666d
commit
45f9808c75
|
|
@ -6735,6 +6735,7 @@ class PlatformSetup {
|
||||||
let servicesConfig = fs_1.default.readFileSync(servicesConfigPathTemplate).toString();
|
let servicesConfig = fs_1.default.readFileSync(servicesConfigPathTemplate).toString();
|
||||||
servicesConfig = servicesConfig.replace('%URL%', buildParameters.unityLicensingServer);
|
servicesConfig = servicesConfig.replace('%URL%', buildParameters.unityLicensingServer);
|
||||||
fs_1.default.writeFileSync(servicesConfigPath, servicesConfig);
|
fs_1.default.writeFileSync(servicesConfigPath, servicesConfig);
|
||||||
|
platform_setup_1.SetupAndroid.setup(buildParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports["default"] = PlatformSetup;
|
exports["default"] = PlatformSetup;
|
||||||
|
|
@ -6751,11 +6752,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.SetupMac = exports.SetupWindows = void 0;
|
exports.SetupAndroid = exports.SetupMac = exports.SetupWindows = void 0;
|
||||||
const setup_windows_1 = __importDefault(__nccwpck_require__(37449));
|
const setup_windows_1 = __importDefault(__nccwpck_require__(37449));
|
||||||
exports.SetupWindows = setup_windows_1.default;
|
exports.SetupWindows = setup_windows_1.default;
|
||||||
const setup_mac_1 = __importDefault(__nccwpck_require__(22466));
|
const setup_mac_1 = __importDefault(__nccwpck_require__(22466));
|
||||||
exports.SetupMac = setup_mac_1.default;
|
exports.SetupMac = setup_mac_1.default;
|
||||||
|
const setup_android_1 = __importDefault(__nccwpck_require__(45142));
|
||||||
|
exports.SetupAndroid = setup_android_1.default;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 45142:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
||||||
|
const path_1 = __importDefault(__nccwpck_require__(71017));
|
||||||
|
class SetupAndroid {
|
||||||
|
static setup(buildParameters) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const { targetPlatform, androidKeystoreBase64, androidKeystoreName, projectPath } = buildParameters;
|
||||||
|
if (targetPlatform === 'Android' && androidKeystoreBase64 !== '' && androidKeystoreName !== '') {
|
||||||
|
SetupAndroid.setupAndroidRun(androidKeystoreBase64, androidKeystoreName, projectPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static setupAndroidRun(androidKeystoreBase64, androidKeystoreName, projectPath) {
|
||||||
|
const decodedKeystore = Buffer.from(androidKeystoreBase64, 'base64').toString('binary');
|
||||||
|
const githubWorkspace = process.env.GITHUB_WORKSPACE || '';
|
||||||
|
fs_1.default.writeFileSync(path_1.default.join(githubWorkspace, projectPath, androidKeystoreName), decodedKeystore, 'binary');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports["default"] = SetupAndroid;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -63,17 +63,9 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Prepare Android keystore and SDK, if needed
|
# Prepare Android SDK, if needed
|
||||||
#
|
#
|
||||||
|
|
||||||
if [[ "$BUILD_TARGET" == "Android" && -n "$ANDROID_KEYSTORE_NAME" && -n "$ANDROID_KEYSTORE_BASE64" ]]; then
|
|
||||||
echo "Creating Android keystore."
|
|
||||||
echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$UNITY_PROJECT_PATH/$ANDROID_KEYSTORE_NAME"
|
|
||||||
echo "Created Android keystore."
|
|
||||||
else
|
|
||||||
echo "Not creating Android keystore."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$BUILD_TARGET" == "Android" && -n "$ANDROID_SDK_MANAGER_PARAMETERS" ]]; then
|
if [[ "$BUILD_TARGET" == "Android" && -n "$ANDROID_SDK_MANAGER_PARAMETERS" ]]; then
|
||||||
echo "Updating Android SDK with parameters: $ANDROID_SDK_MANAGER_PARAMETERS"
|
echo "Updating Android SDK with parameters: $ANDROID_SDK_MANAGER_PARAMETERS"
|
||||||
export JAVA_HOME="$(awk -F'=' '/JAVA_HOME=/{print $2}' /usr/bin/unity-editor.d/*)"
|
export JAVA_HOME="$(awk -F'=' '/JAVA_HOME=/{print $2}' /usr/bin/unity-editor.d/*)"
|
||||||
|
|
|
||||||
|
|
@ -66,21 +66,6 @@ else
|
||||||
Get-ChildItem -Path $Env:UNITY_PROJECT_PATH\Assets\Editor -Recurse
|
Get-ChildItem -Path $Env:UNITY_PROJECT_PATH\Assets\Editor -Recurse
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Create Android Keystore if available
|
|
||||||
#
|
|
||||||
|
|
||||||
if ( "$Env:BUILD_TARGET" -eq "Android" -and -not ([string]::IsNullOrEmpty("$Env:ANDROID_KEYSTORE_NAME")) -and -not ([string]::IsNullOrEmpty("$Env:ANDROID_KEYSTORE_BASE64")) )
|
|
||||||
{
|
|
||||||
Write-Output "Creating Android keystore."
|
|
||||||
$keystorePath = "$Env:GITHUB_WORKSPACE\$Env:ANDROID_KEYSTORE_NAME"
|
|
||||||
[System.IO.File]::WriteAllBytes($keystorePath, [System.Convert]::FromBase64String($Env:ANDROID_KEYSTORE_BASE64))
|
|
||||||
Write-Output "Created Android keystore."
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Output "Not creating Android keystore."
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Pre-build debug information
|
# Pre-build debug information
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { BuildParameters } from '.';
|
import { BuildParameters } from '.';
|
||||||
import { SetupMac, SetupWindows } from './platform-setup/';
|
import { SetupMac, SetupWindows, SetupAndroid } from './platform-setup/';
|
||||||
import ValidateWindows from './platform-validation/validate-windows';
|
import ValidateWindows from './platform-validation/validate-windows';
|
||||||
|
|
||||||
class PlatformSetup {
|
class PlatformSetup {
|
||||||
|
|
@ -33,6 +33,8 @@ class PlatformSetup {
|
||||||
let servicesConfig = fs.readFileSync(servicesConfigPathTemplate).toString();
|
let servicesConfig = fs.readFileSync(servicesConfigPathTemplate).toString();
|
||||||
servicesConfig = servicesConfig.replace('%URL%', buildParameters.unityLicensingServer);
|
servicesConfig = servicesConfig.replace('%URL%', buildParameters.unityLicensingServer);
|
||||||
fs.writeFileSync(servicesConfigPath, servicesConfig);
|
fs.writeFileSync(servicesConfigPath, servicesConfig);
|
||||||
|
|
||||||
|
SetupAndroid.setup(buildParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import SetupWindows from './setup-windows';
|
import SetupWindows from './setup-windows';
|
||||||
import SetupMac from './setup-mac';
|
import SetupMac from './setup-mac';
|
||||||
|
import SetupAndroid from './setup-android';
|
||||||
|
|
||||||
export { SetupWindows, SetupMac };
|
export { SetupWindows, SetupMac, SetupAndroid };
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { BuildParameters } from '..';
|
||||||
|
|
||||||
|
class SetupAndroid {
|
||||||
|
public static async setup(buildParameters: BuildParameters) {
|
||||||
|
const { targetPlatform, androidKeystoreBase64, androidKeystoreName, projectPath } = buildParameters;
|
||||||
|
|
||||||
|
if (targetPlatform === 'Android' && androidKeystoreBase64 !== '' && androidKeystoreName !== '') {
|
||||||
|
SetupAndroid.setupAndroidRun(androidKeystoreBase64, androidKeystoreName, projectPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static setupAndroidRun(androidKeystoreBase64: string, androidKeystoreName: string, projectPath: string) {
|
||||||
|
const decodedKeystore = Buffer.from(androidKeystoreBase64, 'base64').toString('binary');
|
||||||
|
const githubWorkspace = process.env.GITHUB_WORKSPACE || '';
|
||||||
|
fs.writeFileSync(path.join(githubWorkspace, projectPath, androidKeystoreName), decodedKeystore, 'binary');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SetupAndroid;
|
||||||
Loading…
Reference in New Issue