Skip to content

Commit cedfce3

Browse files
committed
Fixing the invokaction of publish script from release and CD with versions as inputs
1 parent ec2c439 commit cedfce3

File tree

2 files changed

+59
-69
lines changed

2 files changed

+59
-69
lines changed

.github/workflows/cd.yml

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,9 @@ env:
1414
DOTNET_CLI_TELEMETRY_OPTOUT: true
1515

1616
jobs:
17-
build:
18-
name: "Build and Test"
19-
strategy:
20-
matrix:
21-
include:
22-
- dotnet: '8.0.x'
23-
dotnet-framework: 'net8.0'
24-
os: ubuntu-latest
25-
- dotnet: '8.0.x'
26-
dotnet-framework: 'net8.0'
27-
os: windows-latest
28-
- dotnet: '9.0.x'
29-
dotnet-framework: 'net9.0'
30-
os: ubuntu-latest
31-
- dotnet: '9.0.x'
32-
dotnet-framework: 'net9.0'
33-
os: windows-latest
34-
35-
runs-on: ${{ matrix.os }}
36-
17+
calculate-version:
18+
name: "Calculate Version"
19+
runs-on: ubuntu-latest
3720
outputs:
3821
version: ${{ steps.gitversion.outputs.SemVer }}
3922
nuget-version: ${{ steps.gitversion.outputs.NuGetVersion }}
@@ -54,16 +37,46 @@ jobs:
5437
- name: Determine Version
5538
id: gitversion
5639
uses: gittools/actions/gitversion/execute@v4.0.1
40+
with:
41+
useConfigFile: true
5742

5843
- name: Display GitVersion outputs
5944
run: |
45+
echo "?? CD Version Calculation:"
46+
echo "Branch: ${{ github.ref }}"
6047
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
6148
echo "NuGet Version: ${{ steps.gitversion.outputs.NuGetVersion }}"
6249
echo "Assembly Version: ${{ steps.gitversion.outputs.AssemblySemVer }}"
6350
echo "File Version: ${{ steps.gitversion.outputs.AssemblySemFileVer }}"
6451
echo "Informational Version: ${{ steps.gitversion.outputs.InformationalVersion }}"
6552
66-
- name: Setup .NET ${{ matrix.dotnot }}
53+
build:
54+
needs: calculate-version
55+
name: "Build and Test"
56+
strategy:
57+
matrix:
58+
include:
59+
- dotnet: '8.0.x'
60+
dotnet-framework: 'net8.0'
61+
os: ubuntu-latest
62+
- dotnet: '8.0.x'
63+
dotnet-framework: 'net8.0'
64+
os: windows-latest
65+
- dotnet: '9.0.x'
66+
dotnet-framework: 'net9.0'
67+
os: ubuntu-latest
68+
- dotnet: '9.0.x'
69+
dotnet-framework: 'net9.0'
70+
os: windows-latest
71+
72+
runs-on: ${{ matrix.os }}
73+
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
78+
79+
- name: Setup .NET ${{ matrix.dotnet }}
6780
uses: actions/setup-dotnet@v4
6881
with:
6982
dotnet-version: ${{ matrix.dotnet }}
@@ -74,11 +87,11 @@ jobs:
7487
- name: Build
7588
run: dotnet build --no-restore -c Release -f ${{ matrix.dotnet-framework }}
7689
env:
77-
GitVersion_SemVer: ${{ steps.gitversion.outputs.SemVer }}
78-
GitVersion_AssemblySemVer: ${{ steps.gitversion.outputs.AssemblySemVer }}
79-
GitVersion_AssemblySemFileVer: ${{ steps.gitversion.outputs.AssemblySemFileVer }}
80-
GitVersion_InformationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }}
81-
GitVersion_NuGetVersion: ${{ steps.gitversion.outputs.NuGetVersion }}
90+
GitVersion_SemVer: ${{ needs.calculate-version.outputs.version }}
91+
GitVersion_AssemblySemVer: ${{ needs.calculate-version.outputs.assembly-version }}
92+
GitVersion_AssemblySemFileVer: ${{ needs.calculate-version.outputs.file-version }}
93+
GitVersion_InformationalVersion: ${{ needs.calculate-version.outputs.informational-version }}
94+
GitVersion_NuGetVersion: ${{ needs.calculate-version.outputs.nuget-version }}
8295

8396
- name: Test (Ubuntu)
8497
if: startsWith(matrix.os, 'ubuntu')
@@ -89,12 +102,18 @@ jobs:
89102
run: dotnet test --no-build --verbosity normal -c Release -f ${{ matrix.dotnet-framework }} --filter "DB!=SQLServer"
90103

91104
publish:
92-
needs: build
105+
needs: [calculate-version, build]
93106
name: "Publish Packages (Development)"
94107
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
95108
uses: ./.github/workflows/publish.yml
96109
with:
97110
publish-to-nuget: false
111+
build-configuration: 'Release'
112+
version: ${{ needs.calculate-version.outputs.version }}
113+
nuget-version: ${{ needs.calculate-version.outputs.nuget-version }}
114+
assembly-version: ${{ needs.calculate-version.outputs.assembly-version }}
115+
informational-version: ${{ needs.calculate-version.outputs.informational-version }}
116+
secrets: inherit
98117

99118
clean:
100119
needs: publish

.github/workflows/pr.yml

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,9 @@ env:
1414
DOTNET_CLI_TELEMETRY_OPTOUT: true
1515

1616
jobs:
17-
build:
18-
name: "Build and Test"
19-
strategy:
20-
matrix:
21-
include:
22-
- dotnet: '8.0.x'
23-
dotnet-framework: 'net8.0'
24-
os: ubuntu-latest
25-
- dotnet: '8.0.x'
26-
dotnet-framework: 'net8.0'
27-
os: windows-latest
28-
- dotnet: '9.0.x'
29-
dotnet-framework: 'net9.0'
30-
os: ubuntu-latest
31-
- dotnet: '9.0.x'
32-
dotnet-framework: 'net9.0'
33-
os: windows-latest
34-
35-
runs-on: ${{ matrix.os }}
36-
17+
calculate-version:
18+
name: "Calculate Version"
19+
runs-on: ubuntu-latest
3720
outputs:
3821
version: ${{ steps.gitversion.outputs.SemVer }}
3922
nuget-version: ${{ steps.gitversion.outputs.NuGetVersion }}
@@ -54,37 +37,22 @@ jobs:
5437
- name: Determine Version
5538
id: gitversion
5639
uses: gittools/actions/gitversion/execute@v4.0.1
40+
with:
41+
useConfigFile: true
5742

5843
- name: Display GitVersion outputs
5944
run: |
45+
echo "🔍 PR Version Calculation:"
46+
echo "PR: #${{ github.event.number }} (${{ github.head_ref }} → ${{ github.base_ref }})"
6047
echo "Version: ${{ steps.gitversion.outputs.SemVer }}"
6148
echo "NuGet Version: ${{ steps.gitversion.outputs.NuGetVersion }}"
6249
echo "Assembly Version: ${{ steps.gitversion.outputs.AssemblySemVer }}"
6350
echo "File Version: ${{ steps.gitversion.outputs.AssemblySemFileVer }}"
64-
echo "Informational Version: ${{ steps.gitversion.outputs.InformationalVersion }}"
65-
66-
- name: Setup .NET ${{ matrix.dotnet }}
67-
uses: actions/setup-dotnet@v4
68-
with:
69-
dotnet-version: ${{ matrix.dotnet }}
70-
env:
71-
GitVersion_SemVer: ${{ steps.gitversion.outputs.SemVer }}
72-
GitVersion_AssemblySemVer: ${{ steps.gitversion.outputs.AssemblySemVer }}
73-
GitVersion_AssemblySemFileVer: ${{ steps.gitversion.outputs.AssemblySemFileVer }}
74-
GitVersion_InformationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }}
75-
GitVersion_NuGetVersion: ${{ steps.gitversion.outputs.NuGetVersion }}
76-
77-
- name: Restore dependencies
78-
run: dotnet restore -p:TargetFramework=${{ matrix.dotnet-framework }}
79-
80-
- name: Build
81-
run: dotnet build --no-restore -c Release -f ${{ matrix.dotnet-framework }}
82-
83-
- name: Test
84-
run: dotnet test --no-build --verbosity normal -c Release -f ${{ matrix.dotnet-framework }}
51+
echo "Informational Version: ${{ steps.gitversion.outputs.InformationalVersion }}}"
52+
run: dotnet test --no-build --verbosity normal -c Release -f ${{ matrix.dotnet-framework }}
8553
8654
summary:
87-
needs: build
55+
needs: [calculate-version, build]
8856
runs-on: ubuntu-latest
8957
if: always()
9058
steps:
@@ -97,6 +65,8 @@ jobs:
9765
echo "| PR Number | #${{ github.event.number }} |" >> $GITHUB_STEP_SUMMARY
9866
echo "| Source Branch | \`${{ github.head_ref }}\` |" >> $GITHUB_STEP_SUMMARY
9967
echo "| Target Branch | \`${{ github.base_ref }}\` |" >> $GITHUB_STEP_SUMMARY
68+
echo "| Version | \`${{ needs.calculate-version.outputs.version }}\` |" >> $GITHUB_STEP_SUMMARY
69+
echo "| NuGet Version | \`${{ needs.calculate-version.outputs.nuget-version }}\` |" >> $GITHUB_STEP_SUMMARY
10070
echo "| Build Status | ${{ needs.build.result == 'success' && '✅ Success' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
10171
echo "| Coverage | ${{ needs.build.result == 'success' && '📊 Collected' || '❌ Not Available' }} |" >> $GITHUB_STEP_SUMMARY
10272
echo "" >> $GITHUB_STEP_SUMMARY
@@ -106,6 +76,7 @@ jobs:
10676
echo "" >> $GITHUB_STEP_SUMMARY
10777
echo "📋 **Test Execution Notes**:" >> $GITHUB_STEP_SUMMARY
10878
echo "- **Ubuntu**: All tests executed" >> $GITHUB_STEP_SUMMARY
79+
echo "- **Windows**: All tests executed" >> $GITHUB_STEP_SUMMARY
10980
else
11081
echo "❌ **Build Failed**: Please check the build logs for more details." >> $GITHUB_STEP_SUMMARY
11182
fi

0 commit comments

Comments
 (0)