From c6af6c51966b5ebe9c658ccb2b4fa757d484b4a7 Mon Sep 17 00:00:00 2001 From: Dexoron Date: Wed, 12 Aug 2026 20:25:36 +0800 Subject: [PATCH] fix release sync --- .github/workflows/ci.yml | 14 ++++++++- .github/workflows/release-mirror.yml | 47 +++++++++++++++++++++------- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f7bcea..01c1226 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,19 @@ on: - master - main - dev + paths: + - 'src/**' + - 'tests/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/ci.yml' pull_request: + paths: + - 'src/**' + - 'tests/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/ci.yml' env: CARGO_TERM_COLOR: always @@ -151,4 +163,4 @@ jobs: - name: sccache stats if: always() - run: sccache --show-stats || true + run: sccache --show-stats || true \ No newline at end of file diff --git a/.github/workflows/release-mirror.yml b/.github/workflows/release-mirror.yml index c487816..d1ceb29 100644 --- a/.github/workflows/release-mirror.yml +++ b/.github/workflows/release-mirror.yml @@ -150,18 +150,41 @@ jobs: uploaded=0; failed=0 for file in assets/*; do [ -f "$file" ] || continue - upload=$(curl -fsSL -X POST -H "PRIVATE-TOKEN: $GITVERSE_PAT" \ - -F "file=@$file" "https://gitverse.ru/api/v4/projects/${project}/uploads") - url=$(jq -r '.url // .file_path' <<< "$upload") name=$(basename "$file") - link=$(jq -n --arg name "$name" --arg url "$url" '{name:$name,url:$url}') - if curl -fsSL -X POST -H "PRIVATE-TOKEN: $GITVERSE_PAT" \ - -H 'Content-Type: application/json' --data "$link" \ - "https://gitverse.ru/api/v4/projects/${project}/releases/${TAG}/assets/links" >/dev/null 2>&1; then - uploaded=$((uploaded+1)) - else - echo "::warning::GitVerse: failed to attach asset $name" + + # Step 1: Upload file and capture response with HTTP code + upload_response=$(curl -sS -w "\n%{http_code}" -X POST -H "PRIVATE-TOKEN: $GITVERSE_PAT" \ + -F "file=@$file" "https://gitverse.ru/api/v4/projects/${project}/uploads") + http_code=$(echo "$upload_response" | tail -n1) + body=$(echo "$upload_response" | sed '$d') + + if [ "$http_code" != "201" ] && [ "$http_code" != "200" ]; then + echo "::warning::GitVerse: failed to upload $name (HTTP $http_code): $body" failed=$((failed+1)) + continue + fi + + # Extract file path from upload response + url=$(jq -r '.url // .file_path' <<< "$body" 2>/dev/null || echo "") + if [ -z "$url" ]; then + echo "::warning::GitVerse: failed to parse upload response for $name: $body" + failed=$((failed+1)) + continue + fi + + # Step 2: Create asset link in release + link=$(jq -n --arg name "$name" --arg url "$url" '{name:$name,url:$url}') + link_response=$(curl -sS -w "\n%{http_code}" -X POST -H "PRIVATE-TOKEN: $GITVERSE_PAT" \ + -H 'Content-Type: application/json' --data "$link" \ + "https://gitverse.ru/api/v4/projects/${project}/releases/${TAG}/assets/links") + link_http=$(echo "$link_response" | tail -n1) + link_body=$(echo "$link_response" | sed '$d') + + if [ "$link_http" != "201" ] && [ "$link_http" != "200" ]; then + echo "::warning::GitVerse: failed to attach asset $name (HTTP $link_http): $link_body" + failed=$((failed+1)) + else + uploaded=$((uploaded+1)) fi done echo "GitVerse: uploaded ${uploaded}, failed ${failed}" @@ -215,8 +238,8 @@ jobs: for file in assets/*; do [ -f "$file" ] || continue if curl -fsSL -X POST -H "Authorization: Bearer $SOURCECRAFT_PAT" \ - -F "name=$(basename "$file")" -F "file=@$file" \ - "${base}/releases/tag/${TAG}/attachments" >/dev/null 2>&1; then + -F "file=@$file" \ + "${base}/releases/tag/${TAG}/assets" >/dev/null 2>&1; then uploaded=$((uploaded+1)) else echo "::warning::SourceCraft: failed to attach asset $(basename "$file")"