-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·74 lines (55 loc) · 1.54 KB
/
build.sh
File metadata and controls
executable file
·74 lines (55 loc) · 1.54 KB
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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$(mktemp -d "${TMPDIR:-/tmp}/flare-daemon-build.XXXXXX")"
BOX_CACHE_DIR="${ROOT_DIR}/.box/bin"
BOX_PHAR="${BOX_CACHE_DIR}/box.phar"
OUTPUT_PHAR="${ROOT_DIR}/daemon.phar"
BOX_VERSION="${BOX_VERSION:-4.6.2}"
cleanup() {
rm -rf "${BUILD_DIR}"
}
ensure_box() {
if command -v box >/dev/null 2>&1; then
BOX_CMD=(box)
return
fi
mkdir -p "${BOX_CACHE_DIR}"
if [[ ! -f "${BOX_PHAR}" ]]; then
curl -fsSL "https://github.com/box-project/box/releases/download/${BOX_VERSION}/box.phar" -o "${BOX_PHAR}"
chmod +x "${BOX_PHAR}"
fi
BOX_CMD=(php -d error_reporting=24575 "${BOX_PHAR}")
}
trap cleanup EXIT
(
cd "${ROOT_DIR}"
tar \
--exclude='./.box' \
--exclude='./.build' \
--exclude='./.git' \
--exclude='./daemon.phar' \
--exclude='./vendor' \
-cf - .
) | (
cd "${BUILD_DIR}"
tar -xf -
)
printf '%s\n' "${FLARE_DAEMON_VERSION:-dev}" > "${BUILD_DIR}/version.txt"
COMPOSER_BUILD_VERSION="${FLARE_DAEMON_VERSION:-dev}"
if [[ "${COMPOSER_BUILD_VERSION}" == "dev" ]]; then
COMPOSER_BUILD_VERSION="dev-main"
fi
export COMPOSER_ROOT_VERSION="${COMPOSER_BUILD_VERSION}"
composer install \
--working-dir="${BUILD_DIR}" \
--no-dev \
--prefer-dist \
--optimize-autoloader
ensure_box
(
cd "${BUILD_DIR}"
"${BOX_CMD[@]}" compile -c box.json.dist
)
cp "${BUILD_DIR}/daemon.phar" "${OUTPUT_PHAR}"
printf 'Built %s\n' "${OUTPUT_PHAR}"