-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (133 loc) · 6.42 KB
/
release.yml
File metadata and controls
149 lines (133 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Release & Publish NuGet
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Setup NuGet
uses: nuget/setup-nuget@v2
- name: Find MSBuild & VS paths
id: vs
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vsPath = & $vswhere -latest -requires Microsoft.Component.MSBuild -property installationPath
$msbuild = & $vswhere -latest -requires Microsoft.Component.MSBuild -find "MSBuild\**\Bin\MSBuild.exe" | Select-Object -First 1
Write-Host "VS Installation: $vsPath"
Write-Host "MSBuild: $msbuild"
"MSBUILD=$msbuild" >> $env:GITHUB_OUTPUT
"VS_PATH=$vsPath" >> $env:GITHUB_OUTPUT
- name: Extract version from tag
id: version
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$ver = $tag -replace '^v', ''
"VERSION=$ver" >> $env:GITHUB_OUTPUT
- name: Restore & Build UWP library
shell: pwsh
run: |
# CCV ProjectReferences CompositionExpressions; both UWP projects
# need their PackageReferences restored explicitly because
# `nuget restore` doesn't follow ProjectReferences across legacy
# UAP csprojs the way `dotnet restore` does for SDK-style ones.
nuget restore src/CompositionExpressions/CompositionExpressions.csproj
nuget restore src/CompositionCollectionView/CompositionCollectionView.csproj
# Build the leaf first so its output is available when CCV is built.
& "${{ steps.vs.outputs.MSBUILD }}" src/CompositionExpressions/CompositionExpressions.csproj `
/t:Build /p:Configuration=Release /p:Platform=AnyCPU
& "${{ steps.vs.outputs.MSBUILD }}" src/CompositionCollectionView/CompositionCollectionView.csproj `
/t:Build /p:Configuration=Release /p:Platform=AnyCPU
- name: Resolve AppxMSBuildToolsPath
id: appx
shell: pwsh
run: |
# dotnet build has .NET 10 but not VS's PRI task DLLs. We just need AppxMSBuildToolsPath.
# The MrtCore.PriGen.targets construct: $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\AppxPackage\
# We override AppxMSBuildToolsPath to point directly to VS's copy.
$vsPath = "${{ steps.vs.outputs.VS_PATH }}"
$msbuildDir = "$vsPath\MSBuild"
$vsVerDir = Get-ChildItem "$msbuildDir\Microsoft\VisualStudio" -Directory -Filter "v*" | Select-Object -First 1
$appxPath = "$($vsVerDir.FullName)\AppxPackage"
Write-Host "AppxMSBuildToolsPath: $appxPath"
Write-Host "PRI DLL exists: $(Test-Path "$appxPath\Microsoft.Build.Packaging.Pri.Tasks.dll")"
"APPX_PATH=$appxPath" >> $env:GITHUB_OUTPUT
- name: Restore & Build WinAppSdk library (AnyCPU - for lib/ compile ref)
shell: pwsh
run: |
# AnyCPU produces an MSIL (Machine=Intel-386, IL-only) binary that
# both nuspecs use as the compile-time reference under lib/net10.0,
# so consumers building for x64/ARM64 don't see MSB3270/CS8012.
dotnet restore src/CompositionCollectionView.WinAppSdk/CompositionCollectionView.WinAppSdk.csproj -p:Platform=AnyCPU
dotnet build src/CompositionCollectionView.WinAppSdk/CompositionCollectionView.WinAppSdk.csproj `
-c Release `
--no-restore `
-p:Platform=AnyCPU `
"-p:AppxMSBuildToolsPath=${{ steps.appx.outputs.APPX_PATH }}\"
- name: Restore & Build WinAppSdk library (x64)
shell: pwsh
run: |
dotnet restore src/CompositionCollectionView.WinAppSdk/CompositionCollectionView.WinAppSdk.csproj -p:Platform=x64
dotnet build src/CompositionCollectionView.WinAppSdk/CompositionCollectionView.WinAppSdk.csproj `
-c Release `
--no-restore `
-p:Platform=x64 `
"-p:AppxMSBuildToolsPath=${{ steps.appx.outputs.APPX_PATH }}\"
- name: Restore & Build WinAppSdk library (ARM64)
shell: pwsh
run: |
dotnet restore src/CompositionCollectionView.WinAppSdk/CompositionCollectionView.WinAppSdk.csproj -p:Platform=ARM64
dotnet build src/CompositionCollectionView.WinAppSdk/CompositionCollectionView.WinAppSdk.csproj `
-c Release `
--no-restore `
-p:Platform=ARM64 `
"-p:AppxMSBuildToolsPath=${{ steps.appx.outputs.APPX_PATH }}\"
- name: Pack NuGet
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
nuget pack CompositionExpressions.nuspec `
-Version ${{ steps.version.outputs.VERSION }} `
-OutputDirectory artifacts
if ($LASTEXITCODE -ne 0) { throw "nuget pack CompositionExpressions failed" }
nuget pack CompositionCollectionView.nuspec `
-Version ${{ steps.version.outputs.VERSION }} `
-OutputDirectory artifacts
if ($LASTEXITCODE -ne 0) { throw "nuget pack CompositionCollectionView failed" }
- name: Upload nupkg artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: artifacts/*.nupkg
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/*.nupkg
- name: Push to NuGet.org
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$key = "${{ secrets.NUGET_API_KEY }}"
if (-not $key) { throw "NUGET_API_KEY secret is not set." }
# NOTE: --skip-duplicate intentionally NOT used. If a previous run
# already pushed this version (e.g. from an earlier failed attempt
# before a fix landed), we want this push to FAIL LOUDLY so we
# know to bump the version. Silent skip + uploaded "good" artifact
# caused 0.1.5 to ship with stale (x64-only) compile-time refs.
Get-ChildItem artifacts\*.nupkg | ForEach-Object {
dotnet nuget push $_.FullName `
--api-key $key `
--source https://api.nuget.org/v3/index.json
if ($LASTEXITCODE -ne 0) { throw "Push failed for $($_.Name)" }
}