-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
publish.sh
executable file
·71 lines (59 loc) · 2.31 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
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Auto-release script for https://github.com/devforth/painterro
# Creates new release, builds assets and performs publishing to github and npm
GH_USER=ivictbor
GH_REPO_USER=devforth
GH_PASS=`cat ~/keys/.ghtoken`
WP_PASSWORD=`cat ~/keys/.wppassword`
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 -rf wp
svn co http://plugins.svn.wordpress.org/painterro/ wp
rm -f wp/trunk/painterro-*.min.js
rm -f 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 --force .
svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm
svn --username=vanbrosh --password="${WP_PASSWORD}" ci -m "${VERSION}"
cd ..
git add -u
git commit -m "$VERSION"
git push
npm publish
ehco "GH USER AND PATH",$GH_USER, $GH_PASS
res=`curl --user "$GH_USER:$GH_PASS" -X POST https://api.github.com/repos/${GH_REPO_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
echo "Release id", $rel_id
curl --user "$GH_USER:$GH_PASS" -X POST https://uploads.github.com/repos/${GH_REPO_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_PASS" -X POST https://uploads.github.com/repos/${GH_REPO_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}