From 5cf3bff4cf7832f4f98ade3216c51936f1d679aa Mon Sep 17 00:00:00 2001 From: GwWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:39:37 +0800 Subject: [PATCH] =?UTF-8?q?chore(ci):=20=E6=B7=BB=E5=8A=A0=20NuGet=20?= =?UTF-8?q?=E5=8C=85=E8=B0=83=E8=AF=95=E4=BF=A1=E6=81=AF=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=8F=91=E5=B8=83=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加调试步骤以显示包信息和登录输出长度 - 检查 nuspec 文件中的 id 和 version 字段 - 验证 NuGet API 密钥的输出长度而不打印密钥内容 - 移除创建 GitHub Release 及上传 .nupkg 资产的相关步骤 - 简化发布流程,仅保留必要的 NuGet 推送操作 --- .github/workflows/publish.yml | 47 ++++++++++++++++------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f68c55d..80092f2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -77,6 +77,27 @@ jobs: # 推荐把用户名放到仓库 Secret(不是邮箱),例如 ${{ secrets.NUGET_USER }} # 也可以直接写用户名(不推荐),但通常使用 secret 更安全 user: ${{ secrets.NUGET_USER }} + - name: Debug NuGet/login outputs (no secret printed) + run: | + echo "---- Debug: show package info and login output length ----" + ls -la ./packages || true + PKG=$(find ./packages -name "*.nupkg" | head -n1) + if [ -z "$PKG" ]; then + echo "No .nupkg found" + exit 1 + fi + echo "Found package: $PKG" + echo "nuspec :" + unzip -p "$PKG" *.nuspec 2>/dev/null | sed -n 's:.*\(.*\).*:\1:p' || true + echo "nuspec :" + unzip -p "$PKG" *.nuspec 2>/dev/null | sed -n 's:.*\(.*\).*:\1:p' || true + + # Check NuGet/login output length (do NOT print the key) + echo -n "Length of steps.login.outputs.NUGET_API_KEY: " + echo -n "${{ steps.login.outputs.NUGET_API_KEY }}" | wc -c + echo + # Also check whether the login step reported any error (GitHub Actions will show step logs) + echo "---- end debug ----" - name: NuGet push (using short-lived API key from NuGet/login) run: | @@ -91,29 +112,3 @@ jobs: --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \ --source https://api.nuget.org/v3/index.json \ --skip-duplicate - # 如果你希望在没有 NuGet/login outputs 的情况下也能失败得更清楚,可以在这里检查输出长度 - - # ----------------------- - # Create GitHub Release and upload .nupkg as asset - # ----------------------- - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref_name }} - release_name: "Release ${{ github.ref_name }}" - body: "Release created by CI for tag ${{ github.ref_name }} (package version ${{ steps.get_version.outputs.version }})" - draft: false - prerelease: false - - - name: Upload .nupkg to Release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ steps.get_version.outputs.package_file }} - asset_name: ${{ steps.get_version.outputs.package_basename }} - asset_content_type: application/octet-stream