build-hass/.pipeline/build.sh

48 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
#
dir=$(dirname $0)
HASS_MAIN_BRANCH=dev
if [[ ! -d core/ ]]; then
echo "[>] git-init.sh"
$dir/git-init.sh
else
echo "[ ] exists: 'core/'"
echo "[>] git checkout $HASS_MAIN_BRANCH"
git -C core/ checkout $HASS_MAIN_BRANCH
fi
if [[ "$HASS_VERSION" == "" ]]; then
echo "[>] version.sh"
source $dir/version.sh
fi
echo "[ ] HASS_VERSION: '$HASS_VERSION'"
echo "[>] git-checkout-version.sh"
$dir/git-checkout-version.sh
echo "[>] docker build"
# --target export --output dist/
docker build \
--progress plain \
-t hass:latest \
.
echo "[>] docker tag"
docker tag hass:latest hass:${HASS_VERSION}
docker tag hass:${HASS_VERSION} git.sudo.is/ben/hass:latest
docker tag hass:${HASS_VERSION} git.sudo.is/ben/hass:${HASS_VERSION}
echo "[ ] docker image ls hass"
docker image ls hass
if [[ -t 1 ]]; then
# run docker container with -t if we are in a TTY
DOCKER_OPT_TTY="-t"
fi
echo "[ ] docker run hass:latest --version"
docker run --rm $DOCKER_OPT_TTY hass:latest --version