-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_bundle_jar.sh
executable file
·56 lines (42 loc) · 1.31 KB
/
upload_bundle_jar.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
56
#!/bin/bash -e
# ref.) https://issues.sonatype.org/browse/OSSRH-39405
# NOTE: Shares the same settings file with https://github.com/saket/startship,
# but it does not work because the tool expect the staging repository state open.
STARTSHIP_SETTINGS_FILE="$HOME/.gradle/gradle.properties"
SONATYPE_USER=$(cat "$STARTSHIP_SETTINGS_FILE" | grep 'SONATYPE_NEXUS_USERNAME=' | sed 's/.*=\(.*\)/\1/')
SONATYPE_PASSWORD=$(cat "$STARTSHIP_SETTINGS_FILE" | grep 'SONATYPE_NEXUS_PASSWORD=' | sed 's/.*=\(.*\)/\1/')
usage_exit() {
echo "Usage: $0 -u SONATYPE_NEXUS_USER -p SONATYPE_NEXUS_PASSWORD bundle_jar" 1>&2
exit 1
}
while getopts u:p:h OPT
do
case $OPT in
u) SONATYPE_USER=$OPTARG
;;
p) SONATYPE_PASSWORD=$OPTARG
;;
h) usage_exit
;;
\?) usage_exit
;;
esac
done
shift $((OPTIND - 1))
BUNDLE="$1"
if [[ "$SONATYPE_USER" = '' ]]; then
echo 'User name is not specified' 1>&2
usage_exit
fi
if [[ "$SONATYPE_PASSWORD" = '' ]]; then
echo 'Password is not specified' 1>&2
usage_exit
fi
if [[ "$BUNDLE" = '' ]]; then
echo 'Artifact bundle file is not specified' 1>&2
usage_exit
fi
curl \
--user "$SONATYPE_USER:$SONATYPE_PASSWORD" \
--form "file=@$BUNDLE" \
https://oss.sonatype.org/service/local/staging/bundle_upload