aboutsummaryrefslogtreecommitdiffstats
path: root/screwdriver/upload-rpm-to-cloudsmith.sh
blob: 6cd50277b3d441c6d566e578f87fc58b52ead7ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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/open-source-rpms/$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/open-source-rpms/upload/rpm/
  fi
}

main "$@"