forked from beautifier/js-beautify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-all.sh
executable file
·85 lines (72 loc) · 1.79 KB
/
release-all.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
#!/usr/bin/env bash
REL_SCRIPT_DIR="`dirname \"$0\"`"
SCRIPT_DIR="`( cd \"$REL_SCRIPT_DIR\" && pwd )`"
case "$OSTYPE" in
darwin*) PLATFORM="OSX" ;;
linux*) PLATFORM="LINUX" ;;
bsd*) PLATFORM="BSD" ;;
*) PLATFORM="UNKNOWN" ;;
esac
generate_changelog()
{
$SCRIPT_DIR/generate-changelog.sh beautify-web/js-beautify || exit 1
git commit -am "Update Changelog for $NEW_VERSION"
}
release_python()
{
git clean -xfd || exit 1
echo "__version__ = '$NEW_VERSION'" > python/jsbeautifier/__version__.py
git commit -am "Python $NEW_VERSION"
cd python
python setup.py register
python setup.py sdist bdist_wininst upload
git push
}
release_node()
{
git clean -xfd || exit 1
npm version $NEW_VERSION
npm publish .
git push
git push --tags
}
release_web()
{
local ORIGINAL_BRANCH
ORIGINAL_BRANCH=$(git branch | grep '[*] .*' | awk '{print $2}')
git clean -xfd || exit 1
git fetch || exit 1
git checkout -B gh-pages origin/gh-pages || exit 1
git merge origin/master && git push || exit 1
git checkout $ORIGINAL_BRANCH
}
sedi() {
if [[ "$PLATFORM" == "OSX" || "$PLATFORM" == "BSD" ]]; then
sed -i "" $@
elif [ "$PLATFORM" == "LINUX" ]; then
sed -i $@
else
exit 1
fi
}
update_readme_versions()
{
git clean -xfd || exit 1
sedi -E 's@(cdn.rawgit.+beautify/)[^/]+@\1'$NEW_VERSION'@' README.md
sedi -E 's/\((README\.md:.js-beautify@).+\)/(\1'$NEW_VERSION')/' README.md
git add README.md
git commit -m "Bump version numbers in README.md"
}
main()
{
cd $SCRIPT_DIR/..
local NEW_VERSION=$1
NEW_VERSION=$1
git checkout master
generate_changelog
update_readme_versions
(release_python)
release_node
release_web
}
(main $*)