This commit is contained in:
@@ -76,22 +76,18 @@ jobs:
|
|||||||
echo "$ART" > "$GITHUB_WORKSPACE/.artifact_name"
|
echo "$ART" > "$GITHUB_WORKSPACE/.artifact_name"
|
||||||
- name: Upload to Alist
|
- name: Upload to Alist
|
||||||
run: |
|
run: |
|
||||||
python3 - << 'PY'
|
ART=$(cat "$GITHUB_WORKSPACE/.artifact_name")
|
||||||
import os,requests,sys
|
BASE="${ALIST_URL%/}"
|
||||||
base=os.environ['ALIST_URL'].rstrip('/')
|
LOGIN_RESP=$(curl -sS -X POST "$BASE/api/auth/login" -H "Content-Type: application/json" -d "{\"username\":\"$ALIST_USER\",\"password\":\"$ALIST_PASSWORD\"}")
|
||||||
user=os.environ['ALIST_USER']
|
TOKEN=$(echo "$LOGIN_RESP" | sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
|
||||||
pwd=os.environ['ALIST_PASSWORD']
|
if [ -z "$TOKEN" ]; then TOKEN=$(echo "$LOGIN_RESP" | sed -n 's/.*"auth":"\([^"]*\)".*/\1/p'); fi
|
||||||
ws=os.environ['GITHUB_WORKSPACE']
|
if [ -z "$TOKEN" ]; then exit 1; fi
|
||||||
art=open(os.path.join(ws,'.artifact_name'),'r',encoding='utf-8').read().strip()
|
curl -sS -X POST "$BASE/api/fs/mkdir" -H "Authorization: $TOKEN" -H "Content-Type: application/json" -d "{\"path\":\"/ci\"}" >/dev/null 2>&1 || true
|
||||||
fp=os.path.join(ws,art)
|
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")
|
||||||
r=requests.post(base+'/api/auth/login',json={'username':user,'password':pwd})
|
if [ "$UPLOAD_STATUS" -ge 400 ]; then
|
||||||
tok=(r.json().get('data') or {}).get('token')
|
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")
|
||||||
if not tok: sys.exit(1)
|
fi
|
||||||
requests.post(base+'/api/fs/mkdir',json={'path':'/ci'},headers={'Authorization':tok})
|
test "$UPLOAD_STATUS" -lt 400
|
||||||
files={'file':(art,open(fp,'rb'),'application/x-tar')}
|
|
||||||
s=requests.put(base+'/api/fs/form',data={'path':'/ci'},files=files,headers={'Authorization':tok})
|
|
||||||
sys.exit(0 if s.status_code<400 else 1)
|
|
||||||
PY
|
|
||||||
- name: Create release with download link
|
- name: Create release with download link
|
||||||
if: env.GITEA_TOKEN != ''
|
if: env.GITEA_TOKEN != ''
|
||||||
run: |
|
run: |
|
||||||
@@ -99,6 +95,6 @@ jobs:
|
|||||||
BRANCH=${GITHUB_REF#refs/heads/}
|
BRANCH=${GITHUB_REF#refs/heads/}
|
||||||
TAG="$VERSION"
|
TAG="$VERSION"
|
||||||
NAME="$VERSION"
|
NAME="$VERSION"
|
||||||
DL="$ALIST_URL/ci/$ART"
|
DL="${ALIST_URL%/}/ci/$ART"
|
||||||
JSON=$(printf '{"tag_name":"%s","target_commitish":"%s","name":"%s","body":"%s"}' "$TAG" "$BRANCH" "$NAME" "$DL")
|
JSON=$(printf '{"tag_name":"%s","target_commitish":"%s","name":"%s","body":"%s"}' "$TAG" "$BRANCH" "$NAME" "$DL")
|
||||||
curl -sS -X POST "$GITEA_SERVER/api/v1/repos/$GITEA_REPO/releases" -H "Content-Type: application/json" -H "Authorization: token $GITEA_TOKEN" -d "$JSON"
|
curl -sS -X POST "$GITEA_SERVER/api/v1/repos/$GITEA_REPO/releases" -H "Content-Type: application/json" -H "Authorization: token $GITEA_TOKEN" -d "$JSON"
|
||||||
|
|||||||
Reference in New Issue
Block a user