feat(gitea,release): use multisort to bypass gitea created_at bug

This commit is contained in:
wpetit 2023-05-10 15:47:40 +02:00
parent abe8dd5f1b
commit 6ebceae3b9
1 changed files with 4 additions and 4 deletions

View File

@ -137,8 +137,7 @@ function json_set {
} }
function upload_release_attachments { function upload_release_attachments {
local release="$1" local release_id="$1"
local release_id=$(echo "$release" | jq -r .id)
if [ -z "$GITEA_RELEASE_ATTACHMENTS" ]; then if [ -z "$GITEA_RELEASE_ATTACHMENTS" ]; then
set +e set +e
@ -175,7 +174,7 @@ function clean_prereleases {
fi fi
local releases=$(gitea_api "/repos/$GITEA_RELEASE_ORG/$GITEA_RELEASE_PROJECT/releases") local releases=$(gitea_api "/repos/$GITEA_RELEASE_ORG/$GITEA_RELEASE_PROJECT/releases")
local to_delete=$(echo "$releases" | jq -r --arg index "$GITEA_RELEASE_CLEANUP_KEPT_PRERELEASES" '[.[] | select(.prerelease == true)] | sort_by(.created_at) | reverse | .[$index | tonumber:] | .[].id') local to_delete=$(echo "$releases" | jq -r --arg index "$GITEA_RELEASE_CLEANUP_KEPT_PRERELEASES" '[.[] | select(.prerelease == true)] | sort_by(.created_at, .id) | reverse | .[$index | tonumber:] | .[].id')
echo $to_delete echo $to_delete
@ -194,8 +193,9 @@ function main {
retrieve_commitish_target retrieve_commitish_target
retrieve_version retrieve_version
local release=$(create_release) local release=$(create_release)
local release_id=$(echo "$release" | jq -r .id)
sleep 1 # Wait for release creation sleep 1 # Wait for release creation
upload_release_attachments "$release" upload_release_attachments "$release_id"
clean_prereleases clean_prereleases
} }