-
Notifications
You must be signed in to change notification settings - Fork 1
/
release-as-zip.sh
executable file
·61 lines (50 loc) · 1.46 KB
/
release-as-zip.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
#!/bin/bash
set -e
VERSION=$(cat package.json | jq --raw-output .version)
PKG_NAME=$(cat package.json | jq --raw-output .name)
GITHUB_ORGANIZATION='sphereio'
LATEST_BRANCH_NAME='latest'
echo "About to release ${PKG_NAME} - v${VERSION} to ${LATEST_BRANCH_NAME} branch!"
cleanup() {
set +e
echo "Cleaning up"
rm -rf package
rm "${PKG_NAME}"-*
rm -rf tmp
set -e
}
# cleanup
cleanup
# install all deps
echo "Installing all deps"
npm install &>/dev/null
echo "Building sources"
grunt build &>/dev/null
# package npm and extract it
echo "Packaging locally"
npm pack
tar -xzf "${PKG_NAME}-${VERSION}.tgz"
cd package
# install production deps (no devDeps)
echo "Installing only production deps"
npm install --production &>/dev/null
# push everything inside package to 'latest' branch
git init
git remote add origin "[email protected]:${GITHUB_ORGANIZATION}/${PKG_NAME}.git"
git add -A &>/dev/null
git commit -m "Release packaged version ${VERSION} to ${LATEST_BRANCH_NAME} branch" &>/dev/null
echo "About to push to ${LATEST_BRANCH_NAME} branch"
git push --force origin master:${LATEST_BRANCH_NAME}
cd -
# test that zipped package works
echo "About to download and test released package"
mkdir -p tmp
cd tmp
curl -s -L "https://github.com/${GITHUB_ORGANIZATION}/${PKG_NAME}/archive/latest.zip" -o latest.zip
unzip -q latest.zip
cd "${PKG_NAME}-latest"/
node lib/run
cd ../..
# cleanup package / tmp folder
cleanup
echo "Congratulations, the latest package has been successfully released"