-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupload_new_trino_version.sh
executable file
·55 lines (40 loc) · 1.83 KB
/
upload_new_trino_version.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -euo pipefail
VERSION=${1:?"Missing version number argument (arg 1)"}
NEXUS_USER=${2:?"Missing Nexus username argument (arg 2)"}
read -r -s -p "Nexus Password: " NEXUS_PASSWORD
echo ""
# https://stackoverflow.com/questions/4632028/how-to-create-a-temporary-directory
# Find the directory name of the script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# the temp directory used, within $DIR
WORK_DIR=$(mktemp -d -p "$DIR")
# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
# deletes the temp directory
function cleanup {
rm -rf "$WORK_DIR"
}
# register the cleanup function to be called on the EXIT signal
trap cleanup EXIT
cd "$WORK_DIR" || exit
src_file=trino-server-$VERSION-src.tar.gz
echo "Downloading Trino"
# Trino provides no offficial source tarballs, download from Git
git clone https://github.com/trinodb/trino "trino-${VERSION}" "--branch=${VERSION}" --depth=1
echo "Archiving Trino"
git -C "trino-${VERSION}" archive "${VERSION}" --format=tar.gz --prefix="trino-server-${VERSION}-src/" > "${src_file}"
sha256sum "${src_file}" | cut --delimiter=' ' --field=1 > "${src_file}.sha256"
echo "Uploading everything to Nexus"
EXIT_STATUS=0
curl --fail -o /dev/null --progress-bar -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "${src_file}" 'https://repo.stackable.tech/repository/packages/trino-server/' || EXIT_STATUS=$?
curl --fail -o /dev/null --progress-bar -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "${src_file}.sha256" 'https://repo.stackable.tech/repository/packages/trino-server/' || EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then
echo "ERROR: Upload failed"
exit 1
fi
echo "Successfully uploaded version ${VERSION} of Trino to Nexus"
echo "https://repo.stackable.tech/service/rest/repository/browse/packages/trino-server/"