Create USD Release v2411 #29
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Workflow to build USD versions required to run the usd plugins | |
| # This assumes there is a Release created called USD Artifacts | |
| name: Create USD Release | |
| run-name: Create USD Release v${{ github.event.inputs.usd_version }} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| usd_version: | |
| description: "USD Version to build" | |
| required: true | |
| default: "2405" | |
| jobs: | |
| prepare-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - id: set-matrix | |
| run: | | |
| OS_LIST="[\"windows-2022\",\"macOS-13\"" | |
| if [[ "${{ github.event.inputs.usd_version }}" -gt 2400 ]]; then | |
| OS_LIST="$OS_LIST,\"macOS-14\"" | |
| fi | |
| OS_LIST="$OS_LIST,\"ubuntu-22.04\"]" | |
| echo "matrix=$OS_LIST" >> $GITHUB_OUTPUT | |
| build: | |
| needs: [prepare-matrix] | |
| name: Create USD Release ${{ matrix.os }} ${{ github.event.inputs.usd_version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check if artifact exists in 'USD-${{ github.event.inputs.usd_version }}-Artifacts' Release | |
| id: check_artifact | |
| shell: pwsh | |
| run: | | |
| $usd_version = "${{ github.event.inputs.usd_version }}" | |
| $usdFormattedVersion = "$($usd_version.Substring(0,2)).$($usd_version.Substring(2))" | |
| "USD_FORMATTED_VERSION=$usdFormattedVersion" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| $releaseName = "USD-${usd_version}-Artifacts" | |
| $ASSET_NAME = "usd-${usd_version}-${{ matrix.os }}.zip" | |
| $releaseExists = $false | |
| $stderr = $null | |
| $releaseView = gh release view $releaseName 2>&1 | Tee-Object -Variable stderr | |
| if ($stderr -match "release not found") { | |
| $releaseExists = $false | |
| "exists=false" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| Write-Output "Release not found: $releaseName -- Creating new one" | |
| gh release create "$releaseName" --title "$releaseName" --notes "USD built with the following parameters: --build-shared --openimageio --tools --python --debug-python --usd-imaging --build-variant release --use-cxx11-abi=0 (linux)" | |
| } else { | |
| $releaseExists = $true | |
| } | |
| Write-Output "Release View result: $releaseName, Exists: $releaseExists" | |
| if ($releaseExists) { | |
| $assets = gh release view $releaseName --repo ${{ github.repository }} --json assets -q '.assets[].name' | |
| if ($assets -like "*$ASSET_NAME*") { | |
| Write-Output "Asset $ASSET_NAME exists in the $releaseName Release." | |
| "exists=true" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| } else { | |
| Write-Output "Asset $ASSET_NAME does not exist in the $releaseName Release." | |
| "exists=false" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| } | |
| } | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| if: env.exists == 'false' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10.11" | |
| id: setup-python | |
| - name: Install Ninja (Unix) | |
| if: env.exists == 'false' && matrix.os != 'windows-2022' | |
| run: | | |
| python -m pip install ninja | |
| - name: Install Additional Dependencies (macOS-13) | |
| if: env.exists == 'false' && matrix.os == 'macOS-13' | |
| run: | | |
| sudo xcode-select -s /Applications/Xcode_14.1.app | |
| brew uninstall --ignore-dependencies openexr imath | |
| brew cleanup | |
| brew install glew | |
| - name: Install Additional Dependencies (macOS-14) | |
| if: env.exists == 'false' && matrix.os == 'macOS-14' | |
| run: | | |
| brew uninstall --ignore-dependencies giflib | |
| brew cleanup | |
| - name: Install Additional Dependencies (Ubuntu) | |
| if: env.exists == 'false' && matrix.os == 'ubuntu-22.04' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential libgl1-mesa-dev libglew-dev libxi-dev libxrandr-dev | |
| - name: Install Additional Dependencies (Windows) | |
| if: env.exists == 'false' && matrix.os == 'windows-2022' | |
| run: | | |
| choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' | |
| - name: Initialize Visual Studio 2017 environment | |
| if: env.exists == 'false' && matrix.os == 'windows-2022' | |
| shell: pwsh | |
| run: | | |
| # Locate VS2017 installation path | |
| $vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[15.0,16.0)" -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | |
| if (!$vsPath) { | |
| Write-Error "Visual Studio 2017 not found." | |
| } | |
| # Path to vcvarsall.bat | |
| $vcvarsall = Join-Path $vsPath 'VC\Auxiliary\Build\vcvarsall.bat' | |
| if (-Not (Test-Path $vcvarsall)) { | |
| Write-Error "vcvarsall.bat not found at $vcvarsall" | |
| } | |
| # Initialize the environment | |
| cmd /c "`"$vcvarsall`" x64" | |
| - name: Clone USD | |
| if: env.exists == 'false' | |
| run: git clone --branch v${{ env.USD_FORMATTED_VERSION }} --depth 1 https://github.com/PixarAnimationStudios/OpenUSD.git | |
| - name: Install Python Dependencies | |
| if: env.exists == 'false' | |
| shell: pwsh | |
| run: | | |
| python -m pip install PySide6 | |
| python -m pip install pyopengl | |
| if ("${{runner.os}}" -eq "Windows") { | |
| python -m pip install jinja2 | |
| } | |
| - name: Build USD | |
| if: env.exists == 'false' | |
| shell: pwsh | |
| run: | | |
| $file = "OpenUSD/build_scripts/build_usd.py" | |
| $env:CMAKE_PREFIX_PATH = "/usr/local;$env:CMAKE_PREFIX_PATH" | |
| $env:DYLD_LIBRARY_PATH = "/usr/local/lib;$env:DYLD_LIBRARY_PATH" | |
| $env:LD_LIBRARY_PATH = "/usr/local/lib;$env:LD_LIBRARY_PATH" | |
| $abi_arg = "" | |
| $generator = "--generator Ninja" | |
| if ("${{runner.os}}" -eq "Windows") { | |
| $generator = '--generator "Visual Studio 15 2017"' | |
| $fileContent = Get-Content $file -Raw | |
| $fileContent = $fileContent -replace ' -- \{multiproc\}', '' | |
| Set-Content $file -Value $fileContent | |
| } | |
| if ("${{runner.os}}" -eq "Linux") { | |
| $abi_arg = "--use-cxx11-abi 0" | |
| } | |
| $python_cmd = "python $file `${{ github.workspace }}/usd_build` --build-shared --openimageio --tools --python --debug-python --usd-imaging --build-variant release $abi_arg $generator" | |
| Invoke-Expression $python_cmd | |
| - name: Remove Specific Folders Unix | |
| if: env.exists == 'false' && matrix.os != 'windows-2022' | |
| run: | | |
| rm -rf ${{ github.workspace }}/usd_build/build | |
| rm -rf ${{ github.workspace }}/usd_build/share | |
| rm -rf ${{ github.workspace }}/usd_build/src | |
| - name: Remove Specific Folders Windows | |
| if: env.exists == 'false' && matrix.os == 'windows-2022' | |
| run: | | |
| powershell -Command "& { | |
| Remove-Item -Path ${{ github.workspace }}\usd_build\build -Recurse -Force | |
| Remove-Item -Path ${{ github.workspace }}\usd_build\share -Recurse -Force | |
| Remove-Item -Path ${{ github.workspace }}\usd_build\src -Recurse -Force | |
| }" | |
| - name: Set USD Paths to Environment variable to USD_BUILD_PATH | |
| if: env.exists == 'false' | |
| shell: pwsh | |
| run: | | |
| if ($env:RUNNER_OS -eq 'macOS') { | |
| $localPath = "/Users/runner/work/USD-Fileformat-plugins/USD-Fileformat-plugins/usd_build" | |
| } elseif ($env:RUNNER_OS -eq 'Linux') { | |
| $localPath = "/home/runner/work/USD-Fileformat-plugins/USD-Fileformat-plugins/usd_build" | |
| } elseif ($env:RUNNER_OS -eq 'Windows') { | |
| $localPath = "D:/a/USD-Fileformat-plugins/USD-Fileformat-plugins/usd_build" | |
| } | |
| $files = @( | |
| "${{ github.workspace }}/usd_build/cmake/pxrTargets.cmake", | |
| "${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO/OpenImageIOConfig.cmake", | |
| "${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO/OpenImageIOTargets.cmake" | |
| ) | |
| $replacementPath = '${USD_BUILD_PATH}' | |
| foreach ($file in $files) { | |
| (Get-Content $file) -replace [regex]::Escape($localPath), $replacementPath | Set-Content $file | |
| $content = 'set(USD_BUILD_PATH "$ENV{USD_BUILD_PATH}")' + "`r`n" + (Get-Content $file -Raw) | |
| $content | Set-Content $file | |
| } | |
| - name: Package Build Artifacts Unix | |
| if: env.exists == 'false' && matrix.os != 'windows-2022' | |
| run: | | |
| cd ${{ github.workspace }}/usd_build | |
| zip -r ../usd-${{ github.event.inputs.usd_version }}-${{ matrix.os }}.zip * | |
| - name: Package Build Artifacts Windows | |
| if: env.exists == 'false' && matrix.os == 'windows-2022' | |
| run: | | |
| powershell -Command "& { | |
| Set-Location ${{ github.workspace }}\usd_build | |
| Compress-Archive -Path * -DestinationPath ..\usd-${{ github.event.inputs.usd_version }}-${{ matrix.os }}.zip | |
| }" | |
| - name: Upload Artifact to USD-${{ github.event.inputs.usd_version }}-Artifacts Release | |
| if: env.exists == 'false' | |
| shell: pwsh | |
| run: | | |
| $ARTIFACT_PATH = "${{ github.workspace }}/usd-${{ github.event.inputs.usd_version }}-${{ matrix.os }}.zip" | |
| if (-Not (Test-Path $ARTIFACT_PATH)) { | |
| Write-Output "$ARTIFACT_PATH does not exist."# Log Artifact Path and Rel | |
| } | |
| else { | |
| Write-Output "File $ARTIFACT_PATH exists." | |
| Write-Output "Size of the artifact file:" | |
| Get-Item $ARTIFACT_PATH | Select-Object Name, Length | |
| } | |
| Write-Output "Uploading $ARTIFACT_PATH to USD-${{github.event.inputs.usd_version}}-Artifacts release..." | |
| gh release upload USD-${{ github.event.inputs.usd_version }}-Artifacts $ARTIFACT_PATH --repo ${{ github.repository }} --clobber | |
| Write-Output "Upload successful." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |