Skip to content

Commit 83fec61

Browse files
committed
Update build.yml
1 parent 880415e commit 83fec61

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

.github/workflows/build.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,121 @@ jobs:
7474

7575
- name: Build
7676
run: msbuild "Scripts/nightly.proj" /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU"
77+
78+
release:
79+
runs-on: windows-2022
80+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
81+
needs: build
82+
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v5
86+
87+
# .NET 9 (GA)
88+
- name: Setup .NET 9
89+
uses: actions/setup-dotnet@v4
90+
with:
91+
dotnet-version: 9.0.x
92+
93+
# .NET 10 (Preview)
94+
- name: Setup .NET 10 (preview)
95+
uses: actions/setup-dotnet@v4
96+
with:
97+
dotnet-version: 10.0.x
98+
dotnet-quality: preview
99+
100+
# global.json dynamisch erzeugen
101+
- name: Force .NET 10 SDK via global.json
102+
run: |
103+
$sdkVersion = (dotnet --list-sdks | Select-String "10.0").ToString().Split(" ")[0]
104+
Write-Output "Using SDK $sdkVersion"
105+
@"
106+
{
107+
"sdk": {
108+
"version": "$sdkVersion",
109+
"rollForward": "latestFeature"
110+
}
111+
}
112+
"@ | Out-File -Encoding utf8 global.json
113+
114+
- name: Setup MSBuild
115+
uses: microsoft/setup-msbuild@v2
116+
with:
117+
msbuild-architecture: x64
118+
119+
- name: Setup NuGet
120+
uses: NuGet/[email protected]
121+
122+
- name: Cache NuGet
123+
uses: actions/cache@v4
124+
with:
125+
path: ~/.nuget/packages
126+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
127+
restore-keys: |
128+
${{ runner.os }}-nuget-
129+
130+
- name: Restore
131+
run: dotnet restore "Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln"
132+
133+
- name: Build Release
134+
run: msbuild "Scripts/build.proj" /t:Build /p:Configuration=Release /p:Platform="Any CPU"
135+
136+
- name: Pack Release
137+
run: msbuild "Scripts/build.proj" /t:Pack /p:Configuration=Release /p:Platform="Any CPU"
138+
139+
- name: Create Release Archives
140+
run: msbuild "Scripts/build.proj" /t:CreateAllReleaseArchives /p:Configuration=Release /p:Platform="Any CPU"
141+
142+
- name: Get Version
143+
id: get_version
144+
run: |
145+
$version = (dotnet build "Source/Krypton Components/Krypton.Toolkit/Krypton.Toolkit.csproj" --no-restore --verbosity quiet | Select-String "Version" | ForEach-Object { $_.Line.Split('=')[1].Trim() })
146+
if (-not $version) {
147+
$version = "100.25.1.1" # Fallback version
148+
}
149+
echo "version=$version" >> $env:GITHUB_OUTPUT
150+
echo "tag=v$version" >> $env:GITHUB_OUTPUT
151+
152+
- name: Create Release
153+
run: |
154+
$releaseBody = @"
155+
## Krypton Toolkit Suite Release ${{ steps.get_version.outputs.version }}
156+
157+
This release includes:
158+
- All Krypton Toolkit components
159+
- NuGet packages for multiple target frameworks
160+
- Release archives (ZIP and TAR.GZ formats)
161+
162+
### Downloads
163+
- **ZIP Archive**: `Krypton-Release_*.zip`
164+
- **TAR.GZ Archive**: `Krypton-Release_*.tar.gz`
165+
166+
### Target Frameworks
167+
- .NET Framework 4.7.2
168+
- .NET Framework 4.8
169+
- .NET Framework 4.8.1
170+
- .NET 8.0 Windows
171+
- .NET 9.0 Windows
172+
- .NET 10.0 Windows
173+
"@
174+
175+
gh release create ${{ steps.get_version.outputs.tag }} `
176+
--title "Release ${{ steps.get_version.outputs.version }}" `
177+
--notes "$releaseBody" `
178+
--latest
179+
env:
180+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
181+
182+
- name: Upload Release Assets
183+
run: |
184+
$zipFile = Get-ChildItem "Bin/Release/Zips/Krypton-Release_*.zip" | Select-Object -First 1
185+
$tarFile = Get-ChildItem "Bin/Release/Zips/Krypton-Release_*.tar.gz" | Select-Object -First 1
186+
187+
if ($zipFile) {
188+
gh release upload ${{ steps.get_version.outputs.tag }} "$($zipFile.FullName)" --clobber
189+
}
190+
if ($tarFile) {
191+
gh release upload ${{ steps.get_version.outputs.tag }} "$($tarFile.FullName)" --clobber
192+
}
193+
env:
194+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)