Repository navigation
300 lines (257 loc) · 10.8 KB
/
Copy pathrelease.yml
File metadata and controls
300 lines (257 loc) · 10.8 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 8.0.11)'
required: true
type: string
prerelease:
description: 'Mark as prerelease'
required: false
default: false
type: boolean
env:
DOTNET_VERSION: '8.0.x'
DOTNET_VERSION_PREVIEW: '10.0.x'
SOLUTION_PATH: 'Source/Current/Windows API CodePack/Windows API CodePack.sln'
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json'
jobs:
prepare-release:
name: Prepare Release
runs-on: windows-latest
outputs:
version: ${{ steps.version.outputs.version }}
version-with-build: ${{ steps.version.outputs.version-with-build }}
build-number: ${{ steps.version.outputs.build-number }}
is-prerelease: ${{ steps.version.outputs.is-prerelease }}
tag-name: ${{ steps.version.outputs.tag-name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$version = "${{ github.event.inputs.version }}"
$isPrerelease = "${{ github.event.inputs.prerelease }}" -eq "true"
} else {
$tagName = "${{ github.ref_name }}"
$version = $tagName -replace '^v', ''
$isPrerelease = $version -match 'alpha|beta|rc|preview'
}
# Add build number
$buildNumber = ${{ github.run_number }}
$versionWithBuild = "$version.$buildNumber"
$tagName = "v$version"
Write-Host "═══════════════════════════════════════════════════════"
Write-Host " RELEASE INFORMATION"
Write-Host "═══════════════════════════════════════════════════════"
Write-Host "Version: $version"
Write-Host "Build Number: $buildNumber"
Write-Host "Full Version: $versionWithBuild"
Write-Host "Tag Name: $tagName"
Write-Host "Is Prerelease: $isPrerelease"
Write-Host "═══════════════════════════════════════════════════════"
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "version-with-build=$versionWithBuild" >> $env:GITHUB_OUTPUT
echo "build-number=$buildNumber" >> $env:GITHUB_OUTPUT
echo "is-prerelease=$isPrerelease" >> $env:GITHUB_OUTPUT
echo "tag-name=$tagName" >> $env:GITHUB_OUTPUT
shell: pwsh
build-and-package:
name: Build and Package
runs-on: windows-latest
needs: prepare-release
outputs:
version-with-build: ${{ needs.prepare-release.outputs.version-with-build }}
strategy:
matrix:
platform: [Any CPU, x64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ env.DOTNET_VERSION }}
${{ env.DOTNET_VERSION_PREVIEW }}
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.3
- name: Restore dependencies
run: |
dotnet restore "${{ env.SOLUTION_PATH }}" --verbosity normal
working-directory: .
- name: Prepare code signing certificate
id: prepare-cert
if: ${{ secrets.CODESIGN_CERTIFICATE_BASE64 != '' }}
run: |
$certPath = "${{ runner.temp }}\codesign.pfx"
$certBase64 = "${{ secrets.CODESIGN_CERTIFICATE_BASE64 }}"
$certBytes = [Convert]::FromBase64String($certBase64)
[System.IO.File]::WriteAllBytes($certPath, $certBytes)
Write-Host "Certificate prepared at: $certPath"
echo "cert-path=$certPath" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Build solution
run: |
$buildProps = @(
"--configuration Release",
"--platform ${{ matrix.platform }}",
"--no-restore",
"--verbosity normal",
"/p:AssemblyVersion=${{ needs.prepare-release.outputs.version-with-build }}",
"/p:FileVersion=${{ needs.prepare-release.outputs.version-with-build }}",
"/p:InformationalVersion=${{ needs.prepare-release.outputs.version-with-build }}+${{ github.sha }}"
)
# Add Authenticode signing properties if certificate is available
$certBase64 = "${{ secrets.CODESIGN_CERTIFICATE_BASE64 }}"
if ($certBase64 -ne "") {
# Use the certificate path from prepare-cert step, or fallback to temp path
$certPath = "${{ steps.prepare-cert.outputs.cert-path }}"
if (-not $certPath -or $certPath -eq "") {
$certPath = "${{ runner.temp }}\codesign.pfx"
}
$buildProps += "/p:EnableAuthenticodeSigning=true"
$buildProps += "/p:CodeSigningCertificatePath=`"$certPath`""
$certPassword = "${{ secrets.CODESIGN_CERTIFICATE_PASSWORD }}"
if ($certPassword -ne "") {
$buildProps += "/p:CodeSigningCertificatePassword=`"$certPassword`""
}
Write-Host "Authenticode signing enabled with certificate at: $certPath"
} else {
Write-Host "Authenticode signing disabled (no certificate provided)"
}
dotnet build "${{ env.SOLUTION_PATH }}" $buildProps
working-directory: .
- name: Pack NuGet packages
run: |
dotnet pack "${{ env.SOLUTION_PATH }}" --configuration Release --platform ${{ matrix.platform }} --no-build --verbosity normal --output ./packages
working-directory: .
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages-${{ matrix.platform }}
path: packages/
retention-days: 30
publish-nuget:
name: Publish to NuGet
runs-on: windows-latest
needs: [prepare-release, build-and-package]
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages-Any CPU
path: ./packages
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Publish to NuGet
run: |
$packages = Get-ChildItem -Path "./packages" -Filter "*.nupkg" | Where-Object { $_.Name -notlike "*symbols*" }
foreach ($package in $packages) {
Write-Host "Publishing package: $($package.Name)"
dotnet nuget push $package.FullName --source ${{ env.NUGET_SOURCE }} --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
}
shell: pwsh
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
create-github-release:
name: Create GitHub Release
runs-on: windows-latest
needs: [prepare-release, build-and-package]
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages-Any CPU
path: ./packages
- name: Generate release notes
id: release-notes
run: |
$version = "${{ needs.prepare-release.outputs.version }}"
$tagName = "${{ needs.prepare-release.outputs.tag-name }}"
$isPrerelease = "${{ needs.prepare-release.outputs.is-prerelease }}" -eq "true"
$releaseNotes = @"
## Windows API CodePack $version
### What's Changed
- Updated Windows API CodePack to version $version
- Built for .NET Framework 4.6.2-4.8.1 and .NET 8-10
- Includes Core, Shell, Sensors, ExtendedLinguisticServices, and ShellExtensions packages
### Packages Included
**Unified Package (All Components):**
- WindowsAPICodePack (includes all components below)
**Individual Packages:**
- WindowsAPICodePackCore
- WindowsAPICodePackShell
- WindowsAPICodePackSensors
- WindowsAPICodePackExtendedLinguisticServices
- WindowsAPICodePackShellExtensions
### Installation
**Option 1 - Install everything (Recommended):**
```bash
Install-Package WindowsAPICodePack
```
**Option 2 - Install individual components:**
```bash
Install-Package WindowsAPICodePackCore
Install-Package WindowsAPICodePackShell
# ... other packages as needed
```
### Requirements
- .NET Framework 4.6.2 or later
- .NET 8.0 or later
- Windows 10/11
"@
$releaseNotes | Out-File -FilePath "release-notes.md" -Encoding UTF8
echo "release-notes-file=release-notes.md" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.prepare-release.outputs.tag-name }}
name: Windows API CodePack ${{ needs.prepare-release.outputs.version }}
body_path: ${{ steps.release-notes.outputs.release-notes-file }}
draft: false
prerelease: ${{ needs.prepare-release.outputs.is-prerelease }}
files: |
packages/*.nupkg
packages/*.snupkg
notify:
name: Notify Release
runs-on: windows-latest
needs: [prepare-release, publish-nuget, create-github-release]
if: always() && (needs.publish-nuget.result == 'success' || needs.create-github-release.result == 'success')
steps:
- name: Notify Success
if: needs.publish-nuget.result == 'success' && needs.create-github-release.result == 'success'
run: |
Write-Host "✅ Release ${{ needs.prepare-release.outputs.version }} published successfully!"
Write-Host "📦 NuGet packages published to NuGet.org"
Write-Host "🏷️ GitHub release created"
shell: pwsh
- name: Notify Partial Success
if: (needs.publish-nuget.result == 'success' || needs.create-github-release.result == 'success') && (needs.publish-nuget.result != 'success' || needs.create-github-release.result != 'success')
run: |
Write-Host "⚠️ Release ${{ needs.prepare-release.outputs.version }} completed with warnings"
Write-Host "NuGet publish result: ${{ needs.publish-nuget.result }}"
Write-Host "GitHub release result: ${{ needs.create-github-release.result }}"
shell: pwsh