diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a667d3929..4bbef50df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,6 +38,21 @@ on: type: string required: false default: 'preview' + suffix: + description: 'Version suffix identifying this distribution, e.g. nakamir.0' + type: string + required: false + default: '' + skRendererRef: + description: 'sk_renderer ref to build against. Empty uses the CPM-pinned release.' + type: string + required: false + default: '' + nugetSource: + description: 'NuGet feed to push to' + type: string + required: false + default: 'https://api.nuget.org/v3/index.json' workflow_call: inputs: branch: @@ -76,6 +91,11 @@ on: type: string required: false default: 'preview' + nugetSource: + description: 'NuGet feed to push to' + type: string + required: false + default: 'https://api.nuget.org/v3/index.json' secrets: NUGET_KEY: required: true @@ -83,6 +103,7 @@ on: permissions: contents: write actions: write + packages: write jobs: @@ -99,6 +120,19 @@ jobs: ref: ${{ inputs.branch }} - uses: lukka/get-cmake@v4.3.3 + - name: Check out sk_renderer + if: inputs.skRendererRef != '' + uses: actions/checkout@v4 + with: + repository: Nakamir-Code/sk_renderer + ref: ${{ inputs.skRendererRef }} + path: .sk_renderer + + - name: Move sk_renderer beside the repo + if: inputs.skRendererRef != '' + shell: pwsh + run: Move-Item .sk_renderer (Join-Path (Split-Path $env:GITHUB_WORKSPACE -Parent) 'sk_renderer') + - name: Get Cache uses: actions/cache@v4 with: @@ -144,6 +178,19 @@ jobs: ref: ${{ inputs.branch }} - uses: lukka/get-cmake@v4.3.3 + - name: Check out sk_renderer + if: inputs.skRendererRef != '' + uses: actions/checkout@v4 + with: + repository: Nakamir-Code/sk_renderer + ref: ${{ inputs.skRendererRef }} + path: .sk_renderer + + - name: Move sk_renderer beside the repo + if: inputs.skRendererRef != '' + shell: pwsh + run: Move-Item .sk_renderer (Join-Path (Split-Path $env:GITHUB_WORKSPACE -Parent) 'sk_renderer') + - name: Get Cache uses: actions/cache@v4 with: @@ -236,6 +283,19 @@ jobs: ref: ${{ inputs.branch }} - uses: lukka/get-cmake@v4.3.3 + - name: Check out sk_renderer + if: inputs.skRendererRef != '' + uses: actions/checkout@v4 + with: + repository: Nakamir-Code/sk_renderer + ref: ${{ inputs.skRendererRef }} + path: .sk_renderer + + - name: Move sk_renderer beside the repo + if: inputs.skRendererRef != '' + shell: pwsh + run: Move-Item .sk_renderer (Join-Path (Split-Path $env:GITHUB_WORKSPACE -Parent) 'sk_renderer') + - name: Get Cache uses: actions/cache@v4 with: @@ -295,12 +355,12 @@ jobs: - name: Set Version shell: pwsh - run: ./tools/Set-Version.ps1 -major ${{inputs.major}} -minor ${{inputs.minor}} -patch ${{inputs.patch}} -pre ${{inputs.pre}} -preName ${{inputs.preName}} + run: ./tools/Set-Version.ps1 -major ${{inputs.major}} -minor ${{inputs.minor}} -patch ${{inputs.patch}} -pre ${{inputs.pre}} -preName ${{inputs.preName}} -suffix '${{inputs.suffix}}' - name: Build Package and Upload if: inputs.upload == true shell: pwsh - run: ./tools/Build-Nuget.ps1 -nobuild -notest -upload -key ${{ secrets.NUGET_KEY }} + run: ./tools/Build-Nuget.ps1 -nobuild -notest -upload -key ${{ secrets.NUGET_KEY || secrets.GITHUB_TOKEN }} -source '${{ inputs.nugetSource }}' - name: Build Package without Upload if: inputs.upload == false diff --git a/StereoKit/StereoKit.csproj b/StereoKit/StereoKit.csproj index c739dbc60..2562cdf60 100644 --- a/StereoKit/StereoKit.csproj +++ b/StereoKit/StereoKit.csproj @@ -27,6 +27,7 @@ MIT OpenXR C# AR VR MR XR MixedReality HoloLens false + true true diff --git a/tools/Build-Nuget.ps1 b/tools/Build-Nuget.ps1 index 47b57b505..415ea2985 100755 --- a/tools/Build-Nuget.ps1 +++ b/tools/Build-Nuget.ps1 @@ -3,6 +3,7 @@ param( [switch]$noTest = $false, [switch]$noBuild = $false, [string]$key = '', + [string]$source = 'https://api.nuget.org/v3/index.json', [string]$saveKey = '', [switch]$noLinux = $false, [switch]$noWin32 = $false, @@ -61,7 +62,7 @@ Push-Location -Path (Join-Path $PSScriptRoot "..") $version = & (Join-Path $PSScriptRoot "Get-Version.ps1") # Ensure all versions match the source of truth -& (Join-Path $PSScriptRoot "Set-Version.ps1") -major $version.major -minor $version.minor -patch $version.patch -pre $version.pre +& (Join-Path $PSScriptRoot "Set-Version.ps1") -major $version.major -minor $version.minor -patch $version.patch -pre $version.pre -suffix $version.suffix # Notify of build, and output the version Write-Host @" @@ -220,7 +221,7 @@ if ($upload) { if ($key -ne '') { $key = $key.Trim() $nupkgPath = Join-Path $PSScriptRoot ".." "bin" "StereoKit.$($version.str).nupkg" - & dotnet nuget push $nupkgPath -k $key -s https://api.nuget.org/v3/index.json + & dotnet nuget push $nupkgPath -k $key -s $source } else { Write-Host 'No key, cancelling upload' } diff --git a/tools/Get-Version.ps1 b/tools/Get-Version.ps1 index c395e6c2a..39ed5418e 100755 --- a/tools/Get-Version.ps1 +++ b/tools/Get-Version.ps1 @@ -14,8 +14,16 @@ if ($pre -ne 0) { $str = "$str-preview.$pre" } +# A distribution suffix lives only in the csproj, and extends this version. +$suffix = '' +if ((Get-Content -Path "$PSScriptRoot\..\StereoKit\StereoKit.csproj" -Raw -ErrorAction SilentlyContinue) -match "(?$([regex]::Escape($str))[-.][^<]+)") { + $suffix = $Matches.ver.Substring($str.Length + 1) + $str = $Matches.ver +} + return @{ 'str' = $str; + 'suffix' = $suffix; 'major' = $major; 'minor' = $minor; 'patch' = $patch; diff --git a/tools/Set-Version.ps1 b/tools/Set-Version.ps1 index 98c414983..760bc85b3 100755 --- a/tools/Set-Version.ps1 +++ b/tools/Set-Version.ps1 @@ -2,7 +2,8 @@ param( [int]$major, [int]$minor, [int]$patch, - [int]$pre = 0 + [int]$pre = 0, + [string]$suffix = '' ) $version = "$major.$minor.$patch" @@ -10,6 +11,10 @@ $versionFull = $version if ($pre -ne 0) { $versionFull = "$version-preview.$pre" } +# Distribution suffix for forks, e.g. 'nakamir.0'. +if ($suffix -ne '') { + $versionFull = "$versionFull$(if ($pre -ne 0) { '.' } else { '-' })$suffix" +} # This file is the source of truth for the version. It may even be the source # of the version provided as an argument. Overwriting it may be redundant, but