Skip to content

Commit 4e7d9f6

Browse files
authored
Merge pull request #2598 from Krypton-Suite/alpha-nightly-workflow-poc
* Add nightly workflow PoC
2 parents 6c863d4 + 8dd83b0 commit 4e7d9f6

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE)
2+
# Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, tobitege et al. 2025 - 2025. All rights reserved.
3+
4+
name: Nightly Release
5+
6+
on:
7+
schedule:
8+
# Run nightly build automatically at midnight UTC every day
9+
- cron: '0 0 * * *'
10+
workflow_dispatch: # Allow manual triggering for testing
11+
12+
jobs:
13+
nightly:
14+
runs-on: windows-2022
15+
retention-days: 30
16+
17+
# Ensure this only runs for the alpha branch, even if the workflow is in main
18+
if: github.ref == 'refs/heads/alpha'
19+
20+
concurrency:
21+
group: nightly-alpha
22+
cancel-in-progress: true
23+
24+
steps:
25+
- name: Checkout alpha branch
26+
uses: actions/checkout@v5
27+
with:
28+
ref: alpha
29+
30+
# .NET 9 (GA)
31+
- name: Setup .NET 9
32+
uses: actions/setup-dotnet@v4
33+
with:
34+
dotnet-version: 9.0.x
35+
36+
# .NET 10 (Preview)
37+
- name: Setup .NET 10 (preview)
38+
uses: actions/setup-dotnet@v4
39+
with:
40+
dotnet-version: 10.0.x
41+
dotnet-quality: preview
42+
43+
# global.json dynamically generate (use latest SDK available)
44+
- name: Force .NET 10 SDK via global.json
45+
run: |
46+
$sdkVersion = (dotnet --list-sdks | Select-String "10.0").ToString().Split(" ")[0]
47+
if (-not $sdkVersion) {
48+
# Fallback to .NET 8 if .NET 10 is not available
49+
$sdkVersion = (dotnet --list-sdks | Select-String "8.0").ToString().Split(" ")[0]
50+
}
51+
Write-Output "Using SDK $sdkVersion"
52+
@"
53+
{
54+
"sdk": {
55+
"version": "$sdkVersion",
56+
"rollForward": "latestFeature"
57+
}
58+
}
59+
"@ | Out-File -Encoding utf8 global.json
60+
61+
- name: Setup MSBuild
62+
uses: microsoft/setup-msbuild@v2
63+
with:
64+
msbuild-architecture: x64
65+
66+
- name: Setup NuGet
67+
uses: NuGet/[email protected]
68+
69+
- name: Cache NuGet
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.nuget/packages
73+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
74+
restore-keys: |
75+
${{ runner.os }}-nuget-
76+
77+
- name: Restore
78+
run: dotnet restore "Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln"
79+
80+
- name: Build Nightly
81+
run: msbuild "Scripts/nightly.proj" /t:Build /p:Configuration=Nightly /p:Platform="Any CPU"
82+
83+
- name: Pack Nightly
84+
run: msbuild "Scripts/nightly.proj" /t:Pack /p:Configuration=Nightly /p:Platform="Any CPU"
85+
86+
- name: Push NuGet Packages to nuget.org
87+
id: push_nuget
88+
shell: pwsh
89+
run: |
90+
$ErrorActionPreference = 'Stop'
91+
if (-not $env:NUGET_API_KEY) {
92+
Write-Warning "NUGET_API_KEY not set - skipping NuGet push"
93+
echo "packages_published=false" >> $env:GITHUB_OUTPUT
94+
exit 0
95+
}
96+
97+
$packages = Get-ChildItem "Bin/Packages/Nightly/*.nupkg" -ErrorAction SilentlyContinue
98+
$publishedAny = $false
99+
100+
if ($packages) {
101+
foreach ($package in $packages) {
102+
Write-Output "Pushing package: $($package.Name)"
103+
try {
104+
$output = dotnet nuget push "$($package.FullName)" --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate 2>&1 | Out-String
105+
Write-Output $output
106+
if ($output -notmatch "already exists" -and $output -notmatch "was not pushed") {
107+
$publishedAny = $true
108+
Write-Host "Package $($package.Name) was published"
109+
} else {
110+
Write-Host "Package $($package.Name) already exists - skipped"
111+
}
112+
} catch {
113+
Write-Warning "Failed to push $($package.Name): $_"
114+
}
115+
}
116+
} else {
117+
Write-Output "No NuGet packages found to push"
118+
}
119+
120+
echo "packages_published=$publishedAny" >> $env:GITHUB_OUTPUT
121+
env:
122+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

0 commit comments

Comments
 (0)