Skip to content

Commit ab6cfc8

Browse files
csharpfritzCopilot
andcommitted
fix: disable NBGV in release workflow and normalize SemVer version
NBGV was overriding the explicit -p:Version flag from the tag, causing nupkg to have wrong version numbers. This fix: - Adds -p:NerdbankGitVersioningEnabled=false to build/pack steps - Normalizes 2-part versions to 3-part SemVer (e.g., 0.18 0.18.0) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c0a2981 commit ab6cfc8

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ jobs:
2626
run: |
2727
VERSION="${{ github.event.release.tag_name }}"
2828
VERSION="${VERSION#v}"
29+
# Ensure version has at least 3 parts for SemVer (e.g., 0.18 → 0.18.0)
30+
if [[ "$VERSION" != *.*.* ]]; then
31+
VERSION="$VERSION.0"
32+
fi
2933
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
3034
echo "Extracted version: $VERSION"
3135
@@ -41,13 +45,13 @@ jobs:
4145
dotnet restore samples/AfterBlazorServerSide/AfterBlazorServerSide.csproj
4246
4347
- name: Build library
44-
run: dotnet build src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-restore
48+
run: dotnet build src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-restore -p:NerdbankGitVersioningEnabled=false -p:Version=${{ env.VERSION }}
4549

4650
- name: Build test project
47-
run: dotnet build src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj --configuration Release --no-restore
51+
run: dotnet build src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj --configuration Release --no-restore -p:NerdbankGitVersioningEnabled=false -p:Version=${{ env.VERSION }}
4852

4953
- name: Build server-side sample
50-
run: dotnet build samples/AfterBlazorServerSide/AfterBlazorServerSide.csproj --configuration Release --no-restore
54+
run: dotnet build samples/AfterBlazorServerSide/AfterBlazorServerSide.csproj --configuration Release --no-restore -p:NerdbankGitVersioningEnabled=false -p:Version=${{ env.VERSION }}
5155

5256
- name: Run tests
5357
run: dotnet test src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --results-directory src/BlazorWebFormsComponents.Test/TestResults
@@ -85,6 +89,9 @@ jobs:
8589
run: |
8690
VERSION="${{ github.event.release.tag_name }}"
8791
VERSION="${VERSION#v}"
92+
if [[ "$VERSION" != *.*.* ]]; then
93+
VERSION="$VERSION.0"
94+
fi
8895
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
8996
echo "Extracted version: $VERSION"
9097
@@ -97,15 +104,15 @@ jobs:
97104
run: dotnet restore src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj
98105

99106
- name: Build
100-
run: dotnet build src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-restore -p:Version=${{ env.VERSION }}
107+
run: dotnet build src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-restore -p:NerdbankGitVersioningEnabled=false -p:Version=${{ env.VERSION }}
101108

102109
- name: Run tests
103110
run: |
104111
dotnet restore src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj
105112
dotnet test src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj --configuration Release --verbosity normal
106113
107114
- name: Pack
108-
run: dotnet pack src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-build --output ./nupkg -p:PackageVersion=${{ env.VERSION }} -p:Version=${{ env.VERSION }}
115+
run: dotnet pack src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-build --output ./nupkg -p:NerdbankGitVersioningEnabled=false -p:PackageVersion=${{ env.VERSION }} -p:Version=${{ env.VERSION }}
109116

110117
- name: Push to GitHub Packages
111118
run: dotnet nuget push ./nupkg/*.nupkg --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
@@ -144,6 +151,9 @@ jobs:
144151
run: |
145152
VERSION="${{ github.event.release.tag_name }}"
146153
VERSION="${VERSION#v}"
154+
if [[ "$VERSION" != *.*.* ]]; then
155+
VERSION="$VERSION.0"
156+
fi
147157
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
148158
echo "Extracted version: $VERSION"
149159
@@ -231,6 +241,9 @@ jobs:
231241
run: |
232242
VERSION="${{ github.event.release.tag_name }}"
233243
VERSION="${VERSION#v}"
244+
if [[ "$VERSION" != *.*.* ]]; then
245+
VERSION="$VERSION.0"
246+
fi
234247
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
235248
echo "Extracted version: $VERSION"
236249

0 commit comments

Comments
 (0)