-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathrelease.sh
executable file
·163 lines (120 loc) · 4.11 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
set -e
PROJECT_DIR=$(pwd)
function echo_section() {
echo "--------------------------------------------"
echo $1
echo "--------------------------------------------"
}
function readVersion() {
echo -n "Type new version: "
read NEW_VERSION
}
function copy_doc_files() {
cp $PROJECT_DIR/README.md .
cp $PROJECT_DIR/LICENSE .
}
function copy_project_file() {
cp -r "$PROJECT_DIR/$1" .
}
function copy_standard_assets() {
copy_project_file dist/assets/schemio-standalone.js
copy_project_file assets/schemio-standalone.html
copy_project_file assets/schemio-standalone.css
copy_project_file assets/main.css
copy_project_file assets/css
copy_project_file assets/images
copy_project_file assets/webfonts
}
function review_and_edit_release_notes() {
vim .release-notes
echo "-------------------"
echo "Release notes"
echo "-------------------"
cat .release-notes
echo ""
echo ""
echo -n "Are you ok with release notes [Y/n] ? "
read ANSWER
if echo "$ANSWER" | grep -iq '[Nn]o*'; then
echo -n "Do you want to edit release notes (if not then it will exit) [Y/n] ? "
read ANSWER2
if echo "$ANSWER2" | grep -iq '[Nn]o*'; then
exit 0
fi
review_and_edit_release_notes
fi
}
echo "Generating release notes"
./release-notes-generator.sh > .release-notes
review_and_edit_release_notes
CURRENT_VERSION=$(cat package.json | jq -r .version)
echo "Current version is: $CURRENT_VERSION"
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
echo -n "Proposed new version: $NEW_VERSION [Y/n] ? "
read ANSWER
if echo "$ANSWER" | grep -iq '[Nn]o*' ;then
readVersion
fi
echo "Going to use new version: $NEW_VERSION"
echo_section "Running tests"
npm test
echo "Cleaning dists folder"
rm -rf dists/*
echo_section "Building app"
npm run build-app-prod
echo_section "Building component"
npm run build-component-prod
echo_section "Building static app"
npm run build-ui-static-app-prod
echo_section "Building release assets"
mkdir -p dist/release
rm -rf dist/release/*
BIN_FOLDER_NAME="schemio-$NEW_VERSION"
BIN_FOLDER_PATH="$PROJECT_DIR/dist/release/$BIN_FOLDER_NAME"
mkdir "$BIN_FOLDER_PATH"
cd "$BIN_FOLDER_PATH"
copy_doc_files
copy_project_file dist/assets/schemio.js
copy_standard_assets
copy_project_file html/index-server.tpl.html
cd $PROJECT_DIR/dist/release
zip -9 -r "schemio-$NEW_VERSION.zip" $BIN_FOLDER_NAME
cd $PROJECT_DIR
BIN_FOLDER_NAME="schemio-static-$NEW_VERSION"
BIN_FOLDER_PATH="$PROJECT_DIR/dist/release/$BIN_FOLDER_NAME"
mkdir "$BIN_FOLDER_PATH"
cd "$BIN_FOLDER_PATH"
copy_doc_files
copy_project_file dist/assets/schemio.app.static.js
copy_standard_assets
cp $PROJECT_DIR/html/index-static.html $BIN_FOLDER_PATH/index.html
cd $PROJECT_DIR/dist/release
zip -9 -r "schemio-static-$NEW_VERSION.zip" $BIN_FOLDER_NAME
cd $PROJECT_DIR
echo_section "Building drive app for prod"
./build-drive-app.sh
echo_section "Building docker container"
# changing package version to hardcoded value so that docker build does not rebuild all layers
cat package.json | jq ".version=\"0.1.1\"" > tmp && mv tmp package.json
DOCKER_CONTAINER="schemio:$NEW_VERSION"
PUBLIC_DOCKER_TAG="binshu/schemio:$NEW_VERSION"
PUBLIC_LATEST_TAG="binshu/schemio:latest"
docker build -t "$DOCKER_CONTAINER" .
docker tag "$DOCKER_CONTAINER" "$PUBLIC_DOCKER_TAG"
docker tag "$DOCKER_CONTAINER" "$PUBLIC_LATEST_TAG"
echo_section "Updating package.json"
cat package.json | jq ".version=\"$NEW_VERSION\"" > tmp && mv tmp package.json
git add package.json
git commit -m "Updated version to $NEW_VERSION"
git push
echo_section "Creating a git tag for version: $NEW_VERSION"
NEW_TAG="v$NEW_VERSION"
git tag "$NEW_TAG"
git push origin --tags
echo_section "Publishing release on GitHub"
gh release create $NEW_TAG dist/release/*.zip --title "Released version $NEW_VERSION" --notes-file .release-notes
echo_section "Done"
echo "You can push docker container to docker hub now using the following command:"
echo ""
echo " docker login --username=binshu && docker push $PUBLIC_DOCKER_TAG && docker push $PUBLIC_LATEST_TAG"