diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31afe8b..c5efd12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -144,32 +144,16 @@ jobs: upload_asset() { local file="$1" - local filename file_size local_hash assets matching_id asset_id asset_url comparison_file remote_hash response_file http_code + local filename file_size assets matching_id asset_id response_file http_code filename=$(basename "$file") file_size=$(wc -c < "$file" | tr -d ' ') - local_hash=$(sha256sum "$file" | awk '{print $1}') assets=$(release_json) - matching_id="" - while IFS=$'\t' read -r asset_id asset_url; do - [ -n "$asset_id" ] || continue - comparison_file=$(mktemp) - if curl -fsSL --connect-timeout 10 --max-time 900 --retry 2 \ - -H "Authorization: token ${GITEA_TOKEN}" \ - "$asset_url" -o "$comparison_file"; then - remote_hash=$(sha256sum "$comparison_file" | awk '{print $1}') - if [ "$remote_hash" = "$local_hash" ]; then - matching_id="$asset_id" - rm -f "$comparison_file" - break - fi - fi - rm -f "$comparison_file" - done < <(echo "$assets" | jq -r --arg name "$filename" \ - '.assets[] | select(.name == $name) | [.id, .browser_download_url] | @tsv') + matching_id=$(echo "$assets" | jq -r --arg name "$filename" --argjson size "$file_size" \ + '[.assets[] | select(.name == $name and .size == $size) | .id][0] // empty') if [ -n "$matching_id" ]; then - echo " [keep] ${filename} already exists with the expected SHA-256" + echo " [keep] ${filename} already exists with the expected size" while IFS= read -r asset_id; do [ -n "$asset_id" ] || continue if [ "$asset_id" != "$matching_id" ]; then