-
Notifications
You must be signed in to change notification settings - Fork 10
/
package.sh
executable file
·40 lines (33 loc) · 1.03 KB
/
package.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
#!/bin/bash
set -euo pipefail
VERSION_REGEX='project\([^)]*VERSION\s+(\d+\.\d+.\d+)[^)]*\)'
TENTRIS_VER=$(grep -Poz "$VERSION_REGEX" CMakeLists.txt | grep -Poz '[0-9]+\.[0-9]+\.[0-9]+')
CUR_BRANCH=$(git branch --show-current | sed 's|/|_|g')
# get current commit hash
COMMIT_HASH=$(git rev-parse --short HEAD)
if [[ -n $CUR_BRANCH ]]; then
TENTRIS_NAME="tentris_${TENTRIS_VER}_${CUR_BRANCH}_${COMMIT_HASH}"
else
TENTRIS_NAME="tentris_${TENTRIS_VER}_${COMMIT_HASH}"
fi
if podman --version > /dev/null; then
echo "Using podman"
BUILDER="podman"
elif docker --version > /dev/null; then
echo "Using docker"
BUILDER="docker"
else
echo "Error: Neither podman nor docker found" 2>&1
exit 1
fi
cleanup_and_tmpdir() {
TEMP_DIR=$(mktemp -d) || exit 1
}
# make sure TEMP_DIR will be removed on failure
trap 'rm -rf "$TEMP_DIR"' EXIT
cleanup_and_tmpdir
mkdir -p "${TENTRIS_NAME}"
${BUILDER} build . --output="${TEMP_DIR}" --target=binaries
echo "${TEMP_DIR}"
ls -lah "${TEMP_DIR}"
cp -r "${TEMP_DIR}/." "./${TENTRIS_NAME}/"