-
-
Notifications
You must be signed in to change notification settings - Fork 157
/
release.sh
137 lines (108 loc) · 3.25 KB
/
release.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# Run checks and prepare a release build
#
# Credits to Feeder by @spacecowboy
# https://gitlab.com/spacecowboy/Feeder/
set -u
TARGET="${1:-HEAD}"
current_default="$(git describe --tags --abbrev=0 "${TARGET}")"
echo >&2 -n "Current version is ${current_default}, "
# read -r current_in
next_default="$(grep "versionName " ./app/build.gradle | sed "s|\s*versionName \"\(.*\)\"|\\1|")"
echo >&2 -n "next version [press 'enter' for ${next_default}]: "
read -r next_in
if [ -z "${next_in}" ]; then
NEXT_VERSION="${next_default}"
else
NEXT_VERSION="${next_in}"
fi
CURRENT_CODE="$(grep "versionCode" ./app/build.gradle | sed "s|\s*versionCode \([0-9]\+\)|\\1|")"
echo >&2 "Current code ${CURRENT_CODE}"
# The old version was 57130, so we have to use the thousands for the minor code, like 70100.
# The last 2 digits are useless, but it can't be helped
next_code_default=$(( CURRENT_CODE + 100 ))
echo >&2 -n "Next code [press 'enter' to confirm ${next_code_default}]: "
read -r next_code_in
if [ -z "${next_code_in}" ]; then
NEXT_CODE="${next_code_default}"
else
NEXT_CODE="${next_code_in}"
fi
read -r -p "Check consistency of languages list with values- folders? [y/N] " response
if [[ "$response" =~ ^[yY]$ ]]
then
./gradlew checkLanguages checkFastlane --quiet
fi
# empty new line
echo >&2 ""
echo >&2 "Opening changelog editor..."
echo >&2 ""
# changelog template. To add all the new commit messages, move this line inside the ""
CL="NoNonsense Notes v${NEXT_VERSION}
Highlights:
- FILL AND SAVE THIS FILE
Details:
-
Write no more than 500 words. Include the following:
$(git shortlog -w76,2,9 --format='* %s' "${current_default}"..HEAD)
"
tmpfile="$(mktemp)"
echo "${CL}" > "${tmpfile}"
if hash notepad 2>/dev/null; then
# edit with notepad
notepad "${tmpfile}"
else
# fallback
nano "${tmpfile}"
fi
echo >&2 ""
echo >&2 "Changelog for [${NEXT_VERSION}]:"
cat >&2 "${tmpfile}"
echo >&2
read -r -p "Write changelog? [y/N] " response
if [[ "$response" =~ ^[yY]$ ]]
then
# Playstore has a limit
head --bytes=500 "${tmpfile}" >"fastlane/metadata/android/en-US/changelogs/${NEXT_CODE}.txt"
fi
# update versions on build.gradle
read -r -p "Update gradle versions? [y/N] " response
if [[ "$response" =~ ^[yY]$ ]]
then
sed -i "s|\(\s*versionCode \)[0-9]\+|\\1${NEXT_CODE}|" app/build.gradle
sed -i "s|\(\s*versionName \).*|\\1\"${NEXT_VERSION}\"|" app/build.gradle
fi
read -r -p "Commit changes? [y/N] " response
if [[ "$response" =~ ^[yY]$ ]]
then
git add "fastlane/metadata/android/en-US/changelogs/${NEXT_CODE}.txt"
git add app/build.gradle
git commit -m "Releasing ${NEXT_VERSION} from release.sh"
fi
read -r -p "Make tag? [y/N] " response
if [[ "$response" =~ ^[yY]$ ]]
then
git tag -am "$(cat "${tmpfile}")" "${NEXT_VERSION}"
fi
echo "Status of git files:"
git status -s
read -r -p "Push files and tags to remote? [y/N] " response
if [[ "$response" =~ ^[yY]$ ]]
then
git push
git push --tags
fi
# github page to create releases
WEBPAGE=https://github.com/spacecowboy/NotePad/releases/new
echo $WEBPAGE
read -r -p "Open that github page to make a new release? [y/N] " response
if [[ "$response" =~ ^[yY]$ ]]
then
if hash start 2>/dev/null; then
# open URL on windows
start $WEBPAGE
else
# open URL on linux
xdg-open $WEBPAGE
fi
fi