forked from LeoNatan/LNPopupController
-
Notifications
You must be signed in to change notification settings - Fork 1
/
releaseVersion.sh
executable file
·57 lines (40 loc) · 1.84 KB
/
releaseVersion.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
#!/bin/bash
set -e
if [[ -n $(git status --porcelain) ]]; then
echo -e >&2 "\033[1;31mCannot release version because there are unstaged changes:\033[0m"
git status --short
exit -2
fi
if [[ -n $(git tag --contains $(git rev-parse --verify HEAD)) ]]; then
echo -e >&2 "\033[1;31mThe latest commit is already contained in the following releases:\033[0m"
git tag --contains $(git rev-parse --verify HEAD)
exit -3
fi
# if [[ -n $(git log --branches --not --remotes) ]]; then
# echo -e "\033[1;34mPushing pending commits to git\033[0m"
# git push
# fi
CURRENT_VERSION=$(/usr/libexec/PlistBuddy LNPopupController/Info.plist -c "Print CFBundleShortVersionString")
NEXT_VERSION=$(echo "$CURRENT_VERSION" | perl -pe 's/^((\d+\.)*)(-?\d+)(.*)$/$1.($3+1).$4/e')
echo -e "\033[1;34mUsing $NEXT_VERSION as release version\033[0m"
echo -e "\033[1;34mCreating release notes\033[0m"
RELEASE_NOTES_FILE=_tmp_release_notes.md
touch "${RELEASE_NOTES_FILE}"
open -Wn "${RELEASE_NOTES_FILE}"
if ! [ -s "${RELEASE_NOTES_FILE}" ]; then
echo >&2 "\033[1;31mNo release notes provided, aborting.\033[0m"
rm -f "${RELEASE_NOTES_FILE}"
exit -1
fi
echo -e "\033[1;34mUpdating framework version\033[0m"
/usr/libexec/PlistBuddy LNPopupController/Info.plist -c "Set CFBundleShortVersionString $NEXT_VERSION" -c "Set CFBundleVersion 1"
/usr/libexec/PlistBuddy LNPopupControllerExample/LNPopupControllerExample/Info.plist -c "Set CFBundleShortVersionString $NEXT_VERSION" -c "Set CFBundleVersion 1"
echo -e "\033[1;34mCommitting all changes to Git for release $NEXT_VERSION\033[0m"
git add -A
git commit -m "$NEXT_VERSION"
git tag "$NEXT_VERSION"
git push
git push --tags
echo -e "\033[1;34mCreating a GitHub release\033[0m"
gh release create --repo LeoNatan/LNPopupController "$NEXT_VERSION" --title "v$NEXT_VERSION" --notes-file "${RELEASE_NOTES_FILE}"
rm -f "${RELEASE_NOTES_FILE}"