1111 schedule :
1212 - cron : " 0 23 * * *" # Daily at 11 PM UTC
1313 workflow_dispatch : # Allow manual triggers
14+ inputs :
15+ version-bump :
16+ description : ' Version bump type'
17+ required : false
18+ default : ' auto'
19+ type : choice
20+ options :
21+ - auto
22+ - patch
23+ - minor
24+ - major
1425
1526concurrency :
1627 group : ${{ github.workflow }}-${{ github.ref }}
1728 cancel-in-progress : true
1829
1930# Default permissions
20- permissions : read-all
31+ permissions :
32+ contents : read
2133
2234env :
2335 DOTNET_VERSION : " 10.0" # Only needed for actions/setup-dotnet
3547 version : ${{ steps.pipeline.outputs.version }}
3648 release_hash : ${{ steps.pipeline.outputs.release_hash }}
3749 should_release : ${{ steps.pipeline.outputs.should_release }}
38- skipped_release : ${{ steps.pipeline.outputs.skipped_release }}
3950
4051 steps :
4152 - name : Set up JDK 17
@@ -95,72 +106,73 @@ jobs:
95106 New-Item -Path .\.sonar\scanner -ItemType Directory
96107 dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
97108
109+ - name : Configure SonarQube exclusions
110+ shell : bash
111+ run : |
112+ EXCLUSIONS="_temp/**,_actions/**"
113+ if [ "${{ github.event.repository.name }}" != "KtsuBuild" ]; then
114+ EXCLUSIONS="$EXCLUSIONS,**/KtsuBuild/**"
115+ fi
116+ echo "SONAR_EXCLUSIONS=$EXCLUSIONS" >> $GITHUB_ENV
117+
98118 - name : Begin SonarQube
99119 if : ${{ env.SONAR_TOKEN != '' }}
100120 env :
101121 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
102122 shell : powershell
103123 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.cs.vscoveragexml.reportsPaths="coverage/coverage.xml" /d:sonar.coverage.exclusions="**/*Test*.cs,**/*.Tests.cs,**/*.Tests/**/*,**/obj/**/*,**/*.dll" /d:sonar.cs.vstest.reportsPaths="coverage/TestResults/**/*.trx"
124+ .\.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.cs.vscoveragexml.reportsPaths="coverage/coverage.xml" /d:sonar.coverage.exclusions="**/*Test*.cs,**/*.Tests.cs,**/*.Tests/**/*,**/obj/**/*,**/*.dll" /d:sonar.cs.vstest.reportsPaths="coverage/TestResults/**/*.trx" /d:sonar.exclusions="${{ env.SONAR_EXCLUSIONS }}"
105125
106- - name : Run PSBuild Pipeline
126+ - name : Clone KtsuBuild (Latest Tag)
127+ run : |
128+ LATEST_TAG=$(git ls-remote --tags https://github.com/ktsu-dev/KtsuBuild.git | grep -o 'refs/tags/v[0-9]*\.[0-9]*\.[0-9]*$' | sed 's/refs\/tags\///' | sort -V | tail -1 || true)
129+ if [ -z "$LATEST_TAG" ]; then
130+ echo "No version tags found, falling back to HEAD"
131+ git clone --depth 1 https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
132+ else
133+ echo "Cloning KtsuBuild at tag: $LATEST_TAG"
134+ git clone --depth 1 --branch "$LATEST_TAG" https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
135+ fi
136+ shell : bash
137+
138+ - name : Run KtsuBuild CI Pipeline
107139 id : pipeline
108140 shell : pwsh
109141 env :
110142 GH_TOKEN : ${{ github.token }}
143+ NUGET_API_KEY : ${{ secrets.NUGET_KEY }}
144+ KTSU_PACKAGE_KEY : ${{ secrets.KTSU_PACKAGE_KEY }}
145+ EXPECTED_OWNER : ktsu-dev
111146 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
147+ # Run the CI pipeline
148+ $versionBump = "${{ github.event.inputs.version-bump }}"
149+
150+ # Build arguments array - only add --version-bump if explicitly set (for backward compatibility during bootstrap)
151+ $args = @("ci", "--workspace", "${{ github.workspace }}", "--verbose")
152+ if (![string]::IsNullOrEmpty($versionBump) -and $versionBump -ne "auto") {
153+ $args += @("--version-bump", $versionBump)
132154 }
133155
134- # Run the complete CI/CD pipeline
135- $result = Invoke-CIPipeline `
136- -BuildConfiguration $buildConfig.Data
156+ & dotnet run --project "${{ runner.temp }}/KtsuBuild/KtsuBuild.CLI" -- @args
137157
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- }
158+ # Set outputs for downstream jobs
159+ $version = (Get-Content "${{ github.workspace }}/VERSION.md" -Raw).Trim()
160+ "version=$version" >> $env:GITHUB_OUTPUT
144161
145- # Set outputs for GitHub Actions from build configuration and pipeline result
146- # Use pipeline result values when available (for skipped releases), otherwise use buildConfig
147- if ($result.Data.SkippedRelease) {
148- "version=$($result.Data.Version)" >> $env:GITHUB_OUTPUT
149- "release_hash=$($result.Data.ReleaseHash)" >> $env:GITHUB_OUTPUT
150- "should_release=$($buildConfig.Data.ShouldRelease)" >> $env:GITHUB_OUTPUT
151- "skipped_release=true" >> $env:GITHUB_OUTPUT
152- } else {
153- "version=$($buildConfig.Data.Version)" >> $env:GITHUB_OUTPUT
154- "release_hash=$($buildConfig.Data.ReleaseHash)" >> $env:GITHUB_OUTPUT
155- "should_release=$($buildConfig.Data.ShouldRelease)" >> $env:GITHUB_OUTPUT
156- # Check for skipped release from buildConfig as fallback
157- if ($buildConfig.Data.SkippedRelease) {
158- "skipped_release=true" >> $env:GITHUB_OUTPUT
159- }
160- }
162+ $releaseHash = git rev-parse HEAD
163+ "release_hash=$releaseHash" >> $env:GITHUB_OUTPUT
164+
165+ # Compute should_release (same logic as BuildConfigurationProvider)
166+ $isMain = "${{ github.ref }}" -eq "refs/heads/main"
167+ $isTagged = [bool](git tag --points-at "${{ github.sha }}" 2>$null)
168+ $isFork = "${{ github.event.repository.fork }}" -eq "true"
169+ $isExpectedOwner = "${{ github.repository_owner }}" -eq "ktsu-dev"
170+ $isOfficial = (-not $isFork) -and $isExpectedOwner
171+ $shouldRelease = $isMain -and (-not $isTagged) -and $isOfficial
172+ "should_release=$($shouldRelease.ToString().ToLower())" >> $env:GITHUB_OUTPUT
161173
162174 - name : End SonarQube
163- if : env.SONAR_TOKEN != '' && steps.pipeline.outputs.skipped_release != 'true'
175+ if : env.SONAR_TOKEN != ''
164176 env :
165177 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
166178 shell : powershell
@@ -169,7 +181,7 @@ jobs:
169181
170182 - name : Upload Coverage Report
171183 uses : actions/upload-artifact@v4
172- if : always() && steps.pipeline.outputs.skipped_release != 'true'
184+ if : always()
173185 with :
174186 name : coverage-report
175187 path : |
@@ -179,7 +191,7 @@ jobs:
179191 winget :
180192 name : Update Winget Manifests
181193 needs : build
182- if : needs.build.outputs.should_release == 'true' && needs.build.outputs.skipped_release != 'true'
194+ if : needs.build.outputs.should_release == 'true'
183195 runs-on : windows-latest
184196 timeout-minutes : 10
185197 permissions :
@@ -197,14 +209,24 @@ jobs:
197209 with :
198210 dotnet-version : ${{ env.DOTNET_VERSION }}.x
199211
212+ - name : Clone KtsuBuild (Latest Tag)
213+ run : |
214+ LATEST_TAG=$(git ls-remote --tags https://github.com/ktsu-dev/KtsuBuild.git | grep -o 'refs/tags/v[0-9]*\.[0-9]*\.[0-9]*$' | sed 's/refs\/tags\///' | sort -V | tail -1 || true)
215+ if [ -z "$LATEST_TAG" ]; then
216+ echo "No version tags found, falling back to HEAD"
217+ git clone --depth 1 https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
218+ else
219+ echo "Cloning KtsuBuild at tag: $LATEST_TAG"
220+ git clone --depth 1 --branch "$LATEST_TAG" https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
221+ fi
222+ shell : bash
223+
200224 - name : Update Winget Manifests
201225 shell : pwsh
202226 env :
203227 GH_TOKEN : ${{ github.token }}
204228 run : |
205- # Use enhanced script with auto-detection capabilities
206- Write-Host "Updating winget manifests for version ${{ needs.build.outputs.version }}"
207- .\scripts\update-winget-manifests.ps1 -Version "${{ needs.build.outputs.version }}"
229+ dotnet run --project "${{ runner.temp }}/KtsuBuild/KtsuBuild.CLI" -- winget generate --version "${{ needs.build.outputs.version }}" --workspace "${{ github.workspace }}" --verbose
208230
209231 - name : Upload Updated Manifests
210232 uses : actions/upload-artifact@v4
@@ -216,7 +238,7 @@ jobs:
216238 security :
217239 name : Security Scanning
218240 needs : build
219- if : needs.build.outputs.should_release == 'true' && needs.build.outputs.skipped_release != 'true'
241+ if : needs.build.outputs.should_release == 'true'
220242 runs-on : windows-latest
221243 timeout-minutes : 10
222244 permissions :
0 commit comments