fix: CI 用 node 替代 jq 解析 JSON
Build and Release auth-rt / release (push) Failing after 51s
Details
Build and Release auth-rt / release (push) Failing after 51s
Details
node:20-bookworm 没有 jq,改用 node -e 解析 API 响应。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9fd284e556
commit
48a03f3376
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue