From 48a03f337649956e09651a861c21230244e384a2 Mon Sep 17 00:00:00 2001 From: ywkj Date: Fri, 20 Mar 2026 21:21:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CI=20=E7=94=A8=20node=20=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=20jq=20=E8=A7=A3=E6=9E=90=20JSON?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit node:20-bookworm 没有 jq,改用 node -e 解析 API 响应。 Co-Authored-By: Claude Opus 4.6 --- .forgejo/workflows/release.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 07809a4..8261917 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -34,12 +34,14 @@ jobs: FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} API_URL: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} run: | + json_get() { node -e "process.stdout.write(String(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).$1 || ''))"; } + # Create release RELEASE_ID=$(curl -s -X POST "$API_URL/releases" \ -H "Authorization: token $FORGEJO_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"auth-rt $TAG\"}" \ - | jq -r '.id') + | json_get id) echo "Created release ID: $RELEASE_ID" @@ -55,12 +57,14 @@ jobs: # Maintain "latest" release LATEST_ID=$(curl -s "$API_URL/releases/tags/latest" \ - -H "Authorization: token $FORGEJO_TOKEN" | jq -r '.id // empty') + -H "Authorization: token $FORGEJO_TOKEN" | json_get id) if [ -n "$LATEST_ID" ]; then # Delete old assets - curl -s "$API_URL/releases/$LATEST_ID/assets" \ - -H "Authorization: token $FORGEJO_TOKEN" | jq -r '.[].id' | while read aid; do + ASSET_IDS=$(curl -s "$API_URL/releases/$LATEST_ID/assets" \ + -H "Authorization: token $FORGEJO_TOKEN" \ + | node -e "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).forEach(a=>console.log(a.id))") + for aid in $ASSET_IDS; do curl -s -X DELETE "$API_URL/releases/$LATEST_ID/assets/$aid" \ -H "Authorization: token $FORGEJO_TOKEN" done @@ -73,7 +77,7 @@ jobs: -H "Authorization: token $FORGEJO_TOKEN" \ -H "Content-Type: application/json" \ -d '{"tag_name":"latest","name":"latest","body":"auth-rt latest","prerelease":true}' \ - | jq -r '.id') + | json_get id) fi for f in auth-rt-*; do