|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +VERSION=${1:?"Missing version number argument (arg 1)"} |
| 6 | +NEXUS_USER=${2:?"Missing Nexus username argument (arg 2)"} |
| 7 | + |
| 8 | +read -r -s -p "Nexus Password: " NEXUS_PASSWORD |
| 9 | +echo "" |
| 10 | + |
| 11 | +# https://stackoverflow.com/questions/4632028/how-to-create-a-temporary-directory |
| 12 | +# Find the directory name of the script |
| 13 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 14 | + |
| 15 | +# the temp directory used, within $DIR |
| 16 | +WORK_DIR=$(mktemp -d -p "$DIR") |
| 17 | + |
| 18 | +# check if tmp dir was created |
| 19 | +if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then |
| 20 | + echo "Could not create temp dir" |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | + |
| 24 | +# deletes the temp directory |
| 25 | +function cleanup { |
| 26 | + rm -rf "$WORK_DIR" |
| 27 | +} |
| 28 | + |
| 29 | +# register the cleanup function to be called on the EXIT signal |
| 30 | +trap cleanup EXIT |
| 31 | + |
| 32 | +cd "$WORK_DIR" || exit |
| 33 | +src_file=phoenix-omid-$VERSION-src.tar.gz |
| 34 | + |
| 35 | +echo "Downloading Omid (this can take a while, it is intentionally downloading from a slow mirror that contains all old versions)" |
| 36 | +curl --fail -LOs "https://downloads.apache.org/phoenix/phoenix-omid-${VERSION}/${src_file}" |
| 37 | +curl --fail -LOs "https://downloads.apache.org/phoenix/phoenix-omid-$VERSION/$src_file.asc" |
| 38 | +curl --fail -LOs "https://downloads.apache.org/phoenix/phoenix-omid-$VERSION/$src_file.sha512" |
| 39 | + |
| 40 | + |
| 41 | +# It is probably redundant to check both the checksum and the signature but it's cheap and why not |
| 42 | +echo "Validating SHA512 Checksums" |
| 43 | +if ! (gpg --print-md SHA512 "$src_file" | diff - "$src_file.sha512"); then |
| 44 | + echo "ERROR: One of the SHA512 sums does not match" |
| 45 | + exit 1 |
| 46 | +fi |
| 47 | + |
| 48 | +echo "Validating signatures" |
| 49 | +echo '--> NOTE: Make sure you have downloaded and added the KEYS file (https://downloads.apache.org/phoenix/KEYS) to GPG: https://www.apache.org/info/verification.html' |
| 50 | +if ! (gpg --verify "$src_file.asc" "$src_file" 2> /dev/null); then |
| 51 | + echo "ERROR: One of the signatures could not be verified" |
| 52 | + exit 1 |
| 53 | +fi |
| 54 | + |
| 55 | +echo "Uploading everything to Nexus" |
| 56 | +EXIT_STATUS=0 |
| 57 | +curl --fail -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "$src_file" 'https://repo.stackable.tech/repository/packages/omid/' || EXIT_STATUS=$? |
| 58 | +curl --fail -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "$src_file.asc" 'https://repo.stackable.tech/repository/packages/omid/' || EXIT_STATUS=$? |
| 59 | +curl --fail -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "$src_file.sha512" 'https://repo.stackable.tech/repository/packages/omid/' || EXIT_STATUS=$? |
| 60 | + |
| 61 | +if [ $EXIT_STATUS -ne 0 ]; then |
| 62 | + echo "ERROR: Upload failed" |
| 63 | + exit 1 |
| 64 | +fi |
| 65 | + |
| 66 | +echo "Successfully uploaded version $VERSION of Omid to Nexus" |
| 67 | +echo "https://repo.stackable.tech/service/rest/repository/browse/packages/omid/" |
0 commit comments