Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3241838511 |
43
action.yml
43
action.yml
@@ -5,7 +5,7 @@ inputs:
|
|||||||
description: 'Gitea Token'
|
description: 'Gitea Token'
|
||||||
required: true
|
required: true
|
||||||
files:
|
files:
|
||||||
description: 'Path to the file to upload'
|
description: 'File path(s) to upload: glob (e.g. dist/*.whl) or whitespace-separated paths/patterns'
|
||||||
required: true
|
required: true
|
||||||
tag:
|
tag:
|
||||||
description: 'Tag name'
|
description: 'Tag name'
|
||||||
@@ -19,9 +19,12 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ inputs.token }}
|
GITEA_TOKEN: ${{ inputs.token }}
|
||||||
FILE_PATH: ${{ inputs.files }}
|
FILES_SPEC: ${{ inputs.files }}
|
||||||
TAG_NAME: ${{ inputs.tag }}
|
TAG_NAME: ${{ inputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
API_URL="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases"
|
API_URL="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases"
|
||||||
|
|
||||||
# 1. Создаем релиз
|
# 1. Создаем релиз
|
||||||
@@ -43,16 +46,32 @@ runs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Загружаем файл
|
# 3. Собираем список файлов (glob и несколько паттернов через пробел)
|
||||||
UPLOAD_STATUS=$(curl -s -o upload_resp.json -w "%{http_code}" -X 'POST' \
|
UPLOAD_FILES=()
|
||||||
"$API_URL/$RELEASE_ID/assets" \
|
for arg in $FILES_SPEC; do
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
for f in $arg; do
|
||||||
-H "Content-Type: multipart/form-data" \
|
[ -f "$f" ] && UPLOAD_FILES+=("$f")
|
||||||
-F "attachment=@$FILE_PATH")
|
done
|
||||||
|
done
|
||||||
|
readarray -t UPLOAD_FILES < <(printf '%s\n' "${UPLOAD_FILES[@]}" | sort -u)
|
||||||
|
|
||||||
if [ "$UPLOAD_STATUS" != "201" ]; then
|
if [ ${#UPLOAD_FILES[@]} -eq 0 ]; then
|
||||||
echo "Upload failed with status $UPLOAD_STATUS"
|
echo "Error: No files matched: $FILES_SPEC"
|
||||||
cat upload_resp.json
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Successfully uploaded $FILE_PATH to release $TAG_NAME"
|
|
||||||
|
# 4. Загружаем каждый файл
|
||||||
|
for asset in "${UPLOAD_FILES[@]}"; do
|
||||||
|
UPLOAD_STATUS=$(curl -s -o upload_resp.json -w "%{http_code}" -X 'POST' \
|
||||||
|
"$API_URL/$RELEASE_ID/assets" \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-F "attachment=@${asset}")
|
||||||
|
|
||||||
|
if [ "$UPLOAD_STATUS" != "201" ]; then
|
||||||
|
echo "Upload failed for $asset with status $UPLOAD_STATUS"
|
||||||
|
cat upload_resp.json
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Successfully uploaded $asset to release $TAG_NAME"
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user