From b675d07d2ef321afbc02f0979cfb731adfe74250 Mon Sep 17 00:00:00 2001 From: linmeideli <2558527373@qq.com> Date: Fri, 25 Sep 2026 18:46:26 +0800 Subject: [PATCH] ci: package version comes from project file only --- .github/workflows/nuget.yml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 10dab1e..d449100 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -24,28 +24,21 @@ jobs: with: dotnet-version: 8.0.x - # Version scheme mirrors build.cake/nightly: -ci.. - # The floor (max already-published ci.N + 1) keeps versions monotonic. - - name: Resolve version + # Package version = in src/Empostor.Api/Empostor.Api.csproj. + # Bump it manually to release a new version; the -dev suffix is cleared + # so the package is published as a stable version. If the version + # already exists on nuget.org, push is skipped by --skip-duplicate. + - name: Read project version id: ver run: | set -euo pipefail PROJ=src/Empostor.Api/Empostor.Api.csproj BASE=$(sed -n 's/.*\([^<]*\)<\/VersionPrefix>.*/\1/p' "$PROJ" | head -1) - CI_RUN=$(curl -sf -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/actions/workflows/ci.yml/runs?per_page=1" \ - | jq -r '.workflow_runs[0].run_number') - N=$(( CI_RUN + 500 )) - MAXN=$(curl -sf "https://api.nuget.org/v3-flatcontainer/empostor.api/index.json" \ - | jq -r '.versions[]' | grep -oE 'ci\.[0-9]+$' | grep -oE '[0-9]+$' | sort -n | tail -1 || true) - MAXN=${MAXN:-0} - if [ "$N" -le "$MAXN" ]; then N=$((MAXN + 1)); fi - echo "suffix=ci.${N}" >> "$GITHUB_OUTPUT" - echo "version=${BASE}-ci.${N}" >> "$GITHUB_OUTPUT" - echo "Publishing version: ${BASE}-ci.${N}" + echo "version=${BASE}" >> "$GITHUB_OUTPUT" + echo "Publishing version: ${BASE}" - name: Pack - run: dotnet pack src/Empostor.Api/Empostor.Api.csproj -c Release -p:VersionSuffix=${{ steps.ver.outputs.suffix }} -p:GeneratePackageOnBuild=false -o artifacts --nologo + run: dotnet pack src/Empostor.Api/Empostor.Api.csproj -c Release -p:VersionSuffix= -p:GeneratePackageOnBuild=false -o artifacts --nologo # Trusted publishing: exchanges the GitHub OIDC token for a short-lived # nuget.org API key tied to the policy (no secret needed).