Skip to content

Commit 67a6d3b

Browse files
Refactor project files and update SDK references. Remove unused package versions from Directory.Packages.props, enhance PSBuild.psm1 for optional NuGet and Ktsu package publishing, and streamline GitHub Actions workflows for better clarity and functionality. Add CompatibilitySuppressions.xml for compatibility diagnostics.
1 parent 55795a7 commit 67a6d3b

15 files changed

Lines changed: 2667 additions & 212 deletions

.github/workflows/dotnet.yml

Lines changed: 183 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ name: .NET Workflow
33
on:
44
push:
55
branches: [main, develop]
6-
paths-ignore: ['**.md', '.github/ISSUE_TEMPLATE/**', '.github/pull_request_template.md']
6+
paths-ignore:
7+
["**.md", ".github/ISSUE_TEMPLATE/**", ".github/pull_request_template.md"]
78
pull_request:
8-
paths-ignore: ['**.md', '.github/ISSUE_TEMPLATE/**', '.github/pull_request_template.md']
9+
paths-ignore:
10+
["**.md", ".github/ISSUE_TEMPLATE/**", ".github/pull_request_template.md"]
911
schedule:
10-
- cron: "0 23 * * *" # Daily at 11 PM UTC
12+
- cron: "0 23 * * *" # Daily at 11 PM UTC
13+
workflow_dispatch: # Allow manual triggers
1114

1215
concurrency:
1316
group: ${{ github.workflow }}-${{ github.ref }}
@@ -17,105 +20,206 @@ concurrency:
1720
permissions: read-all
1821

1922
env:
20-
DOTNET_VERSION: '9.0' # Only needed for actions/setup-dotnet
23+
DOTNET_VERSION: "9.0" # Only needed for actions/setup-dotnet
2124

2225
jobs:
2326
build:
2427
name: Build, Test & Release
2528
runs-on: windows-latest
2629
timeout-minutes: 15
2730
permissions:
28-
contents: write # For creating releases and committing metadata
29-
packages: write # For publishing packages
31+
contents: write # For creating releases and committing metadata
32+
packages: write # For publishing packages
3033

3134
outputs:
3235
version: ${{ steps.pipeline.outputs.version }}
3336
release_hash: ${{ steps.pipeline.outputs.release_hash }}
3437
should_release: ${{ steps.pipeline.outputs.should_release }}
38+
skipped_release: ${{ steps.pipeline.outputs.skipped_release }}
3539

3640
steps:
37-
- name: Checkout Repository
38-
uses: actions/checkout@v4
39-
with:
40-
fetch-depth: 0 # Full history for versioning
41-
fetch-tags: true
42-
lfs: true
43-
submodules: recursive
44-
persist-credentials: true
45-
46-
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
47-
uses: actions/setup-dotnet@v4
48-
with:
49-
dotnet-version: ${{ env.DOTNET_VERSION }}.x
50-
cache: true
51-
cache-dependency-path: '**/*.csproj'
52-
53-
- name: Run PSBuild Pipeline
54-
id: pipeline
55-
shell: pwsh
56-
env:
57-
GH_TOKEN: ${{ github.token }}
58-
run: |
59-
# Import the PSBuild module
60-
Import-Module ${{ github.workspace }}/scripts/PSBuild.psm1
61-
62-
# Get build configuration
63-
$buildConfig = Get-BuildConfiguration `
64-
-ServerUrl "${{ github.server_url }}" `
65-
-GitRef "${{ github.ref }}" `
66-
-GitSha "${{ github.sha }}" `
67-
-GitHubOwner "${{ github.repository_owner }}" `
68-
-GitHubRepo "${{ github.repository }}" `
69-
-GithubToken "${{ github.token }}" `
70-
-NuGetApiKey "${{ secrets.NUGET_KEY }}" `
71-
-WorkspacePath "${{ github.workspace }}" `
72-
-ExpectedOwner "ktsu-dev" `
73-
-ChangelogFile "CHANGELOG.md" `
74-
-AssetPatterns @("staging/*.nupkg", "staging/*.zip")
75-
76-
if (-not $buildConfig.Success) {
77-
throw $buildConfig.Error
78-
}
79-
80-
# Run the complete CI/CD pipeline
81-
$result = Invoke-CIPipeline `
82-
-BuildConfiguration $buildConfig.Data
83-
84-
if (-not $result.Success) {
85-
Write-Information "CI/CD pipeline failed: $($result.Error)" -Tags "Invoke-CIPipeline"
86-
Write-Information "Stack Trace: $($result.StackTrace)" -Tags "Invoke-CIPipeline"
87-
Write-Information "Build Configuration: $($buildConfig.Data | ConvertTo-Json -Depth 10)" -Tags "Invoke-CIPipeline"
88-
throw $result.Error
89-
}
90-
91-
# Set outputs for GitHub Actions from build configuration
92-
"version=$($buildConfig.Data.Version)" >> $env:GITHUB_OUTPUT
93-
"release_hash=$($buildConfig.Data.ReleaseHash)" >> $env:GITHUB_OUTPUT
94-
"should_release=$($buildConfig.Data.ShouldRelease)" >> $env:GITHUB_OUTPUT
95-
96-
- name: Upload Coverage Report
97-
uses: actions/upload-artifact@v4
98-
if: always()
99-
with:
100-
name: coverage-report
101-
path: ./coverage
102-
retention-days: 7
41+
- name: Set up JDK 17
42+
uses: actions/setup-java@v4
43+
with:
44+
java-version: 17
45+
distribution: "zulu" # Alternative distribution options are available.
46+
47+
- name: Checkout Repository
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0 # Full history for versioning
51+
fetch-tags: true
52+
lfs: true
53+
submodules: recursive
54+
persist-credentials: true
55+
56+
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
57+
uses: actions/setup-dotnet@v4
58+
with:
59+
dotnet-version: ${{ env.DOTNET_VERSION }}.x
60+
cache: true
61+
cache-dependency-path: "**/*.csproj"
62+
63+
- name: Install dotnet-coverage
64+
shell: pwsh
65+
run: |
66+
dotnet tool install --global dotnet-coverage
67+
68+
- name: Cache SonarQube Cloud packages
69+
if: ${{ env.SONAR_TOKEN != '' }}
70+
uses: actions/cache@v4
71+
env:
72+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
73+
with:
74+
path: ~\sonar\cache
75+
key: ${{ runner.os }}-sonar
76+
restore-keys: ${{ runner.os }}-sonar
77+
78+
- name: Cache SonarQube Cloud scanner
79+
if: ${{ env.SONAR_TOKEN != '' }}
80+
id: cache-sonar-scanner
81+
uses: actions/cache@v4
82+
env:
83+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
84+
with:
85+
path: .\.sonar\scanner
86+
key: ${{ runner.os }}-sonar-scanner
87+
restore-keys: ${{ runner.os }}-sonar-scanner
88+
89+
- name: Install SonarQube Cloud scanner
90+
if: ${{ env.SONAR_TOKEN != '' && steps.cache-sonar-scanner.outputs.cache-hit != 'true' }}
91+
env:
92+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
93+
shell: pwsh
94+
run: |
95+
New-Item -Path .\.sonar\scanner -ItemType Directory
96+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
97+
98+
- name: Begin SonarQube
99+
if: ${{ env.SONAR_TOKEN != '' }}
100+
env:
101+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
102+
shell: pwsh
103+
run: |
104+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"${{ github.repository_owner }}_${{ github.event.repository.name }}" /o:"${{ github.repository_owner }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverage.exclusions="**/*Tests/**/*,**/*Test/**/*,**/obj/**/*,**/*.dll" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
105+
106+
- name: Run PSBuild Pipeline
107+
id: pipeline
108+
shell: pwsh
109+
env:
110+
GH_TOKEN: ${{ github.token }}
111+
run: |
112+
# Import the PSBuild module
113+
Import-Module ${{ github.workspace }}/scripts/PSBuild.psm1
114+
115+
# Get build configuration
116+
$buildConfig = Get-BuildConfiguration `
117+
-ServerUrl "${{ github.server_url }}" `
118+
-GitRef "${{ github.ref }}" `
119+
-GitSha "${{ github.sha }}" `
120+
-GitHubOwner "${{ github.repository_owner }}" `
121+
-GitHubRepo "${{ github.repository }}" `
122+
-GithubToken "${{ github.token }}" `
123+
-NuGetApiKey "${{ secrets.NUGET_KEY }}" `
124+
-KtsuPackageKey "${{ secrets.KTSU_PACKAGE_KEY }}" `
125+
-WorkspacePath "${{ github.workspace }}" `
126+
-ExpectedOwner "ktsu-dev" `
127+
-ChangelogFile "CHANGELOG.md" `
128+
-AssetPatterns @("staging/*.nupkg", "staging/*.zip")
129+
130+
if (-not $buildConfig.Success) {
131+
throw $buildConfig.Error
132+
}
133+
134+
# Run the complete CI/CD pipeline
135+
$result = Invoke-CIPipeline `
136+
-BuildConfiguration $buildConfig.Data
137+
138+
if (-not $result.Success) {
139+
Write-Information "CI/CD pipeline failed: $($result.Error)" -Tags "Invoke-CIPipeline"
140+
Write-Information "Stack Trace: $($result.StackTrace)" -Tags "Invoke-CIPipeline"
141+
Write-Information "Build Configuration: $($buildConfig.Data | ConvertTo-Json -Depth 10)" -Tags "Invoke-CIPipeline"
142+
throw $result.Error
143+
}
144+
145+
# Set outputs for GitHub Actions from build configuration
146+
"version=$($buildConfig.Data.Version)" >> $env:GITHUB_OUTPUT
147+
"release_hash=$($buildConfig.Data.ReleaseHash)" >> $env:GITHUB_OUTPUT
148+
"should_release=$($buildConfig.Data.ShouldRelease)" >> $env:GITHUB_OUTPUT
149+
150+
if ($buildConfig.Data.SkippedRelease) {
151+
"skipped_release=true" >> $env:GITHUB_OUTPUT
152+
}
153+
154+
- name: End SonarQube
155+
if: env.SONAR_TOKEN != '' && steps.pipeline.outputs.skipped_release != 'true'
156+
env:
157+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
158+
shell: pwsh
159+
run: |
160+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
161+
162+
- name: Upload Coverage Report
163+
uses: actions/upload-artifact@v4
164+
if: always() && steps.pipeline.outputs.skipped_release != 'true'
165+
with:
166+
name: coverage-report
167+
path: |
168+
./coverage/*
169+
retention-days: 7
170+
171+
winget:
172+
name: Update Winget Manifests
173+
needs: build
174+
if: needs.build.outputs.should_release == 'true' && needs.build.outputs.skipped_release != 'true'
175+
runs-on: windows-latest
176+
timeout-minutes: 10
177+
permissions:
178+
contents: write
179+
180+
steps:
181+
- name: Checkout Release Commit
182+
uses: actions/checkout@v4
183+
with:
184+
ref: ${{ needs.build.outputs.release_hash }}
185+
fetch-depth: 0 # Full history for better auto-detection
186+
187+
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
188+
uses: actions/setup-dotnet@v4
189+
with:
190+
dotnet-version: ${{ env.DOTNET_VERSION }}.x
191+
192+
- name: Update Winget Manifests
193+
shell: pwsh
194+
env:
195+
GH_TOKEN: ${{ github.token }}
196+
run: |
197+
# Use enhanced script with auto-detection capabilities
198+
Write-Host "Updating winget manifests for version ${{ needs.build.outputs.version }}"
199+
.\scripts\update-winget-manifests.ps1 -Version "${{ needs.build.outputs.version }}"
200+
201+
- name: Upload Updated Manifests
202+
uses: actions/upload-artifact@v4
203+
with:
204+
name: winget-manifests-${{ needs.build.outputs.version }}
205+
path: winget/*.yaml
206+
retention-days: 30
103207

104208
security:
105209
name: Security Scanning
106210
needs: build
107-
if: needs.build.outputs.should_release == 'true'
211+
if: needs.build.outputs.should_release == 'true' && needs.build.outputs.skipped_release != 'true'
108212
runs-on: windows-latest
109213
timeout-minutes: 10
110214
permissions:
111215
id-token: write # For dependency submission
112216
contents: write # For dependency submission
113217

114218
steps:
115-
- name: Checkout Release Commit
116-
uses: actions/checkout@v4
117-
with:
118-
ref: ${{ needs.build.outputs.release_hash }}
219+
- name: Checkout Release Commit
220+
uses: actions/checkout@v4
221+
with:
222+
ref: ${{ needs.build.outputs.release_hash }}
119223

120-
- name: Detect Dependencies
121-
uses: advanced-security/component-detection-dependency-submission-action@v0.0.2
224+
- name: Detect Dependencies
225+
uses: advanced-security/component-detection-dependency-submission-action@v0.0.2

0 commit comments

Comments
 (0)