-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·59 lines (48 loc) · 1.25 KB
/
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
#!/bin/bash
set -eE
function getVersion {
local buildTS;
local buildYear;
local version;
buildTS="$(date '+%Y%m%d%H%M%S')"
buildYear="$(date '+%Y')"
if [ -z "${TRAVIS_BRANCH}" ]; then
version="local-${buildTS}"
else
if [[ -n $TRAVIS_TAG ]]; then
version="${TRAVIS_TAG}"
else
version="${TRAVIS_BRANCH}-${buildTS}"
fi
fi
echo "${version}"
}
function main {
local buildDir;
local buildYear;
local version;
local archiveName;
buildDir="$(dirname "$0")/build"
buildYear="$(date '+%Y')"
version="$(getVersion "${buildDir}")"
archiveName="synogandip-${version}.zip"
echo "building archive [${archiveName}] (${buildYear}) ..."
echo "cleaning ${buildDir} ..."
rm -rfv "${buildDir:?}"/*
mkdir -p "${buildDir}/synogandip"
echo "copying files ..."
cp -v ./src/* "${buildDir}/synogandip"
echo "setting version ..."
sed -i.tmp \
-e 's@__version__@'"${version}"'@g' \
-e 's@__year__@'"${buildYear}"'@g' \
"${buildDir}/synogandip/synogandip.sh"
rm "${buildDir}"/synogandip/*.tmp
echo "creating archive ..."
cd "${buildDir}" && zip -r "${archiveName}" synogandip
echo "archive created:"
ls -l "${archiveName}"
echo "$(pwd)/${archiveName}"
echo "build completed."
}
main "$@"