diff --git a/lib b/lib index 64fae75..acf0316 100644 --- a/lib +++ b/lib @@ -13,6 +13,13 @@ function create-release(){ exit fi + if [[ $1 == 'latest' ]]; then + echo "Deleting old latest release" + RELEASE_LIST=$(curl -X GET -Url https://gitea.kdiva.ru/api/v1/repos/modules/sc-items/releases) + LATEST_RELEASE_ID=(jq -r '.[] | select(.tag_name=="latest") | .id' <<< $RELEASE_LIST) + delete-release $LATEST_RELEASE_ID + fi + RESPONSE=$(curl \ -X 'POST' \ -Url "https://gitea.kdiva.ru/api/v1/repos/${DRONE_REPO}/releases" \ @@ -40,6 +47,12 @@ function upload-attachments(){ -F "attachment=@$1" } +function delete-release(){ + curl \ + -X 'DELETE' \ + -Url "https://gitea.kdiva.ru/api/v1/repos/${DRONE_REPO}/releases/${1}" +} + function vars() { echo "DRONE_SEMVER $DRONE_SEMVER" echo "DRONE_REPO_LINK $DRONE_REPO_LINK"