name: Get the Unity version required from a UPM Package.json file on: workflow_call: inputs: build-host: required: true type: string version-file-path: 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"' 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 UPM Package runs-on: ${{ inputs.build-host }} outputs: upmunityversion: ${{ steps.getVersion.outputs.packageunityversion }} steps: - name: Script Version run: | echo "::group::Script Versioning" $scriptVersion = "1.0.2" echo "Build Script Version: $scriptVersion" echo "::endgroup::" shell: pwsh - uses: actions/checkout@v3 with: submodules: recursive clean: true - id: getVersion name: 'Get Unity Version Number' run: | echo "::group::Validating input" $versionFile = "${{ inputs.version-file-path }}" if([string]::IsNullOrEmpty($versionFile)) { echo 'version input was empty, using default' $versionFile = 'package.json' } echo 'Checking for project json at $versionFile' if ( -not (Test-Path -Path $versionFile) ) { Write-Error "Failed to find a valid package.json file" exit 1 } echo "::endgroup::" echo "::group::Unity Version UPM check" $package_json = Get-Content -Path $versionFile | ConvertFrom-Json $unityVersion = $package_json.unity if($unityVersion.Length -lt 6) { echo "Error - Detected version is $unityVersion" echo "Unity version is too short, please check your UPM package Unity setting" exit 1 } echo "packageunityversion=$unityVersion" >> $env:GITHUB_OUTPUT echo "Detected version is $unityVersion" echo "::endgroup::" shell: pwsh