Files
bake/Bakefile
T
2019-09-19 15:25:31 -04:00

104 lines
2.3 KiB
Plaintext

REGISTRY=${REGISTRY:-docker.pkg.github.com}
USERNAME=${USERNAME:-kennethreitz}
install: install/system install/python
test: python/test docker/test
# bake -i release v0.0.0
release: pypi/publish docker/release
python/test: install/python
pipenv run pytest
docker/bash: docker/build
docker-compose run --entrypoint bash bake
docker/test: docker/build
docker-compose run --entrypoint bash bake -c 'set -ex && pip3 install pytest && pytest'
docker/build:
# Build the images.
set -ex && docker-compose build
docker/build/full:
# Build the images.
set -ex && docker-compose build --no-cache
install/python: @skip:key=Pipfile.lock install/system
pipenv install --dev
install/system:
lazy_brew pipenv
release/pypi: install/python
pipenv run python setup.py upload
release: test release/git release/docker
release/git:
RELEASE=$1
if [[ -z "$RELEASE" ]]; then
echo 'Release ($1) not provided; skipping.'
exit 0
fi
set -u
if [[ $(git diff --stat) ]]; then
git commit -am
git tag "$1"
git push --tags
else
echo 'Git tree is dirty. Aborting!'
exit 1
fi
release/docker: docker/build/full release/docker/github
release/docker/github: docker/build/full
set -ux
declare -a IMAGES=('bake:core' 'bake:latest')
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
release/docker/dockerhub: docker/build/full
docker-compose push
ci: ci/setup
set -ex && mkdir -p reports/pytest && pytest --junitxml=reports/pytest/report.xml
ci/setup: @skip:key=Pipfile.lock
pipenv install --dev --deploy --system
random/python:
#!/usr/bin/env python
import site
print(site)
lazy_brew() {
set -e
# Install jq if it's not available.
if ! which jq > /dev/null; then
set -ex && brew install jq
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
}