Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -76,13 +91,19 @@ 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

permissions:
contents: write
actions: write
packages: write

jobs:

Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions StereoKit/StereoKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>OpenXR C# AR VR MR XR MixedReality HoloLens</PackageTags>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

Expand Down
5 changes: 3 additions & 2 deletions tools/Build-Nuget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 @"
Expand Down Expand Up @@ -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'
}
Expand Down
8 changes: 8 additions & 0 deletions tools/Get-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<Version>(?<ver>$([regex]::Escape($str))[-.][^<]+)</Version>") {
$suffix = $Matches.ver.Substring($str.Length + 1)
$str = $Matches.ver
}

return @{
'str' = $str;
'suffix' = $suffix;
'major' = $major;
'minor' = $minor;
'patch' = $patch;
Expand Down
7 changes: 6 additions & 1 deletion tools/Set-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ param(
[int]$major,
[int]$minor,
[int]$patch,
[int]$pre = 0
[int]$pre = 0,
[string]$suffix = ''
)

$version = "$major.$minor.$patch"
$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
Expand Down
Loading