Skip to content

Commit 220e601

Browse files
author
Martin Boje Carpentier
committed
2 parents d8acc12 + b582584 commit 220e601

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env:
1515
# Official NuGet Feed settings
1616
NUGET_FEED: https://api.nuget.org/v3/index.json
1717
NUGET_KEY: ${{ secrets.NUGET_KEY }}
18+
NUGET_VERSIONING_REGEX: "[0-9]+\\.[0-9]+\\.[0-9]+-[a-zA-Z]+"
1819

1920
jobs:
2021
deploy:
@@ -37,9 +38,14 @@ jobs:
3738
run: dotnet build src/${{ env.PROJECT_NAME }}.sln -c Release --no-restore
3839
- name: Create Release NuGet package
3940
run: |
40-
arrTag=(${GITHUB_REF//\// })
41-
VERSION="${arrTag[2]}"
42-
VERSION="${VERSION//v}"
43-
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.csproj
41+
$VERSION=${env:GITHUB_REF_NAME}
42+
if($VERSION[0] -eq "v"){
43+
$VERSION=$VERSION.substring(1)
44+
}
45+
46+
if(!($VERSION -match ${env:NUGET_VERSIONING_REGEX})) {
47+
throw "Release tag did not contain a valid NUGET version. TAG was : ${env:GITHUB_REF_NAME}"
48+
}
49+
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj
4450
- name: Push to Nuget
45-
run: dotnet nuget push nuget/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_KEY}} --skip-duplicate
51+
run: dotnet nuget push nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_KEY}} --skip-duplicate

0 commit comments

Comments
 (0)