Skip to content

Commit 01d1d59

Browse files
committed
chore(wip): Upload script for nvm
WIP: We might not need this, but I made it and it works.
1 parent b3a8f7d commit 01d1d59

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.scripts/upload_new_nvm_version.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
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+
34+
# https://github.com/nvm-sh/nvm/archive/refs/tags/v0.40.3.tar.gz
35+
BASE_URL="https://github.com/nvm-sh/nvm/archive/refs/tags"
36+
ARCHIVE_FILE="v$VERSION.tar.gz"
37+
ARCHIVE_URL="$BASE_URL/$ARCHIVE_FILE"
38+
39+
echo "Downloading nvm $VERSION"
40+
curl --fail -LO --progress-bar "$ARCHIVE_URL"
41+
42+
# nvm maintainers don't produce sum files
43+
44+
echo "Uploading to Nexus"
45+
46+
curl --fail -o /dev/null --progress-bar -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "$ARCHIVE_FILE" 'https://repo.stackable.tech/repository/packages/nvm/'
47+
48+
echo "Successfully uploaded nvm $VERSION to Nexus"
49+
echo "https://repo.stackable.tech/service/rest/repository/browse/packages/nvm/"
50+
echo "https://github.com/nvm-sh/nvm/releases/tag/v$VERSION"

0 commit comments

Comments
 (0)