ci: release 已存在时复用(避免同名创建失败)

This commit is contained in:
Reasonix committed 2026-08-14 17:01:44 +08:00
1 parent 5d41af033f
commit fd41de3bc5
1 file changed
+17 -8
+17 -8
View File
@@ -35,18 +35,27 @@ jobs:
cp dsh.ico README.md install.cmd uninstall.vbs register-uninstall.ps1 pkg/ cp dsh.ico README.md install.cmd uninstall.vbs register-uninstall.ps1 pkg/
cd pkg && python ../scripts/build-online.py ../dsh-desktop-online.zip cd pkg && python ../scripts/build-online.py ../dsh-desktop-online.zip
- name: Create release - name: Create or reuse release
id: release id: release
shell: bash shell: bash
run: | run: |
VER="${{ steps.version.outputs.latest }}" VER="${{ steps.version.outputs.latest }}"
BODY="Auto-built by Gitea Actions. dsh version: ${VER}. Online install package (run install.cmd, requires network)." TAG="v${VER}"
curl -s -X POST \ API="https://git.vanusys.com/api/v1/repos/${{ github.repository }}"
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$API/releases/tags/${TAG}" -o exist.json
-H "Content-Type: application/json" \ EXIST=$(python -c "import json; d=json.load(open('exist.json')); print(d.get('id',''))")
-d "{\"tag_name\":\"v${VER}\",\"name\":\"DeepSeek Harness v${VER}\",\"body\":\"${BODY}\",\"draft\":false,\"prerelease\":false}" \ if [ -n "$EXIST" ]; then
"https://git.vanusys.com/api/v1/repos/${{ github.repository }}/releases" > release.json echo "$EXIST" > release_id.txt
python -c "import json; print(json.load(open('release.json'))['id'])" > release_id.txt echo "reuse existing release $EXIST"
else
BODY="Auto-built by Gitea Actions. dsh version: ${VER}. Online install package (run install.cmd, requires network)."
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"DeepSeek Harness ${TAG}\",\"body\":\"${BODY}\",\"draft\":false,\"prerelease\":false}" \
"$API/releases" > release.json
python -c "import json; print(json.load(open('release.json'))['id'])" > release_id.txt
fi
echo "release_id=$(cat release_id.txt)" >> "$GITHUB_OUTPUT" echo "release_id=$(cat release_id.txt)" >> "$GITHUB_OUTPUT"
- name: Upload asset - name: Upload asset