Improve error message for unset UNITY_EMAIL and UNITY_PASSWORD

pull/305/head
Andrew Kahr 2022-01-23 20:14:14 -08:00
parent a3cadeaf30
commit d6cc7fd22f
3 changed files with 115 additions and 113 deletions

223
dist/index.js vendored
View File

@ -358,9 +358,9 @@ class Docker {
const { path, dockerfile, baseImage } = buildParameters; const { path, dockerfile, baseImage } = buildParameters;
const { version, platform } = baseImage; const { version, platform } = baseImage;
const tag = new image_tag_1.default({ repository: '', name: 'unity-builder', version, platform }); const tag = new image_tag_1.default({ 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} \
--tag ${tag}`; --tag ${tag}`;
yield exec_1.exec(command, undefined, { silent }); yield exec_1.exec(command, undefined, { silent });
return tag; return tag;
@ -371,56 +371,56 @@ class Docker {
const { version, workspace, runnerTempPath, platform, projectPath, buildName, buildPath, buildFile, buildMethod, buildVersion, androidVersionCode, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass, androidTargetSdkVersion, androidSdkManagerParameters, customParameters, sshAgent, gitPrivateToken, chownFilesTo, } = parameters; const { version, workspace, runnerTempPath, platform, projectPath, buildName, buildPath, buildFile, buildMethod, buildVersion, androidVersionCode, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass, androidTargetSdkVersion, androidSdkManagerParameters, customParameters, sshAgent, gitPrivateToken, chownFilesTo, } = parameters;
switch (process.platform) { switch (process.platform) {
case 'linux': { case 'linux': {
const linuxRunCommand = `docker run \ const linuxRunCommand = `docker run \
--workdir /github/workspace \ --workdir /github/workspace \
--rm \ --rm \
--env UNITY_LICENSE \ --env UNITY_LICENSE \
--env UNITY_LICENSE_FILE \ --env UNITY_LICENSE_FILE \
--env UNITY_EMAIL \ --env UNITY_EMAIL \
--env UNITY_PASSWORD \ --env UNITY_PASSWORD \
--env UNITY_SERIAL \ --env UNITY_SERIAL \
--env UNITY_VERSION="${version}" \ --env UNITY_VERSION="${version}" \
--env USYM_UPLOAD_AUTH_TOKEN \ --env USYM_UPLOAD_AUTH_TOKEN \
--env PROJECT_PATH="${projectPath}" \ --env PROJECT_PATH="${projectPath}" \
--env BUILD_TARGET="${platform}" \ --env BUILD_TARGET="${platform}" \
--env BUILD_NAME="${buildName}" \ --env BUILD_NAME="${buildName}" \
--env BUILD_PATH="${buildPath}" \ --env BUILD_PATH="${buildPath}" \
--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 ANDROID_VERSION_CODE="${androidVersionCode}" \
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \ --env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \ --env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \ --env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \ --env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \ --env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \ --env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \ --env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
--env CUSTOM_PARAMETERS="${customParameters}" \ --env CUSTOM_PARAMETERS="${customParameters}" \
--env CHOWN_FILES_TO="${chownFilesTo}" \ --env CHOWN_FILES_TO="${chownFilesTo}" \
--env GITHUB_REF \ --env GITHUB_REF \
--env GITHUB_SHA \ --env GITHUB_SHA \
--env GITHUB_REPOSITORY \ --env GITHUB_REPOSITORY \
--env GITHUB_ACTOR \ --env GITHUB_ACTOR \
--env GITHUB_WORKFLOW \ --env GITHUB_WORKFLOW \
--env GITHUB_HEAD_REF \ --env GITHUB_HEAD_REF \
--env GITHUB_BASE_REF \ --env GITHUB_BASE_REF \
--env GITHUB_EVENT_NAME \ --env GITHUB_EVENT_NAME \
--env GITHUB_WORKSPACE=/github/workspace \ --env GITHUB_WORKSPACE=/github/workspace \
--env GITHUB_ACTION \ --env GITHUB_ACTION \
--env GITHUB_EVENT_PATH \ --env GITHUB_EVENT_PATH \
--env RUNNER_OS \ --env RUNNER_OS \
--env RUNNER_TOOL_CACHE \ --env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \ --env RUNNER_TEMP \
--env RUNNER_WORKSPACE \ --env RUNNER_WORKSPACE \
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \ --env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \ ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "/var/run/docker.sock":"/var/run/docker.sock" \ --volume "/var/run/docker.sock":"/var/run/docker.sock" \
--volume "${runnerTempPath}/_github_home":"/root" \ --volume "${runnerTempPath}/_github_home":"/root" \
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \ --volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
--volume "${workspace}":"/github/workspace" \ --volume "${workspace}":"/github/workspace" \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \ ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
${image}`; ${image}`;
yield exec_1.exec(linuxRunCommand, undefined, { silent }); yield exec_1.exec(linuxRunCommand, undefined, { silent });
break; break;
@ -430,9 +430,9 @@ class Docker {
if (!process.env.UNITY_SERIAL) { if (!process.env.UNITY_SERIAL) {
//No serial was present so it is a personal license that we need to convert //No serial was present so it is a personal license that we need to convert
if (!process.env.UNITY_LICENSE) { if (!process.env.UNITY_LICENSE) {
throw new Error(`Missing Unity License File and no Serial was found. If this throw new Error(`Missing Unity License File and no Serial was found. If this
is a personal license, make sure to follow the activation is a personal license, make sure to follow the activation
steps and set the UNITY_LICENSE GitHub secret or enter a Unity steps and set the UNITY_LICENSE GitHub secret or enter a Unity
serial number inside the UNITY_SERIAL GitHub secret.`); serial number inside the UNITY_SERIAL GitHub secret.`);
} }
unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE); unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE);
@ -441,60 +441,61 @@ class Docker {
unitySerial = process.env.UNITY_SERIAL; unitySerial = process.env.UNITY_SERIAL;
} }
if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) { if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) {
throw new Error(`Unity email and password must be set for windows based builds`); throw new Error(`Unity email and password must be set for Windows based builds. Make
sure to set them inside UNITY_EMAIL and UNITY_PASSWORD in Github Secrets.`);
} }
yield this.setupWindowsRun(platform); yield this.setupWindowsRun(platform);
this.validateWindowsPlatformRequirements(platform); this.validateWindowsPlatformRequirements(platform);
const windowsRunCommand = `docker run \ const windowsRunCommand = `docker run \
--workdir c:/github/workspace \ --workdir c:/github/workspace \
--rm \ --rm \
--env UNITY_LICENSE \ --env UNITY_LICENSE \
--env UNITY_LICENSE_FILE \ --env UNITY_LICENSE_FILE \
--env UNITY_EMAIL \ --env UNITY_EMAIL \
--env UNITY_PASSWORD \ --env UNITY_PASSWORD \
--env UNITY_SERIAL="${unitySerial}" \ --env UNITY_SERIAL="${unitySerial}" \
--env UNITY_VERSION="${version}" \ --env UNITY_VERSION="${version}" \
--env USYM_UPLOAD_AUTH_TOKEN \ --env USYM_UPLOAD_AUTH_TOKEN \
--env PROJECT_PATH="${projectPath}" \ --env PROJECT_PATH="${projectPath}" \
--env BUILD_TARGET="${platform}" \ --env BUILD_TARGET="${platform}" \
--env BUILD_NAME="${buildName}" \ --env BUILD_NAME="${buildName}" \
--env BUILD_PATH="${buildPath}" \ --env BUILD_PATH="${buildPath}" \
--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 ANDROID_VERSION_CODE="${androidVersionCode}" \
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \ --env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \ --env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \ --env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \ --env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \ --env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \ --env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \ --env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
--env CUSTOM_PARAMETERS="${customParameters}" \ --env CUSTOM_PARAMETERS="${customParameters}" \
--env CHOWN_FILES_TO="${chownFilesTo}" \ --env CHOWN_FILES_TO="${chownFilesTo}" \
--env GITHUB_REF \ --env GITHUB_REF \
--env GITHUB_SHA \ --env GITHUB_SHA \
--env GITHUB_REPOSITORY \ --env GITHUB_REPOSITORY \
--env GITHUB_ACTOR \ --env GITHUB_ACTOR \
--env GITHUB_WORKFLOW \ --env GITHUB_WORKFLOW \
--env GITHUB_HEAD_REF \ --env GITHUB_HEAD_REF \
--env GITHUB_BASE_REF \ --env GITHUB_BASE_REF \
--env GITHUB_EVENT_NAME \ --env GITHUB_EVENT_NAME \
--env GITHUB_WORKSPACE=/github/workspace \ --env GITHUB_WORKSPACE=/github/workspace \
--env GITHUB_ACTION \ --env GITHUB_ACTION \
--env GITHUB_EVENT_PATH \ --env GITHUB_EVENT_PATH \
--env RUNNER_OS \ --env RUNNER_OS \
--env RUNNER_TOOL_CACHE \ --env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \ --env RUNNER_TEMP \
--env RUNNER_WORKSPACE \ --env RUNNER_WORKSPACE \
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \ --env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
--volume "${runnerTempPath}/_github_home":"c:/root" \ --volume "${runnerTempPath}/_github_home":"c:/root" \
--volume "${runnerTempPath}/_github_workflow":"c:/github/workflow" \ --volume "${runnerTempPath}/_github_workflow":"c:/github/workflow" \
--volume "${workspace}":"c:/github/workspace" \ --volume "${workspace}":"c:/github/workspace" \
--volume "c:/regkeys":"c:/regkeys" \ --volume "c:/regkeys":"c:/regkeys" \
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \ --volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \ --volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \ --volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \
${image}`; ${image}`;
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit //Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
yield exec_1.exec(windowsRunCommand, undefined, { silent }); yield exec_1.exec(windowsRunCommand, undefined, { silent });
@ -553,8 +554,8 @@ class Docker {
static checkForWin10SDK() { static checkForWin10SDK() {
//Check for Windows 10 SDK on runner //Check for Windows 10 SDK on runner
if (!fs.existsSync('C:/Program Files (x86)/Windows Kits')) { if (!fs.existsSync('C:/Program Files (x86)/Windows Kits')) {
throw new Error(`Windows 10 SDK not found in default location. Make sure throw new Error(`Windows 10 SDK not found in default location. Make sure
the runner has a Windows 10 SDK installed in the default the runner has a Windows 10 SDK installed in the default
location.`); location.`);
} }
} }
@ -562,8 +563,8 @@ class Docker {
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit //Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
if (!(fs.existsSync('C:/Program Files (x86)/Microsoft Visual Studio') && if (!(fs.existsSync('C:/Program Files (x86)/Microsoft Visual Studio') &&
fs.existsSync('C:/ProgramData/Microsoft/VisualStudio'))) { fs.existsSync('C:/ProgramData/Microsoft/VisualStudio'))) {
throw new Error(`Visual Studio not found at the default location. throw new Error(`Visual Studio not found at the default location.
Make sure the runner has Visual Studio installed in the Make sure the runner has Visual Studio installed in the
default location`); default location`);
} }
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -117,7 +117,8 @@ class Docker {
} }
if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) { if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) {
throw new Error(`Unity email and password must be set for windows based builds`); throw new Error(`Unity email and password must be set for Windows based builds. Make
sure to set them inside UNITY_EMAIL and UNITY_PASSWORD in Github Secrets.`);
} }
await this.setupWindowsRun(platform); await this.setupWindowsRun(platform);