From 5d747faee105c5a714e36dfbf1eacaababb66d58 Mon Sep 17 00:00:00 2001 From: spdis Date: Wed, 26 Nov 2025 22:07:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E4=B8=80=E4=B8=8Bym?= =?UTF-8?q?l=E8=BF=9B=E8=A1=8C=E6=9E=84=E5=BB=BA=E5=92=8C=E5=8F=91?= =?UTF-8?q?=E5=B8=83[ci][0.2.3]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 9cb5817..46add65 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -79,30 +79,13 @@ jobs: ART=$(cat "$GITHUB_WORKSPACE/.artifact_name") BASE="${ALIST_URL%/}" LOGIN_RESP=$(curl -sS -X POST "$BASE/api/auth/login" -H "Content-Type: application/json" -d "{\"username\":\"$ALIST_USER\",\"password\":\"$ALIST_PASSWORD\"}") - export LOGIN_RESP - TOKEN=$(python3 - << 'PY' -import os, json -s=os.environ.get('LOGIN_RESP','') -try: - j=json.loads(s) - d=j.get('data') or {} - print(d.get('token') or d.get('auth') or d.get('Authorization') or '') -except Exception: - print('') -PY - ) - if [ -n "$TOKEN" ]; then - curl -sS -X POST "$BASE/api/fs/mkdir" -H "Authorization: $TOKEN" -H "Content-Type: application/json" -d "{\"path\":\"/ci\"}" >/dev/null 2>&1 || true - UPLOAD_STATUS=$(curl -sS -w "%{http_code}" -o /dev/null -X PUT "$BASE/api/fs/form" -H "Authorization: $TOKEN" -F "path=/ci" -F "file=@$GITHUB_WORKSPACE/$ART;type=application/x-tar") - if [ "$UPLOAD_STATUS" -ge 400 ]; then - UPLOAD_STATUS=$(curl -sS -w "%{http_code}" -o /dev/null -X PUT "$BASE/api/fs/form" -H "Authorization: Bearer $TOKEN" -F "path=/ci" -F "file=@$GITHUB_WORKSPACE/$ART;type=application/x-tar") - fi - else - UPLOAD_STATUS=999 - fi + TOKEN=$(echo "$LOGIN_RESP" | sed -n 's/.*"token":"\([^"]*\)".*/\1/p') + if [ -z "$TOKEN" ]; then TOKEN=$(echo "$LOGIN_RESP" | sed -n 's/.*"auth":"\([^"]*\)".*/\1/p'); fi + if [ -z "$TOKEN" ]; then exit 1; fi + curl -sS -X POST "$BASE/api/fs/mkdir" -H "Authorization: $TOKEN" -H "Content-Type: application/json" -d "{\"path\":\"/ci\"}" >/dev/null 2>&1 || true + UPLOAD_STATUS=$(curl -sS -w "%{http_code}" -o /dev/null -X PUT "$BASE/api/fs/form" -H "Authorization: $TOKEN" -F "path=/ci" -F "file=@$GITHUB_WORKSPACE/$ART;type=application/x-tar") if [ "$UPLOAD_STATUS" -ge 400 ]; then - curl -s -u "$ALIST_USER:$ALIST_PASSWORD" -X MKCOL "$BASE/dav/ci" || true - UPLOAD_STATUS=$(curl -sS -w "%{http_code}" -o /dev/null -u "$ALIST_USER:$ALIST_PASSWORD" -T "$GITHUB_WORKSPACE/$ART" "$BASE/dav/ci/$ART") + UPLOAD_STATUS=$(curl -sS -w "%{http_code}" -o /dev/null -X PUT "$BASE/api/fs/form" -H "Authorization: Bearer $TOKEN" -F "path=/ci" -F "file=@$GITHUB_WORKSPACE/$ART;type=application/x-tar") fi test "$UPLOAD_STATUS" -lt 400 - name: Create release with download link