diff --git a/.github/workflows/ci-otapi3-nuget.yml b/.github/workflows/ci-otapi3-nuget.yml index 7834ccf01..eaba28b2e 100644 --- a/.github/workflows/ci-otapi3-nuget.yml +++ b/.github/workflows/ci-otapi3-nuget.yml @@ -1,12 +1,11 @@ -name: Deploy NuGet(OTAPI3) +name: Publish NuGet on: - push: - branches: [ nuget-release ] + release: + types: [published] jobs: - build: - + publish: runs-on: ubuntu-latest environment: release @@ -14,17 +13,28 @@ jobs: - uses: actions/checkout@v4 with: submodules: 'recursive' + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x + + - name: Check csproj version matches release tag + run: | + CSPROJ_VERSION=$(grep -oP '(?<=)[^<]+' TShockAPI/TShockAPI.csproj) + TAG_VERSION=${GITHUB_REF_NAME#v} + if [ "$CSPROJ_VERSION" != "$TAG_VERSION" ]; then + echo "::warning:: in TShockAPI.csproj is $CSPROJ_VERSION but the release tag is $TAG_VERSION. The NuGet package will use $TAG_VERSION. Consider updating the csproj to match." + fi + - name: Restore dependencies run: dotnet restore + - name: Build - run: dotnet build TShock.sln --configuration Release --no-restore + run: dotnet build TShock.sln --configuration Release --no-restore -p:PackageVersion=${GITHUB_REF_NAME#v} + - name: Test run: dotnet test --no-build --verbosity normal --configuration Release - # Publish to nuget - - name: Push TShockAPI - run: dotnet nuget push TShockAPI/bin/Release/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json + - name: Push to NuGet + run: dotnet nuget push TShockAPI/bin/Release/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 5a63117fe..9c5a98be0 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -16,7 +16,9 @@ location, which previously held the date and time. Also, be sure to release on github with the exact assembly version tag as below - so that the update manager works correctly (via the Github releases api and mimic) + so that the update manager works correctly (via the Github releases api and mimic). + Otherwise the Nuget package will have a version mismatch with the version here. + Prerelease upgrades should not update this version—only do so for the full release. --> 5.9.9 TShock for Terraria