-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·110 lines (87 loc) · 3.96 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
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
#!/bin/bash -e
# -------------------------------------------------------------------------------------------------------------------- #
# INITIALIZATION.
# -------------------------------------------------------------------------------------------------------------------- #
init() {
# Vars.
REPO="${1}"
USER="${2}"
EMAIL="${3}"
TOKEN="${4}"
# Apps.
composer="$( command -v composer )"
mkdir="$( command -v mkdir )"
rm="$( command -v rm )"
tar="$( command -v tar )"
git="$( command -v git )"
date="$( command -v date )"
# Git config.
${git} config --global user.email "${EMAIL}"
${git} config --global user.name "${USER}"
${git} config --global init.defaultBranch 'main'
# Run.
git_clone \
&& build_eng \
&& build_rus \
&& git_push
}
# -------------------------------------------------------------------------------------------------------------------- #
# GIT: CLONE REPOSITORY.
# -------------------------------------------------------------------------------------------------------------------- #
git_clone() {
REPO_AUTH="https://${USER}:${TOKEN}@${REPO#https://}"
${git} clone "${REPO_AUTH}" '/root/git/build' \
&& cd '/root/git/build' || exit 1
${git} remote add 'build' "${REPO_AUTH}"
}
# -------------------------------------------------------------------------------------------------------------------- #
# BUILD: FLARUM ENG.
# -------------------------------------------------------------------------------------------------------------------- #
build_eng() {
local name="flarum.eng"
${mkdir} -p "${name}" \
&& ${composer} --ignore-platform-reqs create-project flarum/flarum "${name}" \
&& ${tar} -cJf "${name}.tar.xz" "${name}" \
&& ${rm} -rf "${name}"
}
# -------------------------------------------------------------------------------------------------------------------- #
# BUILD: FLARUM RUS.
# -------------------------------------------------------------------------------------------------------------------- #
build_rus() {
local name="flarum.rus"
${mkdir} -p "${name}" \
&& ${composer} --ignore-platform-reqs create-project flarum/flarum "${name}" \
&& _pushd "${name}" \
&& ${composer} --ignore-platform-reqs require 'flarum-lang/russian' \
&& _popd \
&& ${tar} -cJf "${name}.tar.xz" "${name}" \
&& ${rm} -rf "${name}"
}
# -------------------------------------------------------------------------------------------------------------------- #
# GIT: PUSH FLARUM BUILDS TO STORAGE.
# -------------------------------------------------------------------------------------------------------------------- #
git_push() {
ts="$( _timestamp )"
${git} add . \
&& ${git} commit -a -m "BUILD: ${ts}" \
&& ${git} push 'build'
}
# -------------------------------------------------------------------------------------------------------------------- #
# ------------------------------------------------< COMMON FUNCTIONS >------------------------------------------------ #
# -------------------------------------------------------------------------------------------------------------------- #
# Pushd.
_pushd() {
command pushd "$@" > /dev/null || exit 1
}
# Popd.
_popd() {
command popd > /dev/null || exit 1
}
# Timestamp.
_timestamp() {
${date} -u '+%Y-%m-%d %T'
}
# -------------------------------------------------------------------------------------------------------------------- #
# -------------------------------------------------< INIT FUNCTIONS >------------------------------------------------- #
# -------------------------------------------------------------------------------------------------------------------- #
init "$@"; exit 0