Skip to content

Commit bb3b60d

Browse files
liranmaudanimrod-becker
authored andcommitted
build_server.sh: moved the logic of the job into file
build_server.sh: - Moved the logic of the job into file
1 parent 2dc0e6d commit bb3b60d

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

src/deploy/Linux/build_server.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
echo "$(date) =====> nvm install"
4+
source ~/.bashrc || exit 1
5+
source "$NVM_DIR/nvm.sh" || exit 1
6+
nvm install || exit 1
7+
NODEJS_VERSION=$(nvm current)
8+
9+
echo "$(date) =====> mkdirs"
10+
mkdir -p build/public/
11+
12+
echo "$(date) =====> update package.json for git commit $GIT_COMMIT"
13+
NB_VERSION=$(node << EOF
14+
'use strict';
15+
const fs = require('fs');
16+
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
17+
const git = process.env.GIT_COMMIT || 'DEVONLY';
18+
const version = pkg.version.split('-')[0] + '-' + git.slice(0, 7);
19+
const EXCLUDE_DEPS_REGEXP = /gulp|mocha|istanbul|eslint|vsphere/;
20+
const INCLUDE_DEV_DEPS_REGEXP = /babel/;
21+
const deps = Object.keys(pkg.dependencies);
22+
const dev_deps = Object.keys(pkg.devDependencies);
23+
const dependencies = {};
24+
const devDependencies = {};
25+
for (let i = 0; i < deps.length; ++i) {
26+
if (EXCLUDE_DEPS_REGEXP.test(deps[i])) {
27+
console.warn('exclude dependency:', deps[i]);
28+
} else {
29+
dependencies[deps[i]] = pkg.dependencies[deps[i]];
30+
}
31+
}
32+
for (let i = 0; i < dev_deps.length; ++i) {
33+
if (INCLUDE_DEV_DEPS_REGEXP.test(dev_deps[i])) {
34+
devDependencies[dev_deps[i]] = pkg.devDependencies[dev_deps[i]];
35+
}
36+
}
37+
const updated_pkg = {
38+
name: 'noobaa-NVA',
39+
version: version,
40+
private: true,
41+
license: 'Copyright (C) 2016 NooBaa all rights reserved',
42+
scripts: pkg.scripts,
43+
dependencies,
44+
devDependencies,
45+
browser: pkg.browser,
46+
};
47+
fs.writeFileSync('./package.json', JSON.stringify(updated_pkg, null, 2) + '\n');
48+
console.log(version);
49+
EOF
50+
)
51+
echo "$(date) =====> version $NB_VERSION"
52+
53+
echo "$(date) =====> npm install"
54+
npm install || exit 1
55+
56+
echo "$(date) =====> npm install frontend"
57+
pushd frontend
58+
npm install || exit 1
59+
popd
60+
61+
echo "$(date) =====> download node.js tarball ($NODEJS_VERSION} and nvm.sh (latest)"
62+
wget -P build/public/ https://nodejs.org/dist/${NODEJS_VERSION}/node-${NODEJS_VERSION}-linux-x64.tar.xz || exit 1
63+
wget -P build/public/ https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh || exit 1
64+
65+
echo "$(date) =====> tar noobaa-NVA-${NB_VERSION}.tar.gz"
66+
tar \
67+
--transform='s:^:noobaa-core/:' \
68+
--exclude='src/native' \
69+
-czf noobaa-NVA-${NB_VERSION}.tar.gz \
70+
LICENSE \
71+
EULA.pdf \
72+
package.json \
73+
platform_restrictions.json \
74+
config.js \
75+
.nvmrc \
76+
src/ \
77+
frontend/dist/ \
78+
build/public/ \
79+
build/Release/ \
80+
node_modules/ \
81+
|| exit 1
82+
mv noobaa-NVA-${NB_VERSION}.tar.gz build/public/

0 commit comments

Comments
 (0)