Files
bake/Bakefile
T
2019-09-18 18:45:44 -04:00

60 lines
1.5 KiB
Plaintext

install: install/system install/python
install/python: install/system @skip:key=./Pipfile.lock
pipenv install
install/system:
lazy-brew jq docker-compose
docker/bash: docker/build install/system
docker-compose run --entrypoint=bash bake
docker/release: docker/build install/system docker/login
docker-compose push
docker/login:
# -- this task must be run with -i mode.
# Login to GitHub Package Registry.
echo 'Maybe visit: https://github.com/settings/tokens'
set -ex && docker login {REGISTRY:=-docker.pkg.github.com}" --username "{USERNAME:=-kennethreitz}"
# Login to DockerHub.
docker login
docker/build: install/system
REGISTRY="{REGISTRY:=-docker.pkg.github.com}"
USERNAME="{USERNAME:=-kennethreitz}"
set -u
declare -a IMAGES=('bake:core' 'bake:latest')
# Build the images.
docker-compose build
for IMAGE in "${IMAGES[@]}"; do
REMOTE_IMAGE="$REGISTRY/$USERNAME/bake/$IMAGE"
# Tag the images for GitHub Registry.
docker tag "$USERNAME/$IMAGE" "$REMOTE_IMAGE"
# Push the images to GitHub.
docker push "$REMOTE_IMAGE"
done
lazy-brew() {
set -e
# Install jq if it's not available.
if ! which jq > /dev/null; then
set -ex && brew install jq > /dev/null
fi
# Install requested packages, if they aren't installed.
for PACKAGE in "$@"; do
if ! brew info --installed --json | jq 'map(.name) | index( "$PACKAGE" )' > /dev/null; then
set -ex && brew install "$PACKAGE" > /dev/null
fi
done
}