-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (57 loc) · 2.22 KB
/
getunityversionfromproject.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Get the Unity version required from a Unity Project, expects a packageversion.txt file
on:
workflow_call:
inputs:
build-target:
required: true
type: string
version-file-path:
description: 'Optional, specify a path to search for the unity project version text file. Use this if validation fails to find a valid project version file.'
type: string
required: false
outputs:
unityversion:
description: "Returns the version of Unity the UPM package requires"
value: ${{ jobs.get_unity_version.outputs.upmunityversion }}
jobs:
get_unity_version:
name: Get required Unity version from Unity Project
runs-on: ${{ inputs.build-target }}
outputs:
upmunityversion: ${{ steps.getversion.outputs.upmunityversion }}
steps:
- name: Script Version
run: |
echo "::group::Script Versioning"
$scriptVersion = "1.0.1"
echo "Build Script Version: $scriptVersion"
echo "::endgroup::"
shell: pwsh
- uses: actions/checkout@v3
with:
submodules: recursive
clean: true
- id: getversion
name: 'Get Unity Package Version'
run: |
echo "::group::Validating input"
$versionFile = "${{ inputs.version-file-path }}"
if([string]::IsNullOrEmpty($versionFile))
{
echo 'version input was empty, using default'
$versionFile = '**/ProjectSettings/ProjectVersion.txt'
}
if ( -not (Test-Path -Path $versionFile) ) {
Write-Error "Failed to find a valid ProjectVersion.txt file"
exit 1
}
echo "::endgroup::"
echo "::group::Unity Version Project check"
$version = Get-Content $versionFile
$pattern = '(?<version>(?:(?<major>\d+)\.)?(?:(?<minor>\d+)\.)?(?:(?<patch>\d+[fab]\d+)\b))|((?:\((?<revision>\w+))\))'
$matches = $matches = [regex]::Matches($version, $pattern)
$unityVersion = $matches[1].Groups['version'].Value.Trim()
echo "Detected version is $unityVersion"
echo "upmunityversion=$unityVersion" >> $env:GITHUB_OUTPUT
echo "::endgroup::"
shell: pwsh