-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpublish.sh
executable file
·57 lines (44 loc) · 1.69 KB
/
publish.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
57
#!/usr/bin/env bash
######################################################################################################
#
# This deploy script requires have all the necessary gradle properties already set up:
# - signing.keyId
# - signing.password
# - signing.secretKeyRingFile
# - sonatype.url
# - sonatype.username
# - sonatype.password
#
######################################################################################################
# Stop script on errors or undefined vars
set -euo pipefail;
readonly SCRIPT_NAME="$(basename "$0")"
readonly green="\e[0;32m"
readonly red="\e[0;31m"
readonly reset="\e[0m"
if [ $# -lt 1 ]; then
echo
echo "Usage:"
echo -e "${green}$SCRIPT_NAME <version> [optional tag message]${reset}"
exit 1
fi
readonly version="$1"
# default tag message
tag_message="$version release"
if [ -n "${2-}" ]; then
tag_message="$2"
fi
echo -e "${green}Building and uploading release ...${reset}"
./gradlew clean build publishToSonatype
echo -e "${green}Closing sonatype staging repository ...${reset}"
./gradlew closeSonatypeStagingRepository
echo -e "${green}Pushing version tag ...${reset}"
git tag -a "${version}" -m "${tag_message}" && \
git push --tags
# fix version in README.md if needed
echo -e "${green}Setting version in README.md to $version ...${reset}"
sed -E "s/\"com.infinum:retrofit-converter-thrifty:[\.0-9]+\"/\"com.infinum:retrofit-converter-thrifty:$version\"/g" README.md > tmp_readme && mv tmp_readme README.md
# show changes so we know to commit if needed
echo -e "${green}\nHere's the output of git status:\n${reset}"
git status
echo -e "${red}\n\nDON'T FORGET to release the artifact on https://oss.sonatype.org/#stagingRepositories !\n${reset}"