Skip to content

Commit 8fd9a3d

Browse files
SyncFileContentsSyncFileContents
authored andcommitted
Sync .github\workflows\dotnet.yml
1 parent 3c5fe80 commit 8fd9a3d

1 file changed

Lines changed: 51 additions & 58 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
version: ${{ steps.pipeline.outputs.version }}
3636
release_hash: ${{ steps.pipeline.outputs.release_hash }}
3737
should_release: ${{ steps.pipeline.outputs.should_release }}
38-
skipped_release: ${{ steps.pipeline.outputs.skipped_release }}
3938

4039
steps:
4140
- name: Set up JDK 17
@@ -103,64 +102,48 @@ jobs:
103102
run: |
104103
.\.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"
105104
106-
- name: Run PSBuild Pipeline
105+
- name: Clone KtsuBuild (Latest Tag)
106+
run: |
107+
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)
108+
if [ -z "$LATEST_TAG" ]; then
109+
echo "No version tags found, falling back to HEAD"
110+
git clone --depth 1 https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
111+
else
112+
echo "Cloning KtsuBuild at tag: $LATEST_TAG"
113+
git clone --depth 1 --branch "$LATEST_TAG" https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
114+
fi
115+
shell: bash
116+
117+
- name: Run KtsuBuild CI Pipeline
107118
id: pipeline
108119
shell: pwsh
109120
env:
110121
GH_TOKEN: ${{ github.token }}
122+
NUGET_API_KEY: ${{ secrets.NUGET_KEY }}
123+
KTSU_PACKAGE_KEY: ${{ secrets.KTSU_PACKAGE_KEY }}
124+
EXPECTED_OWNER: ktsu-dev
111125
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 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-
}
126+
# Run the CI pipeline
127+
dotnet run --project "${{ runner.temp }}/KtsuBuild/KtsuBuild.CLI" -- ci --workspace "${{ github.workspace }}" --verbose
128+
129+
# Set outputs for downstream jobs
130+
$version = (Get-Content "${{ github.workspace }}/VERSION.md" -Raw).Trim()
131+
"version=$version" >> $env:GITHUB_OUTPUT
132+
133+
$releaseHash = git rev-parse HEAD
134+
"release_hash=$releaseHash" >> $env:GITHUB_OUTPUT
135+
136+
# Compute should_release (same logic as BuildConfigurationProvider)
137+
$isMain = "${{ github.ref }}" -eq "refs/heads/main"
138+
$isTagged = [bool](git tag --points-at "${{ github.sha }}" 2>$null)
139+
$isFork = "${{ github.event.repository.fork }}" -eq "true"
140+
$isExpectedOwner = "${{ github.repository_owner }}" -eq "ktsu-dev"
141+
$isOfficial = (-not $isFork) -and $isExpectedOwner
142+
$shouldRelease = $isMain -and (-not $isTagged) -and $isOfficial
143+
"should_release=$($shouldRelease.ToString().ToLower())" >> $env:GITHUB_OUTPUT
161144
162145
- name: End SonarQube
163-
if: env.SONAR_TOKEN != '' && steps.pipeline.outputs.skipped_release != 'true'
146+
if: env.SONAR_TOKEN != ''
164147
env:
165148
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
166149
shell: powershell
@@ -169,7 +152,7 @@ jobs:
169152
170153
- name: Upload Coverage Report
171154
uses: actions/upload-artifact@v4
172-
if: always() && steps.pipeline.outputs.skipped_release != 'true'
155+
if: always()
173156
with:
174157
name: coverage-report
175158
path: |
@@ -179,7 +162,7 @@ jobs:
179162
winget:
180163
name: Update Winget Manifests
181164
needs: build
182-
if: needs.build.outputs.should_release == 'true' && needs.build.outputs.skipped_release != 'true'
165+
if: needs.build.outputs.should_release == 'true'
183166
runs-on: windows-latest
184167
timeout-minutes: 10
185168
permissions:
@@ -197,14 +180,24 @@ jobs:
197180
with:
198181
dotnet-version: ${{ env.DOTNET_VERSION }}.x
199182

183+
- name: Clone KtsuBuild (Latest Tag)
184+
run: |
185+
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)
186+
if [ -z "$LATEST_TAG" ]; then
187+
echo "No version tags found, falling back to HEAD"
188+
git clone --depth 1 https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
189+
else
190+
echo "Cloning KtsuBuild at tag: $LATEST_TAG"
191+
git clone --depth 1 --branch "$LATEST_TAG" https://github.com/ktsu-dev/KtsuBuild.git "${{ runner.temp }}/KtsuBuild"
192+
fi
193+
shell: bash
194+
200195
- name: Update Winget Manifests
201196
shell: pwsh
202197
env:
203198
GH_TOKEN: ${{ github.token }}
204199
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 }}"
200+
dotnet run --project "${{ runner.temp }}/KtsuBuild/KtsuBuild.CLI" -- winget generate --version "${{ needs.build.outputs.version }}" --workspace "${{ github.workspace }}" --verbose
208201
209202
- name: Upload Updated Manifests
210203
uses: actions/upload-artifact@v4
@@ -216,7 +209,7 @@ jobs:
216209
security:
217210
name: Security Scanning
218211
needs: build
219-
if: needs.build.outputs.should_release == 'true' && needs.build.outputs.skipped_release != 'true'
212+
if: needs.build.outputs.should_release == 'true'
220213
runs-on: windows-latest
221214
timeout-minutes: 10
222215
permissions:

0 commit comments

Comments
 (0)