Skip to content

Commit

Permalink
Fix finding project version for Unity 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
kuler90 committed Nov 7, 2020
1 parent f9fbbf4 commit 2a71f2b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function run() {
const projectPath = core.getInput('project-path');

if (!unityVersion) {
[unityVersion, unityVersionChangeset] = findProjectVersion(projectPath);
[unityVersion, unityVersionChangeset] = await findProjectVersion(projectPath);
} else if (!unityVersionChangeset) {
unityVersionChangeset = await findVersionChangeset(unityVersion);
}
Expand Down Expand Up @@ -106,17 +106,24 @@ async function findUnity(unityHubPath, unityVersion) {
return unityPath;
}

function findProjectVersion(projectPath) {
async function findProjectVersion(projectPath) {
const filePath = path.join(projectPath, 'ProjectSettings/ProjectVersion.txt');
if (fs.existsSync(filePath)) {
const fileText = fs.readFileSync(filePath, 'utf8');
const match = fileText.match(/m_EditorVersionWithRevision: (.+) \((.+)\)/);
const version = match[1];
const changeset = match[2];
return [version, changeset];
} else {
throw new Error(`Project not found at path: ${projectPath}`);
const match1 = fileText.match(/m_EditorVersionWithRevision: (.+) \((.+)\)/);
if (match1) {
const version = match1[1];
const changeset = match1[2];
return [version, changeset];
}
const match2 = fileText.match(/m_EditorVersion: (.+)/);
if (match2) {
const version = match2[1];
const changeset = await findVersionChangeset(version);
return [version, changeset];
}
}
throw new Error(`Project not found at path: ${projectPath}`);
}

async function findVersionChangeset(unityVersion) {
Expand Down

0 comments on commit 2a71f2b

Please sign in to comment.