delete any existing packages
This commit is contained in:
parent
b4e8d88b7a
commit
20adfc8417
16
upload.sh
16
upload.sh
@ -11,14 +11,12 @@ then
|
||||
fi
|
||||
|
||||
# other optional parameters
|
||||
|
||||
BASE_URL=${PLUGIN_URL:-https://git.burble.dn42/api/packages}
|
||||
USER=${PLUGIN_USER:-burble}
|
||||
OWNER=${PLUGIN_OWNER:-burble}
|
||||
FILENAME=${PLUGIN_FILENAME:-$PLUGIN_ARTIFACT}
|
||||
|
||||
# version or token could be a filename
|
||||
|
||||
function maybe_from_file
|
||||
{
|
||||
local var="$1"
|
||||
@ -34,12 +32,22 @@ VERSION=$(maybe_from_file "$PLUGIN_VERSION")
|
||||
TOKEN=$(maybe_from_file "$PLUGIN_TOKEN")
|
||||
|
||||
##########################################################################
|
||||
# finally do the curl thing to upload the artifact
|
||||
|
||||
# package URL
|
||||
url=$(printf '%s/%s/generic/%s/%s/%s' \
|
||||
"$BASE_URL" "$OWNER" "$PLUGIN_PACKAGE" \
|
||||
"$VERSION" "$PLUGIN_ARTIFACT")
|
||||
|
||||
|
||||
# check if there is already an existing package
|
||||
status=$(curl --user "${USER}:${TOKEN}" -s -o /dev/null \
|
||||
-w "%{http_code}" -X 'GET' "$url")
|
||||
if [ "$status" -eq 200 ]
|
||||
then
|
||||
echo "Deleting existing package ..."
|
||||
curl --user "${USER}:${TOKEN}" -X 'DELETE' "$url"
|
||||
fi
|
||||
|
||||
# finally, actually upload the artifact
|
||||
curl --user "${USER}:${TOKEN}" --upload-file "$FILENAME" "$url"
|
||||
|
||||
##########################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user