Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix existing package check during release #10

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
name: nupkg

- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4

- name: Add nuget.org source
run: dotnet nuget add source --name NUGET https://www.nuget.org
Expand All @@ -69,9 +69,9 @@ jobs:
grep -oP '(?<=\.)[0-9]+\.[0-9]+\.[0-9]+((-[a-zA-Z]+)?(\.[0-9]+)*)*$' \
)
# get package id by truncating the version from the file name
_packageId="${_filenamewithoutext%%.$_version}"
_packageId="${_filenamewithoutext%%.$_packageVersion}"
# verify all packages have the same version
if [ $_releaseVersion != "" ] && [ $_packageVersion != $_releaseVersion ] ; then
if [[ $_releaseVersion != "" ]] && [[ $_packageVersion != $_releaseVersion ]]; then
# mulitple package versions detected
echo "Multiple package versions detected. Expected '${_releaseVersion}' but found '${_packageVersion}' for '${_packageId}'."; exit 1
else
Expand All @@ -82,9 +82,9 @@ jobs:
_packageUrl="https://api.nuget.org/v3/registration5-semver1/${_packageIdLower}/${_packageVersion}.json"
echo "Checking for existing package at ${_packageUrl}"
_statusCode=$(curl -s -o /dev/null -I -w '%{http_code}' "${_packageUrl}")
if [ $_statusCode == "200" ]; then
if [[ $_statusCode == "200" ]]; then
echo "The package ${_packageId} with version ${_packageVersion} already exists on nuget.org"; exit 1
elif [ $_statusCode == "404" ]; then
elif [[ $_statusCode == "404" ]]; then
echo "Confirmed package ${_packageId} with version ${_packageVersion} does not already exist on nuget.org"
else
echo "Unexpected status code ${_statusCode} received from nuget.org"; exit 1
Expand Down