Skip to content

Commit 5fad4fb

Browse files
committed
Add support for .NET 10.0, update workflows, and enhance NuGet package cleaning
1 parent 481955f commit 5fad4fb

14 files changed

Lines changed: 369 additions & 465 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
name: Build and Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
configuration:
7+
description: Build configuration to use
8+
required: false
9+
type: string
10+
default: Release
11+
version-tag-name:
12+
description: Tag name to use when calculating a release version
13+
required: false
14+
type: string
15+
default: ''
16+
collect-coverage:
17+
description: Whether to collect test coverage
18+
required: false
19+
type: boolean
20+
default: false
21+
outputs:
22+
version:
23+
description: Calculated semantic version
24+
value: ${{ jobs.version.outputs.version }}
25+
nuget-version:
26+
description: Calculated NuGet package version
27+
value: ${{ jobs.version.outputs.nuget-version }}
28+
assembly-version:
29+
description: Calculated assembly version
30+
value: ${{ jobs.version.outputs.assembly-version }}
31+
file-version:
32+
description: Calculated file version
33+
value: ${{ jobs.version.outputs.file-version }}
34+
informational-version:
35+
description: Calculated informational version
36+
value: ${{ jobs.version.outputs.informational-version }}
37+
version-source:
38+
description: Where the version came from
39+
value: ${{ jobs.version.outputs.version-source }}
40+
secrets:
41+
codecov-token:
42+
required: false
43+
44+
permissions:
45+
contents: read
46+
packages: read
47+
48+
env:
49+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
50+
DOTNET_NOLOGO: true
51+
DOTNET_CLI_TELEMETRY_OPTOUT: true
52+
53+
jobs:
54+
version:
55+
name: Calculate Version
56+
runs-on: ubuntu-latest
57+
outputs:
58+
version: ${{ steps.calculate.outputs.version }}
59+
nuget-version: ${{ steps.calculate.outputs.nuget-version }}
60+
assembly-version: ${{ steps.calculate.outputs.assembly-version }}
61+
file-version: ${{ steps.calculate.outputs.file-version }}
62+
informational-version: ${{ steps.calculate.outputs.informational-version }}
63+
version-source: ${{ steps.calculate.outputs.version-source }}
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Install GitVersion
71+
uses: gittools/actions/gitversion/setup@v1.1.1
72+
with:
73+
versionSpec: '5.x'
74+
75+
- name: Determine Version
76+
id: gitversion
77+
uses: gittools/actions/gitversion/execute@v1.1.1
78+
79+
- name: Calculate Version Metadata
80+
id: calculate
81+
run: |
82+
set -euo pipefail
83+
tag_name="${{ inputs.version-tag-name }}"
84+
85+
if [[ -n "$tag_name" ]]; then
86+
version="${tag_name#v}"
87+
88+
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$ ]]; then
89+
echo "Invalid tag version: $version" >&2
90+
exit 1
91+
fi
92+
93+
assembly_version="${version%%[-+]*}.0"
94+
if [[ ! "$assembly_version" =~ \.[0-9]+$ ]]; then
95+
assembly_version="${assembly_version}.0"
96+
fi
97+
98+
echo "version=$version" >> "$GITHUB_OUTPUT"
99+
echo "nuget-version=$version" >> "$GITHUB_OUTPUT"
100+
echo "assembly-version=$assembly_version" >> "$GITHUB_OUTPUT"
101+
echo "file-version=$assembly_version" >> "$GITHUB_OUTPUT"
102+
echo "informational-version=$version" >> "$GITHUB_OUTPUT"
103+
echo "version-source=input-tag" >> "$GITHUB_OUTPUT"
104+
elif [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
105+
version="${GITHUB_REF_NAME#v}"
106+
107+
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$ ]]; then
108+
echo "Invalid tag version: $version" >&2
109+
exit 1
110+
fi
111+
112+
assembly_version="${version%%[-+]*}.0"
113+
if [[ ! "$assembly_version" =~ \.[0-9]+$ ]]; then
114+
assembly_version="${assembly_version}.0"
115+
fi
116+
117+
echo "version=$version" >> "$GITHUB_OUTPUT"
118+
echo "nuget-version=$version" >> "$GITHUB_OUTPUT"
119+
echo "assembly-version=$assembly_version" >> "$GITHUB_OUTPUT"
120+
echo "file-version=$assembly_version" >> "$GITHUB_OUTPUT"
121+
echo "informational-version=$version" >> "$GITHUB_OUTPUT"
122+
echo "version-source=tag" >> "$GITHUB_OUTPUT"
123+
else
124+
echo "version=${{ steps.gitversion.outputs.SemVer }}" >> "$GITHUB_OUTPUT"
125+
echo "nuget-version=${{ steps.gitversion.outputs.NuGetVersionV2 }}" >> "$GITHUB_OUTPUT"
126+
echo "assembly-version=${{ steps.gitversion.outputs.AssemblySemVer }}" >> "$GITHUB_OUTPUT"
127+
echo "file-version=${{ steps.gitversion.outputs.AssemblySemFileVer }}" >> "$GITHUB_OUTPUT"
128+
echo "informational-version=${{ steps.gitversion.outputs.InformationalVersion }}" >> "$GITHUB_OUTPUT"
129+
echo "version-source=gitversion" >> "$GITHUB_OUTPUT"
130+
fi
131+
shell: bash
132+
133+
build:
134+
needs: version
135+
name: Build and Test
136+
strategy:
137+
fail-fast: true
138+
matrix:
139+
include:
140+
- dotnet: '8.0.x'
141+
dotnet-framework: 'net8.0'
142+
os: ubuntu-latest
143+
- dotnet: '8.0.x'
144+
dotnet-framework: 'net8.0'
145+
os: windows-latest
146+
- dotnet: '9.0.x'
147+
dotnet-framework: 'net9.0'
148+
os: ubuntu-latest
149+
- dotnet: '9.0.x'
150+
dotnet-framework: 'net9.0'
151+
os: windows-latest
152+
- dotnet: '10.0.x'
153+
dotnet-framework: 'net10.0'
154+
os: ubuntu-latest
155+
- dotnet: '10.0.x'
156+
dotnet-framework: 'net10.0'
157+
os: windows-latest
158+
159+
runs-on: ${{ matrix.os }}
160+
161+
steps:
162+
- uses: actions/checkout@v4
163+
with:
164+
fetch-depth: 0
165+
166+
- name: Setup .NET ${{ matrix.dotnet }}
167+
uses: actions/setup-dotnet@v4
168+
with:
169+
dotnet-version: ${{ matrix.dotnet }}
170+
171+
- name: Restore dependencies
172+
run: dotnet restore Deveel.Messaging.Model.sln -p:TargetFramework=${{ matrix.dotnet-framework }}
173+
174+
- name: Build
175+
run: >
176+
dotnet build Deveel.Messaging.Model.sln
177+
--no-restore
178+
--configuration "${{ inputs.configuration }}"
179+
--framework "${{ matrix.dotnet-framework }}"
180+
--verbosity normal
181+
-p:Version="${{ needs.version.outputs.version }}"
182+
-p:PackageVersion="${{ needs.version.outputs.nuget-version }}"
183+
-p:AssemblyVersion="${{ needs.version.outputs.assembly-version }}"
184+
-p:FileVersion="${{ needs.version.outputs.file-version }}"
185+
-p:InformationalVersion="${{ needs.version.outputs.informational-version }}"
186+
-p:UseGitVersion=false
187+
188+
- name: Test
189+
if: inputs.collect-coverage != true
190+
run: >
191+
dotnet test Deveel.Messaging.Model.sln
192+
--no-build
193+
--verbosity normal
194+
--configuration "${{ inputs.configuration }}"
195+
--framework "${{ matrix.dotnet-framework }}"
196+
197+
- name: Test with coverage
198+
if: inputs.collect-coverage == true
199+
run: >
200+
dotnet test Deveel.Messaging.Model.sln
201+
--no-build
202+
--verbosity normal
203+
--configuration "${{ inputs.configuration }}"
204+
--framework "${{ matrix.dotnet-framework }}"
205+
--
206+
--coverage
207+
--coverage-output-format cobertura
208+
--coverage-output coverage.cobertura.xml
209+
210+
- name: Upload coverage to Codecov
211+
if: inputs.collect-coverage == true && secrets.codecov-token != ''
212+
uses: codecov/codecov-action@v4
213+
with:
214+
files: ./test/**/TestResults/coverage.cobertura.xml
215+
flags: ${{ matrix.dotnet-framework }},${{ matrix.os }}
216+
name: ${{ matrix.os }}-${{ matrix.dotnet-framework }}
217+
fail_ci_if_error: false
218+
verbose: true
219+
env:
220+
CODECOV_TOKEN: ${{ secrets.codecov-token }}

.github/workflows/cd.yml

Lines changed: 18 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -14,116 +14,26 @@ env:
1414
DOTNET_CLI_TELEMETRY_OPTOUT: true
1515

1616
jobs:
17-
calculate-version:
18-
name: "Calculate Version"
19-
runs-on: ubuntu-latest
20-
outputs:
21-
version: ${{ steps.gitversion.outputs.semVer }}
22-
nuget-version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
23-
assembly-version: ${{ steps.gitversion.outputs.assemblySemVer }}
24-
file-version: ${{ steps.gitversion.outputs.assemblySemFileVer }}
25-
informational-version: ${{ steps.gitversion.outputs.informationalVersion }}
26-
is-prerelease: ${{ contains(steps.gitversion.outputs.nuGetVersionV2, '-') }}
27-
28-
steps:
29-
- uses: actions/checkout@v4
30-
with:
31-
fetch-depth: 0
32-
33-
- name: Install GitVersion
34-
uses: gittools/actions/gitversion/setup@v1.1.1
35-
with:
36-
versionSpec: '5.x'
37-
38-
- name: Determine Version
39-
id: gitversion
40-
uses: gittools/actions/gitversion/execute@v1.1.1
41-
42-
- name: Display GitVersion Results
43-
run: |
44-
echo "🔍 GitVersion 5.x Results:"
45-
echo "Branch: ${{ github.ref }}"
46-
echo "SemVer: '${{ steps.gitversion.outputs.semVer }}'"
47-
echo "NuGetVersionV2: '${{ steps.gitversion.outputs.nuGetVersionV2 }}'"
48-
echo "AssemblySemVer: '${{ steps.gitversion.outputs.assemblySemVer }}'"
49-
echo "AssemblySemFileVer: '${{ steps.gitversion.outputs.assemblySemFileVer }}'"
50-
echo "InformationalVersion: '${{ steps.gitversion.outputs.informationalVersion }}'"
51-
echo "PreReleaseTag: '${{ steps.gitversion.outputs.preReleaseTag }}'"
52-
echo "PreReleaseNumber: '${{ steps.gitversion.outputs.preReleaseNumber }}'"
53-
echo "CommitsSinceVersionSource: '${{ steps.gitversion.outputs.commitsSinceVersionSource }}'"
54-
echo "Is Pre-release: ${{ contains(steps.gitversion.outputs.nuGetVersionV2, '-') }}"
55-
echo ""
56-
echo "📋 Expected behavior:"
57-
echo "- CD workflow should ALWAYS produce pre-release versions"
58-
echo "- main branch should produce versions like: X.Y.Z-alpha.N"
59-
echo "- develop branch should produce versions like: X.Y.Z-dev.N"
60-
echo "- Only tagged releases from release workflow should produce stable versions"
61-
6217
build:
63-
needs: calculate-version
6418
name: "Build and Test"
65-
strategy:
66-
matrix:
67-
include:
68-
- dotnet: '8.0.x'
69-
dotnet-framework: 'net8.0'
70-
os: ubuntu-latest
71-
- dotnet: '8.0.x'
72-
dotnet-framework: 'net8.0'
73-
os: windows-latest
74-
- dotnet: '9.0.x'
75-
dotnet-framework: 'net9.0'
76-
os: ubuntu-latest
77-
- dotnet: '9.0.x'
78-
dotnet-framework: 'net9.0'
79-
os: windows-latest
80-
81-
runs-on: ${{ matrix.os }}
82-
83-
steps:
84-
- uses: actions/checkout@v4
85-
with:
86-
fetch-depth: 0
87-
88-
- name: Setup .NET ${{ matrix.dotnet }}
89-
uses: actions/setup-dotnet@v4
90-
with:
91-
dotnet-version: ${{ matrix.dotnet }}
92-
93-
- name: Display Build Version Info
94-
run: |
95-
echo "🔍 Build Version Information (from GitVersion 5.x):"
96-
echo "SemVer: ${{ needs.calculate-version.outputs.version }}"
97-
echo "NuGet Version: ${{ needs.calculate-version.outputs.nuget-version }}"
98-
echo "Assembly Version: ${{ needs.calculate-version.outputs.assembly-version }}"
99-
echo "File Version: ${{ needs.calculate-version.outputs.file-version }}"
100-
echo "Informational Version: ${{ needs.calculate-version.outputs.informational-version }}"
101-
echo "Is Pre-release: ${{ needs.calculate-version.outputs.is-prerelease }}"
102-
103-
- name: Restore dependencies
104-
run: dotnet restore -p:TargetFramework=${{ matrix.dotnet-framework }}
105-
106-
- name: Build
107-
run: |
108-
echo "🏗️ Building with GitVersion 5.x integration..."
109-
dotnet build --no-restore -c Release -f ${{ matrix.dotnet-framework }} -p:UseGitVersion=true --verbosity normal
110-
111-
- name: Test
112-
run: dotnet test --no-build --verbosity normal -c Release -f ${{ matrix.dotnet-framework }}
19+
uses: ./.github/workflows/build-test.yml
20+
with:
21+
configuration: Release
11322

11423
publish:
115-
needs: [calculate-version, build]
24+
needs: build
11625
name: "Publish Pre-release Packages (CI/CD)"
11726
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
11827
uses: ./.github/workflows/publish.yml
11928
with:
12029
publish-to-nuget: false
12130
build-configuration: 'Release'
122-
version: ${{ needs.calculate-version.outputs.version }}
123-
nuget-version: ${{ needs.calculate-version.outputs.nuget-version }}
124-
assembly-version: ${{ needs.calculate-version.outputs.assembly-version }}
125-
informational-version: ${{ needs.calculate-version.outputs.informational-version }}
126-
secrets: inherit
31+
version: ${{ needs.build.outputs.version }}
32+
nuget-version: ${{ needs.build.outputs.nuget-version }}
33+
assembly-version: ${{ needs.build.outputs.assembly-version }}
34+
informational-version: ${{ needs.build.outputs.informational-version }}
35+
secrets:
36+
github-token: ${{ secrets.GITHUB_TOKEN }}
12737

12838
clean:
12939
needs: publish
@@ -132,39 +42,21 @@ jobs:
13242
uses: ./.github/workflows/clean-packages.yml
13343

13444
summary:
135-
needs: [calculate-version, build, publish]
45+
needs: [build, publish]
13646
runs-on: ubuntu-latest
13747
if: always()
13848
steps:
13949
- name: CD Workflow Summary
14050
run: |
141-
echo "## 🚀 CD Workflow Summary (GitVersion 5.x Direct)" >> $GITHUB_STEP_SUMMARY
51+
echo "## 🚀 CD Workflow Summary" >> $GITHUB_STEP_SUMMARY
14252
echo "" >> $GITHUB_STEP_SUMMARY
14353
echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
14454
echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY
14555
echo "| Branch | \`${{ github.ref_name }}\` |" >> $GITHUB_STEP_SUMMARY
146-
echo "| Version (GitVersion) | \`${{ needs.calculate-version.outputs.version }}\` |" >> $GITHUB_STEP_SUMMARY
147-
echo "| NuGet Version (GitVersion) | \`${{ needs.calculate-version.outputs.nuget-version }}\` |" >> $GITHUB_STEP_SUMMARY
148-
echo "| Assembly Version (GitVersion) | \`${{ needs.calculate-version.outputs.assembly-version }}\` |" >> $GITHUB_STEP_SUMMARY
149-
echo "| Pre-release | ${{ needs.calculate-version.outputs.is-prerelease == 'true' && '✅ Yes' || '❌ No' }} |" >> $GITHUB_STEP_SUMMARY
56+
echo "| Version | \`${{ needs.build.outputs.version }}\` |" >> $GITHUB_STEP_SUMMARY
57+
echo "| NuGet Version | \`${{ needs.build.outputs.nuget-version }}\` |" >> $GITHUB_STEP_SUMMARY
58+
echo "| Assembly Version | \`${{ needs.build.outputs.assembly-version }}\` |" >> $GITHUB_STEP_SUMMARY
59+
echo "| Version Source | \`${{ needs.build.outputs.version-source }}\` |" >> $GITHUB_STEP_SUMMARY
60+
echo "| Pre-release | ${{ contains(needs.build.outputs.nuget-version, '-') && '✅ Yes' || '❌ No' }} |" >> $GITHUB_STEP_SUMMARY
15061
echo "| Published to GitHub | ${{ needs.publish.result == 'success' && '✅ Yes' || '❌ No' }} |" >> $GITHUB_STEP_SUMMARY
151-
echo "" >> $GITHUB_STEP_SUMMARY
152-
153-
if [ "${{ needs.calculate-version.outputs.is-prerelease }}" == "true" ]; then
154-
echo "🎯 **Pre-release Package**: This version is directly from GitVersion 5.x" >> $GITHUB_STEP_SUMMARY
155-
echo "📦 **Usage**: Install with \`--prerelease\` flag: \`dotnet add package PackageName --version ${{ needs.calculate-version.outputs.nuget-version }} --prerelease\`" >> $GITHUB_STEP_SUMMARY
156-
echo "✅ **GitVersion Direct**: No manual version construction - all versions from GitVersion 5.x" >> $GITHUB_STEP_SUMMARY
157-
else
158-
echo "⚠️ **Warning**: GitVersion produced a stable version!" >> $GITHUB_STEP_SUMMARY
159-
echo "🏷️ **Current**: \`${{ needs.calculate-version.outputs.nuget-version }}\`" >> $GITHUB_STEP_SUMMARY
160-
echo "🔧 **Action Required**: Check GitVersion configuration for branch labeling" >> $GITHUB_STEP_SUMMARY
161-
fi
162-
echo "" >> $GITHUB_STEP_SUMMARY
163-
echo "📋 **Versioning Strategy**:" >> $GITHUB_STEP_SUMMARY
164-
echo "- **CI/CD Workflow** (this): GitVersion 5.x calculates all versions directly" >> $GITHUB_STEP_SUMMARY
165-
echo " - **main**: GitVersion → \`X.Y.Z-alpha.N\` versions" >> $GITHUB_STEP_SUMMARY
166-
echo " - **develop**: GitVersion → \`X.Y.Z-dev.N\` versions" >> $GITHUB_STEP_SUMMARY
167-
echo "- **Release Workflow**: GitVersion produces stable versions from tags (\`X.Y.Z\`)" >> $GITHUB_STEP_SUMMARY
168-
echo "- **Build Process**: Uses \`-p:UseGitVersion=true\` to integrate directly" >> $GITHUB_STEP_SUMMARY
169-
echo "" >> $GITHUB_STEP_SUMMARY
170-
echo "📦 **Published Packages**: Check the [GitHub Packages](https://github.com/${{ github.repository }}/pkgs) for the published packages." >> $GITHUB_STEP_SUMMARY
62+
shell: bash

0 commit comments

Comments
 (0)