diff --git a/workflow-templates/build.properties.json b/workflow-templates/build.properties.json new file mode 100644 index 0000000..049f1c9 --- /dev/null +++ b/workflow-templates/build.properties.json @@ -0,0 +1,8 @@ +{ + "name": "XRTK CI Workflow", + "description": "XRTK CI workflow template for unity projects.", + "iconName": "xrtk", + "categories": [ + "C#" + ] +} \ No newline at end of file diff --git a/workflow-templates/build.yml b/workflow-templates/build.yml new file mode 100644 index 0000000..0713113 --- /dev/null +++ b/workflow-templates/build.yml @@ -0,0 +1,93 @@ +name: XRTK CI + +on: + push: + branches: [ main ] + pull_request: + branches: + - '*' + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + +jobs: + validate: + runs-on: self-hosted + outputs: + editor-path: ${{ steps.unity-validate.outputs.editor-path }} + project-path: ${{ steps.unity-validate.outputs.project-path }} + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - id: unity-validate + uses: xrtk/unity-validate@main + + - uses: xrtk/unity-action@main + name: 'project-validation' + with: + name: 'project-validation' + editor-path: '${{ steps.unity-validate.outputs.editor-path }}' + project-path: '${{ steps.unity-validate.outputs.project-path }}' + args: '-quit -batchmode -executeMethod XRTK.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject' + + - uses: actions/upload-artifact@v2 + if: always() + with: + name: 'Validation-Results' + path: '${{ steps.unity-validate.outputs.project-path }}\Builds\Logs' + + - name: cleanup + run: | + $logDirectory = "${{ steps.unity-validate.outputs.project-path }}\Builds" + + if (Test-Path -Path $logDirectory) { + Remove-Item $logDirectory -Force -Recurse + } + shell: powershell + + build: + needs: validate + runs-on: self-hosted + strategy: + matrix: + build-target: [StandaloneWindows64, WSAPlayer, Android, Lumin] + max-parallel: 1 + + steps: + - uses: xrtk/unity-action@main + name: '${{ matrix.build-target }}-Tests' + with: + name: '${{ matrix.build-target }}-Tests' + editor-path: '${{ needs.validate.outputs.editor-path }}' + project-path: '${{ needs.validate.outputs.project-path }}' + build-target: '${{ matrix.build-target }}' + args: '-batchmode -runEditorTests' + + - uses: xrtk/unity-action@main + name: '${{ matrix.build-target }}-Build' + with: + name: '${{ matrix.build-target }}-Build' + editor-path: '${{ needs.validate.outputs.editor-path }}' + project-path: '${{ needs.validate.outputs.project-path }}' + build-target: '${{ matrix.build-target }}' + args: '-quit -batchmode -executeMethod XRTK.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild' + + - name: 'zip artifacts' + if: always() + run: | + $artifacts = "${{ needs.validate.outputs.project-path }}\Builds" + + if (Test-Path -Path $artifacts) { + Compress-Archive -Path "$artifacts\*" -DestinationPath ${{ github.workspace }}\${{ matrix.build-target }}-Artifacts.zip + Remove-Item $artifacts -Force -Recurse + } + shell: powershell + + - uses: actions/upload-artifact@v2 + if: always() + with: + name: '${{ matrix.build-target }}-Artifacts' + path: '${{ github.workspace }}\${{ matrix.build-target }}-Artifacts.zip' diff --git a/workflow-templates/upm-build.properties.json b/workflow-templates/upm-build.properties.json deleted file mode 100644 index 130a315..0000000 --- a/workflow-templates/upm-build.properties.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "XRTK CI Workflow (UPM)", - "description": "XRTK CI workflow template for upm projects.", - "iconName": "xrtk", - "categories": [ - "C#" - ] -} \ No newline at end of file diff --git a/workflow-templates/upm-build.yml b/workflow-templates/upm-build.yml deleted file mode 100644 index 7230ad7..0000000 --- a/workflow-templates/upm-build.yml +++ /dev/null @@ -1,176 +0,0 @@ -name: XRTK CI - -on: - push: - branches: [ main ] - pull_request: - branches: - - '*' - -concurrency: - group: ${{ github.head_ref }} - cancel-in-progress: true - -jobs: - validate: - runs-on: self-hosted - outputs: - editor-path: ${{ steps.validate-project-setup.outputs.editor-path }} - project-path: ${{ steps.validate-project-setup.outputs.project-path }} - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - - id: validate-project-setup - name: 'Unity Installation Validation' - run: | - Write-Host "Unity Installation Validation" - $editorRootPath = "" - $editorFileEx = "" - $versionFile = "${{ '**/ProjectSettings/ProjectVersion.txt' }}" - - if ( -not (Test-Path -Path $versionFile) ) { - Write-Error "Failed to find a valid project version file at `"$versionFile`"" - exit 1 - } - - $projectPath = (Get-Item $versionFile).Directory.Parent.FullName - Write-Host "Unity project path: `"$projectPath`"" - Write-Host "::set-output name=project-path::$projectPath" - - $version = Get-Content -Path $versionFile - $pattern = '(?(?:(?\d+)\.)?(?:(?\d+)\.)?(?:(?\d+[fab]\d+)\b))|((?:\((?\w+))\))' - $matches = $matches = [regex]::Matches($version, $pattern) - $unityVersion = $matches[1].Groups['version'].Value.Trim() - $unityVersionChangeSet = $matches[2].Groups['revision'].Value.Trim() - - if ( (-not $global:PSVersionTable.Platform) -or ($global:PSVersionTable.Platform -eq "Win32NT") ) { - $hubPath = "C:\Program Files\Unity Hub\Unity Hub.exe" - $editorRootPath = "C:\Program Files\Unity\Hub\Editor\" - $editorFileEx = "\Editor\Unity.exe" - $modules = @('windows-il2cpp', 'universal-windows-platform', 'lumin', 'webgl', 'android') - } - elseif ( $global:PSVersionTable.OS.Contains("Darwin") ) { - $hubPath = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" - $editorRootPath = "/Applications/Unity/Hub/Editor/" - $editorFileEx = "/Unity.app" - $modules = @('mac-il2cpp', 'ios', 'lumin', 'webgl', 'android') - } - elseif ( $global:PSVersionTable.OS.Contains("Linux") ) { - $hubPath = "./UnityHub.AppImage" - $editorRootPath = "~/Unity/Hub/Editor/" - $editorFileEx = "/Unity" - $modules = @('linux', 'lumin', 'webgl', 'android') - } - - if ( Test-Path -Path $hubPath ) { - Write-Host "Unity Hub found at `"$hubPath`"" - Write-Host "" - } else { - Write-Error "Failed to validate Unity Hub path at `"$hubPath`"" - exit 1 - } - - Write-Host "Editor root path currently set to: `"$editorRootPath`"" - Write-Host "" - - Write-Host "Unity HUB CLI Options:" - $p = Start-Process -NoNewWindow -PassThru -Wait -FilePath "$hubPath" -ArgumentList @('--','--headless','help') - Write-Host "" - - $editorPath = "{0}{1}{2}" -f $editorRootPath,$unityVersion,$editorFileEx - - if ( -not (Test-Path -Path $editorPath) ) { - Write-Host "Installing $unityVersion ($unityVersionChangeSet)..." - $installArgs = @('--','--headless','install',"--version $unityVersion","--changeset $unityVersionChangeSet",'--cm'); - - foreach ( $module in $modules ) { - $installArgs += '-m' - $installArgs += $module - } - - $p = Start-Process -NoNewWindow -PassThru -Wait -FilePath "$hubPath" -ArgumentList $installArgs - Write-Host "" - } - - Write-Host "Getting installed editors..." - $p = Start-Process -NoNewWindow -PassThru -Wait -FilePath "$hubPath" -ArgumentList @('--','--headless','editors','-i') - Write-Host "" - - if ( -not (Test-Path -Path $editorPath) ) { - Write-Error "Failed to find a valid editor installation at `"$editorPath`"" - exit 1 - } - - Write-Host "Unity Editor path: `"$editorPath`"" - Write-Host "::set-output name=editor-path::$editorPath" - exit 0 - shell: powershell - - - uses: xrtk/unity-action@main - name: 'project-validation' - with: - name: 'project-validation' - editor-path: '${{ steps.validate-project-setup.outputs.editor-path }}' - project-path: '${{ steps.validate-project-setup.outputs.project-path }}' - args: '-quit -batchmode -executeMethod XRTK.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject' - - - uses: actions/upload-artifact@v2 - if: always() - with: - name: 'Validation-Results' - path: '${{ steps.validate-project-setup.outputs.project-path }}\Builds\Logs' - - - name: cleanup - run: | - $logDirectory = "${{ steps.validate-project-setup.outputs.project-path }}\Builds" - - if (Test-Path -Path $logDirectory) { - Remove-Item $logDirectory -Force -Recurse - } - shell: powershell - - build: - needs: validate - runs-on: self-hosted - strategy: - matrix: - build-target: [StandaloneWindows64, WSAPlayer, Android, Lumin] - max-parallel: 1 - - steps: - - uses: xrtk/unity-action@main - name: '${{ matrix.build-target }}-Tests' - with: - name: '${{ matrix.build-target }}-Tests' - editor-path: '${{ needs.validate.outputs.editor-path }}' - project-path: '${{ needs.validate.outputs.project-path }}' - build-target: '${{ matrix.build-target }}' - args: '-batchmode -runEditorTests' - - - uses: xrtk/unity-action@main - name: '${{ matrix.build-target }}-Build' - with: - name: '${{ matrix.build-target }}-Build' - editor-path: '${{ needs.validate.outputs.editor-path }}' - project-path: '${{ needs.validate.outputs.project-path }}' - build-target: '${{ matrix.build-target }}' - args: '-quit -batchmode -executeMethod XRTK.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild' - - - name: 'zip artifacts' - if: always() - run: | - $artifacts = "${{ needs.validate.outputs.project-path }}\Builds" - - if (Test-Path -Path $artifacts) { - Compress-Archive -Path "$artifacts\*" -DestinationPath ${{ github.workspace }}\${{ matrix.build-target }}-Artifacts.zip - Remove-Item $artifacts -Force -Recurse - } - shell: powershell - - - uses: actions/upload-artifact@v2 - if: always() - with: - name: '${{ matrix.build-target }}-Artifacts' - path: '${{ github.workspace }}\${{ matrix.build-target }}-Artifacts.zip'