-
Notifications
You must be signed in to change notification settings - Fork 17
/
release.sh
executable file
·65 lines (44 loc) · 1.84 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
#!/bin/zsh -e
# Assumes gh is installed and logged in
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ ! "$BRANCH" = "master" ]; then
printf >&2 "\033[1;31mNot on master branch, abording\033[0m"
exit 255
fi
if [[ -n $(git status --porcelain) ]]; then
printf >&2 "\033[1;31mCannot release version because there are unstaged changes, aborting\nChanges:\033[0m\n"
git status --short
exit 255
fi
if [[ -n $(git log --branches --not --remotes) ]]; then
echo -e "\033[1;34mPushing pending commits to git\033[0m"
git push
fi
echo -e "\033[1;34mCreating release notes\033[0m"
RELEASE_NOTES_FILE="${SCRIPTPATH}/Distribution/_tmp_release_notes.md"
touch "${RELEASE_NOTES_FILE}"
open -Wn "${RELEASE_NOTES_FILE}"
if ! [ -s "${RELEASE_NOTES_FILE}" ]; then
echo -e >&2 "\033[1;31mNo release notes provided, aborting\033[0m"
rm -f "${RELEASE_NOTES_FILE}"
exit 255
fi
"${SCRIPTPATH}/Scripts/updateCopyright.sh"
"${SCRIPTPATH}/build.sh"
echo -e "\033[1;34mCopying script\033[0m"
cp "${SCRIPTPATH}/record.sh" "${SCRIPTPATH}/Distribution"
echo -e "\033[1;34mUpdating package.json version\033[0m"
SHORT_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${SCRIPTPATH}/Distribution/DetoxRecorder.framework/Info.plist")
BUILD_NUMBER=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${SCRIPTPATH}/Distribution/DetoxRecorder.framework/Info.plist")
VERSION="${SHORT_VERSION}"."${BUILD_NUMBER}"
cd "${SCRIPTPATH}/Distribution"
npm version "${VERSION}" --allow-same-version
# echo -e "\033[1;34mReleasing\033[0m"
npm publish
git add -A &> /dev/null
git commit -m "${VERSION}" &> /dev/null
git push
echo -e "\033[1;34mCreating GitHub release\033[0m"
gh release create --repo wix/DetoxRecorder "$VERSION" --title "$VERSION" --notes-file "${RELEASE_NOTES_FILE}"
rm -f "${RELEASE_NOTES_FILE}"