forked from devforth/painterro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
61 lines (52 loc) · 1.98 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
58
59
60
61
#!/usr/bin/env bash
# Auto-release script for https://github.com/ivictbor/painterro
# Creates new release, builds assets and performs publishing to github and npm
GH_USER=ivictbor
GH_PATH=`cat ~/.ghpass`
GH_REPO=painterro
GH_TARGET=master
ASSETS_PATH=build
npm --no-git-tag-version version patch
VERSION=`grep '"version":' package.json | cut -d\" -f4`
npm run build
if [ $? -eq 0 ]; then
echo BUILD OK
else
echo FAIL
exit 0
fi
rm wp/trunk/painterro-*.min.js
rm wp/trunk/painterro-*.min.js.map
cp build/painterro-${VERSION}.min.js wp/trunk/
cp build/painterro-${VERSION}.min.js.map wp/trunk/
sed -i -E "s/([ \t]+version: \")[0-9\\.]+(\",)/\1${VERSION}\2/" wp/trunk/index.js
sed -i -E "s/(Version: )[0-9\\.]+/\1${VERSION}/" wp/trunk/painterro-wp.php
sed -i -E "s/(define\\(\"PAINTERRO_FILE\", \"painterro-)[0-9\\.]+(\\.min\\.js\"\\);)/\1${VERSION}\2/" wp/trunk/painterro-wp.php
cd wp
svn add trunk/*
svn ci -m "${VERSION}"
cd ..
git add -u
git commit -m "$VERSION"
git push
npm publish
res=`curl --user "$GH_USER:$GH_PATH" -X POST https://api.github.com/repos/${GH_USER}/${GH_REPO}/releases \
-d "
{
\"tag_name\": \"v$VERSION\",
\"target_commitish\": \"$GH_TARGET\",
\"name\": \"v$VERSION\",
\"body\": \"new version $VERSION\",
\"draft\": false,
\"prerelease\": false
}"`
echo Create release result: ${res}
rel_id=`echo ${res} | python -c 'import json,sys;print(json.load(sys.stdin)["id"])'`
file_name=painterro-${VERSION}.min.js
curl --user "$GH_USER:$GH_PATH" -X POST https://uploads.github.com/repos/${GH_USER}/${GH_REPO}/releases/${rel_id}/assets?name=${file_name}\
--header 'Content-Type: text/javascript ' --upload-file ${ASSETS_PATH}/${file_name}
file_map_name=painterro-${VERSION}.min.js.map
curl --user "$GH_USER:$GH_PATH" -X POST https://uploads.github.com/repos/${GH_USER}/${GH_REPO}/releases/${rel_id}/assets?name=${file_map_name}\
--header 'Content-Type: text/javascript ' --upload-file ${ASSETS_PATH}/${file_map_name}
rm ${ASSETS_PATH}/${file_name}
rm ${ASSETS_PATH}/${file_map_name}