Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- fixed `unity-version` not properly overriding version in `version-file`.
- fixed `version-file` not properly being found when using relative paths.
  • Loading branch information
StephenHodgson authored Aug 7, 2024
1 parent c8dedf1 commit b736c67
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-latest]
unity-versions:
- 'in version file'
- 2019.4.40f1 (ffc62b691db5)
- 2020.3.48f1 (b805b124c6b7)
- 2021.3.41f1 (6c5a9e20c022)
Expand Down Expand Up @@ -54,6 +55,7 @@ jobs:

- uses: ./ # buildalon/unity-setup
with:
version-file: com.utilities.buildpipline/Utilities.BuildPipeline/ProjectSettings/ProjectVersion.txt
unity-version: ${{ matrix.unity-versions }}
build-targets: ${{ matrix.build-targets }}
modules: ${{ matrix.modules }}
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ A GitHub Action for setting up the [Unity Game Engine](https://unity.com) on Git
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-latest]
unity-versions: [2020.3.48f1 (b805b124c6b7), 2021.3.41f1 (6c5a9e20c022), 2022.3.40f1 (cbdda657d2f0)]
unity-versions:
- 'in version file'
- 2019.4.40f1 (ffc62b691db5)
- 2020.3.48f1 (b805b124c6b7)
- 2021.3.41f1 (6c5a9e20c022)
- 2022.3.40f1 (cbdda657d2f0)
- 6000.0.13f1 (53a692e3fca9)
include:
- os: ubuntu-latest
build-targets: StandaloneLinux64, Android, iOS
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
required: false
default: ''
build-targets:
description: 'Specify the build targets to install modules for. One or more of `StandaloneWindows64` `WSAPlayer` `StandaloneOSX` `iOS` `StandaloneLinux64` `Android` `Lumin` `WebGL`.'
description: 'Specify the build targets to install modules for. One or more of `StandaloneWindows64` `WSAPlayer` `StandaloneOSX` `iOS` `StandaloneLinux64` `Android` `Lumin` `WebGL` `VisionOS`.'
required: false
default: ''
modules:
Expand Down
21 changes: 14 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31192,7 +31192,7 @@ async function ValidateInputs() {
const [unityVersion, changeset] = await getUnityVersionFromFile(versionFilePath);
const versions = getUnityVersionsFromInput();
const pathInput = core.getInput('version-file');
const overrideVersion = (pathInput === '' || pathInput === undefined) && versions.length > 0;
const overrideVersion = pathInput && pathInput.length > 0 && versions.length > 0;
if (versions.length > 0) {
const version = versions.find(([v, c]) => v === unityVersion && c === changeset);
if (!version && !overrideVersion) {
Expand Down Expand Up @@ -31286,21 +31286,28 @@ function getDefaultModules() {

async function getVersionFilePath() {
let projectVersionPath = core.getInput('version-file');
if (!projectVersionPath) {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**/ProjectVersion.txt'));
if (projectVersionPath) {
} else {
core.info(`projectVersionPath: ${projectVersionPath}`);
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
}
try {
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
try {
projectVersionPath = await FindGlobPattern(projectVersionPath);
projectVersionPath = path.join(process.env.GITHUB_WORKSPACE, projectVersionPath);
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
// ignore
core.error(error);
try {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
}
}
throw Error(`Could not find ProjectVersion.txt in ${projectVersionPath}`);
}
Expand All @@ -31309,7 +31316,7 @@ async function getVersionFilePath() {
function getUnityVersionsFromInput() {
const versions = [];
const inputVersions = core.getInput('unity-version');
if (!inputVersions) {
if (!inputVersions || inputVersions.length == 0) {
return versions;
}
const versionRegEx = new RegExp(/(?<version>(?:(?<major>\d+)\.)?(?:(?<minor>\d+)\.)?(?:(?<patch>\d+[fab]\d+)\b))\s?(?:\((?<changeset>\w+)\))?/g);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-setup",
"version": "1.0.2",
"version": "1.0.3",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "Buildalon",
"license": "MIT",
Expand Down
21 changes: 14 additions & 7 deletions src/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function ValidateInputs() {
const [unityVersion, changeset] = await getUnityVersionFromFile(versionFilePath);
const versions = getUnityVersionsFromInput();
const pathInput = core.getInput('version-file');
const overrideVersion = (pathInput === '' || pathInput === undefined) && versions.length > 0;
const overrideVersion = pathInput && pathInput.length > 0 && versions.length > 0;
if (versions.length > 0) {
const version = versions.find(([v, c]) => v === unityVersion && c === changeset);
if (!version && !overrideVersion) {
Expand Down Expand Up @@ -141,21 +141,28 @@ function getDefaultModules() {

async function getVersionFilePath() {
let projectVersionPath = core.getInput('version-file');
if (!projectVersionPath) {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**/ProjectVersion.txt'));
if (projectVersionPath) {
} else {
core.info(`projectVersionPath: ${projectVersionPath}`);
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
}
try {
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
try {
projectVersionPath = await FindGlobPattern(projectVersionPath);
projectVersionPath = path.join(process.env.GITHUB_WORKSPACE, projectVersionPath);
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
// ignore
core.error(error);
try {
projectVersionPath = await FindGlobPattern(path.join(process.env.GITHUB_WORKSPACE, '**', 'ProjectVersion.txt'));
await fs.access(projectVersionPath, fs.constants.R_OK);
return projectVersionPath;
} catch (error) {
core.debug(error);
}
}
throw Error(`Could not find ProjectVersion.txt in ${projectVersionPath}`);
}
Expand All @@ -164,7 +171,7 @@ async function getVersionFilePath() {
function getUnityVersionsFromInput() {
const versions = [];
const inputVersions = core.getInput('unity-version');
if (!inputVersions) {
if (!inputVersions || inputVersions.length == 0) {
return versions;
}
const versionRegEx = new RegExp(/(?<version>(?:(?<major>\d+)\.)?(?:(?<minor>\d+)\.)?(?:(?<patch>\d+[fab]\d+)\b))\s?(?:\((?<changeset>\w+)\))?/g);
Expand Down

0 comments on commit b736c67

Please sign in to comment.