From db5e9a9ce4eecfc13a07d614805b2da6a9f87062 Mon Sep 17 00:00:00 2001 From: cuongph87 <152460338+cuongph87@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:27:39 +0700 Subject: [PATCH] Add ability to publish pre-release Nuget packages (#34) --- .github/workflows/publish_nuget.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_nuget.yml b/.github/workflows/publish_nuget.yml index e5fba2d7..d8283323 100644 --- a/.github/workflows/publish_nuget.yml +++ b/.github/workflows/publish_nuget.yml @@ -17,7 +17,25 @@ jobs: - uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v4 - - run: dotnet pack --configuration Release --output ${{env.NuGetDirectory}} -p:PackageVersion=${{github.event.release.tag_name}} + - name: Set version + id: set_version + shell: pwsh + run: | + echo "$version" + $version = "${{github.event.release.tag_name}}" + $isPrerelease = "${{github.event.release.prerelease}}" -eq "true" + $hasPrereleaseSuffix = $version -match "-\w+" + if ($isPrerelease -and -not $hasPrereleaseSuffix) { + Write-Error "Pre-release tag must contain a suffix (e.g., -alpha, -beta, -rc). Found: $version" + exit 1 + } + + if (-not $isPrerelease -and $hasPrereleaseSuffix) { + Write-Error "Regular release tag must not contain a pre-release suffix. Found: $version" + exit 1 + } + echo "VERSION=$version" >> $env:GITHUB_ENV + - run: dotnet pack --configuration Release --output ${{env.NuGetDirectory}} -p:PackageVersion=${{env.VERSION}} - uses: actions/upload-artifact@v3 with: name: nuget