From cb17d9ecddff67618bf21762ef773f2de71bc762 Mon Sep 17 00:00:00 2001 From: GwWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Fri, 2 Jan 2026 20:31:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ci):=20=E4=BC=98=E5=8C=96=20GitHub=20A?= =?UTF-8?q?ctions=20=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 softprops/action-gh-release 替换 actions/create-release - 简化发布创建和资产上传流程 - 移除手动 curl 上传 .nupkg 文件的复杂脚本 - 直接通过 files 参数支持通配符上传所有包文件 - 保持发布描述和版本信息功能 - 减少工作流步骤数量,提高可维护性 --- .github/workflows/publish.yml | 40 ++++++----------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6743ff7..e625aee 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -129,42 +129,14 @@ jobs: # 创建 GitHub Release # 使用从包中提取的版本信息和当前标签创建发布 # 发布包含描述信息和版本详情 - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create GitHub Release and Upload Assets + uses: softprops/action-gh-release@v2 with: - tag_name: ${{ github.ref_name }} - release_name: "Release ${{ github.ref_name }}" + 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 - - # 使用 curl 将所有 .nupkg 文件上传到 GitHub Release - # 从 create-release 步骤获取上传 URL 并移除模板部分 - # 每个包文件作为资产上传到发布中 - - name: Upload all .nupkg to Release (curl) + # 核心优化:直接支持通配符 + files: ./packages/*.nupkg env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - UPLOAD_URL_TEMPLATE: ${{ steps.create_release.outputs.upload_url }} - run: | - set -e - # upload_url from create-release is like: https://uploads.github.com/repos/OWNER/REPO/releases/ID/assets{?name,label} - # strip template part "{?name,label}" - UPLOAD_URL="${UPLOAD_URL_TEMPLATE%\{*}" - echo "Upload base URL: $UPLOAD_URL" - - for package_file in ./packages/*.nupkg; do - if [ -f "$package_file" ]; then - basename=$(basename "$package_file") - echo "Uploading $basename to release..." - curl --fail -sS -X POST \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "Content-Type: application/octet-stream" \ - --data-binary @"$package_file" \ - "$UPLOAD_URL?name=$basename" - echo "Uploaded $basename" - fi - done - + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file