Skip to content

Commit 5ec4b0b

Browse files
Merge pull request #462 from Unity-UI-Extensions/development
Release 2.3.2 - take 2
2 parents e909d73 + d69ee0c commit 5ec4b0b

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Get the Unity version required from a UPM Package.json file
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build-host:
7+
required: true
8+
type: string
9+
version-file-path:
10+
description: 'Optional, specify a path to search for the upm package.json file. Use this if validation fails to find a valid package.json file.\n **Note, Version file MUST contain the attribute "Unity" with the full Unity version expected, e.g. "2020.2.3f1"'
11+
type: string
12+
required: false
13+
outputs:
14+
unityversion:
15+
description: "Returns the version of Unity the UPM package requires"
16+
value: ${{ jobs.get_unity_version.outputs.upmunityversion }}
17+
18+
jobs:
19+
get_unity_version:
20+
name: Get required Unity version from UPM Package
21+
runs-on: ${{ inputs.build-host }}
22+
outputs:
23+
upmunityversion: ${{ steps.getVersion.outputs.packageunityversion }}
24+
steps:
25+
- name: Script Version
26+
run: |
27+
echo "::group::Script Versioning"
28+
$scriptVersion = "1.0.2"
29+
echo "Build Script Version: $scriptVersion"
30+
echo "::endgroup::"
31+
shell: pwsh
32+
- uses: actions/checkout@v3
33+
with:
34+
submodules: recursive
35+
clean: true
36+
- id: getVersion
37+
name: 'Get Unity Version Number'
38+
run: |
39+
echo "::group::Validating input"
40+
41+
$versionFile = "${{ inputs.version-file-path }}"
42+
if([string]::IsNullOrEmpty($versionFile))
43+
{
44+
echo 'version input was empty, using default'
45+
$versionFile = 'package.json'
46+
}
47+
echo 'Checking for project json at $versionFile'
48+
49+
if ( -not (Test-Path -Path $versionFile) ) {
50+
Write-Error "Failed to find a valid package.json file"
51+
exit 1
52+
}
53+
54+
echo "::endgroup::"
55+
56+
echo "::group::Unity Version UPM check"
57+
58+
$package_json = Get-Content -Path $versionFile | ConvertFrom-Json
59+
$unityVersion = $package_json.unity
60+
61+
if($unityVersion.Length -lt 6) {
62+
echo "Error - Detected version is $unityVersion"
63+
echo "Unity version is too short, please check your UPM package Unity setting"
64+
exit 1
65+
}
66+
67+
echo "packageunityversion=$unityVersion" >> $env:GITHUB_OUTPUT
68+
69+
echo "Detected version is $unityVersion"
70+
echo "::endgroup::"
71+
72+
shell: pwsh

0 commit comments

Comments
 (0)