diff options
Diffstat (limited to 'screwdriver/upload-rpm-to-cloudsmith.sh')
-rwxr-xr-x | screwdriver/upload-rpm-to-cloudsmith.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/screwdriver/upload-rpm-to-cloudsmith.sh b/screwdriver/upload-rpm-to-cloudsmith.sh new file mode 100755 index 00000000000..dd24185433b --- /dev/null +++ b/screwdriver/upload-rpm-to-cloudsmith.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +set -euo pipefail + +if (( $# < 1 )); then + echo "Usage: $0 <RPM file>" + exit 1 +fi + +if [[ -z $CLOUDSMITH_API_CREDS ]]; then + echo "Environment CLOUDSMITH_API_CREDS not set. Exiting." + exit 1 +fi + +RPM=$1 +OS_DISTRO=el +RELEASEVER=8 + +main() { + + FID=$(curl -sLf \ + --upload-file $RPM \ + -u "$CLOUDSMITH_API_CREDS" \ + -H "Content-Sha256: $(sha256sum $RPM | cut -f1 -d' ')" \ + https://upload.cloudsmith.io/vespa/vespa/$RPM | jq -re '.identifier') + + if [[ -n $FID ]]; then + curl -sLf -X POST -H "Content-Type: application/json" \ + -u "$CLOUDSMITH_API_CREDS" \ + -d "{\"package_file\": \"$FID\", \"distribution\": \"$OS_DISTRO/$RELEASEVER\"}" \ + https://api-prd.cloudsmith.io/v1/packages/vespa/vespa/upload/rpm/ + fi +} + +main "$@" |