This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
/
run-build.sh
executable file
·111 lines (97 loc) · 2.31 KB
/
run-build.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
#!/bin/bash
export CMD=$*
if [[ -z "$CMD" ]]; then
echo "Usage: $0 <your build cmd>"
exit 1
fi
set -e
cd /opt/buildhome
if [[ ! -d repo ]]; then
git clone /opt/repo repo
fi
cd repo
if [[ -f runtime.txt ]]; then
if source $HOME/python$(cat runtime.txt)/bin/activate; then
echo "Python version set to $(cat runtime.txt)"
else
echo "Error setting python version from runtime.txt"
echo "Will use default version (2.7)"
source $HOME/python2.7/bin/activate
fi
else
source $HOME/python2.7/bin/activate
fi
# Node version
source $HOME/.nvm/nvm.sh
export NODE_VERSION=6
if [[ -f .nvmrc ]]; then
nvm install $(cat .nvmrc)
if [[ $? -ne 0 ]]; then
echo "Failed to set version of node to '$(cat .nvmrc)' from .nvmrc. Falling back to version $NODE_VERSION"
else
NODE_VERSION=$(nvm current)
fi
fi
export NODE_VERSION=$NODE_VERSION
# Ruby version
source $HOME/.rvm/scripts/rvm
export RUBY_VERSION=2.1.2
if [[ -f .ruby-version ]]; then
if rvm use $(cat .ruby-version); then
echo "Set ruby from .ruby-version"
export RUBY_VERSION=$(cat .ruby-version)
else
echo "Error setting ruby version from .ruby-version file. Unsupported version?"
echo "Will use default version (2.1.2)"
rvm use $RUBY_VERSION
fi
else
rvm use $RUBY_VERSION
fi
# Java version
export JAVA_VERSION=default_sdk
# Rubygems
if [[ -f Gemfile ]]; then
echo "Installing gem bundle"
if bundle install --path $HOME/bundle --deployment --binstubs=$HOME/binstubs; then
export PATH=$HOME/binstubs:$PATH
echo "Gem bundle installed"
fi
fi
# PIP dependencies
if [[ -f requirements.txt ]]; then
echo "Installing pip dependencies"
if pip install -r requirements.txt; then
echo "Pip dependencies installed"
fi
fi
# NPM Dependencies
if [[ -f package.json ]]; then
echo "Installing npm modules"
if [[ -f yarn.lock ]]; then
if yarn install; then
export PATH=$(yarn bin):$PATH
echo "NPM modules installed"
fi
else
if npm install; then
export PATH=$(npm bin):$PATH
echo "NPM modules installed"
fi
fi
fi
# Bower Dependencies
if [[ -f bower.json ]]; then
echo "Installing bower components"
if bower install --config.interactive=false; then
echo "Bower components installed"
fi
fi
# Leiningen
if [[ -f project.clj ]]; then
if lein deps; then
echo "Leiningen dependencies installed"
fi
fi
echo "Running build command '$CMD'"
eval $CMD