Skip to content

Commit 3e754fe

Browse files
committed
fix(release):修复Python wheels上传逻辑
- 替换actions/upload-release-asset为自定义curl上传脚本 - 使用GitHub API动态获取release上传URL - 支持批量上传多个wheel文件 - 添加wheel文件存在性检查 - 优化错误处理和日志输出 - 保持与原有asset上传步骤的兼容性
1 parent 0fcf2f1 commit 3e754fe

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,25 @@ jobs:
9595
fi
9696
9797
- name: Upload Python Wheels
98-
uses: actions/upload-release-asset@v1
99-
env:
100-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101-
with:
102-
upload_url: ${{ needs.create-release.outputs.upload_url }}
103-
asset_path: ${{ github.workspace }}/target/wheels/*.whl
104-
asset_name: image_to_console_python-${{ matrix.target }}.whl
105-
asset_content_type: application/octet-stream
98+
shell: bash
99+
run: |
100+
shopt -s nullglob
101+
wheel_files=(${{ github.workspace }}/target/wheels/*.whl)
102+
if [ ${#wheel_files[@]} -gt 0 ]; then
103+
for wheel in "${wheel_files[@]}"; do
104+
echo "Uploading wheel: $wheel"
105+
upload_url=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
106+
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }}" \
107+
| jq -r '.upload_url' | sed 's/{?name,label}//')
108+
curl -sS -X POST \
109+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
110+
-H "Content-Type: application/octet-stream" \
111+
--data-binary "@$wheel" \
112+
"${upload_url}?name=$(basename "$wheel")"
113+
done
114+
else
115+
echo "No wheel files found"
116+
fi
106117
107118
- name: Upload Release Asset
108119
uses: actions/upload-release-asset@v1

0 commit comments

Comments
 (0)