This commit is contained in:
@@ -42,15 +42,72 @@ jobs:
|
||||
env:
|
||||
WINEDEBUG: '-all'
|
||||
|
||||
- name: Create Gitea Release & Upload
|
||||
uses: akkuman/gitea-release-action@v1
|
||||
env:
|
||||
NODE_OPTIONS: '--experimental-fetch'
|
||||
with:
|
||||
server_url: http://10.0.0.119:3000
|
||||
files: |-
|
||||
out/make/**/*.exe
|
||||
out/make/**/*.zip
|
||||
out/make/**/*.deb
|
||||
out/make/**/*.rpm
|
||||
token: ${{ gitea.token }}
|
||||
- name: Create Gitea Release
|
||||
run: |
|
||||
GITEA_URL="http://10.0.0.119:3000"
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
REPO="${GITHUB_REPOSITORY}"
|
||||
TOKEN="${{ gitea.token }}"
|
||||
|
||||
# Check if release exists, create if not
|
||||
RELEASE_ID=$(curl -sf \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/tags/${TAG}" \
|
||||
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
RELEASE_ID=$(curl -sf \
|
||||
-X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\"}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
||||
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
||||
fi
|
||||
|
||||
echo "Release ID: ${RELEASE_ID}"
|
||||
echo "RELEASE_ID=${RELEASE_ID}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Upload Release Assets
|
||||
run: |
|
||||
GITEA_URL="http://10.0.0.119:3000"
|
||||
REPO="${GITHUB_REPOSITORY}"
|
||||
TOKEN="${{ gitea.token }}"
|
||||
MAX_RETRIES=3
|
||||
|
||||
upload_file() {
|
||||
local file="$1"
|
||||
local name=$(basename "$file")
|
||||
local attempt=1
|
||||
|
||||
while [ $attempt -le $MAX_RETRIES ]; do
|
||||
echo "Uploading ${name} (attempt ${attempt}/${MAX_RETRIES})..."
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-F "attachment=@${file}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${name}")
|
||||
|
||||
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
|
||||
echo "✅ Uploaded ${name}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "⚠️ Upload failed (HTTP ${HTTP_CODE}), retrying in 5s..."
|
||||
sleep 5
|
||||
attempt=$((attempt + 1))
|
||||
done
|
||||
|
||||
echo "❌ Failed to upload ${name} after ${MAX_RETRIES} attempts"
|
||||
return 1
|
||||
}
|
||||
|
||||
FAILED=0
|
||||
for file in $(find out/make -type f \( -name "*.exe" -o -name "*.zip" -o -name "*.deb" -o -name "*.rpm" \)); do
|
||||
upload_file "$file" || FAILED=1
|
||||
done
|
||||
|
||||
if [ $FAILED -eq 1 ]; then
|
||||
echo "Some uploads failed"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user