mirror of
https://github.com/kennethreitz/bake.git
synced 2026-06-05 23:00:17 +00:00
87 lines
2.5 KiB
Plaintext
87 lines
2.5 KiB
Plaintext
|
||
REGISTRY=${REGISTRY:-docker.pkg.github.com}
|
||
USERNAME=${USERNAME:-kennethreitz}
|
||
|
||
//: //system //python
|
||
red "System is setup for local development."
|
||
//system: //warn
|
||
lazy_brew pipenv bats
|
||
//python: @skip:key=Pipfile.lock //system
|
||
pipenv install --dev
|
||
test: docker/build
|
||
unset BAKEFILE
|
||
docker-compose run --entrypoint bash ci -c 'set -ex && pip3 uninstall -y bake-cli && pip3 install -e . --upgrade && hash -r && cd tests && bats *.bats --pretty'
|
||
release: test //warn @confirm:secure release//pypi docker/release
|
||
|
||
//warn:
|
||
echo
|
||
echo "$(red 'Warning'): you are about to do something destructive (to your system; or the internet — but what's the difference, these days?)."
|
||
echo
|
||
|
||
docker/build:
|
||
# Build the images.
|
||
set -ex && docker-compose build
|
||
|
||
docker/bash: @interactive docker/build
|
||
docker-compose run --entrypoint bash bake
|
||
|
||
release//pypi: @interactive //python
|
||
pipenv run python setup.py upload
|
||
|
||
docker/push: docker/build //docker/github //docker/dockerhub
|
||
|
||
//docker/github: docker/build
|
||
set -ux
|
||
|
||
declare -a IMAGES=('red', 'bake:core' 'bake:latest' 'bake:ci')
|
||
|
||
for IMAGE in "${IMAGES[@]}"; do
|
||
bake_step "Pushing $IMAGE..."
|
||
|
||
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
|
||
|
||
//docker/dockerhub: docker/build
|
||
docker-compose push
|
||
|
||
random/python/ip:
|
||
#!/usr/bin/env python
|
||
import requests
|
||
r = requests.get('https://httpbin.org/ip')
|
||
print(r.json()['origin'].split(',')[0])
|
||
|
||
//example/cli: //
|
||
red 'Testing sub–commands.'
|
||
bake_step 'sub-task'
|
||
echo 'I should *not* be red.' | red | bake_indent | notred
|
||
echo 'But, I *should* be red.' | red --always | bake_indent | bake_indent
|
||
echo "$(echo $(red test --fg yellow) $(red test --bold) $(red test --fg cyan) | bake_indent)"
|
||
echo
|
||
|
||
/kr:
|
||
sparkescakesparkles="✨ 🍰 ✨" | pbcopy
|
||
echo "$sparkescakesparkles" | pbcopy
|
||
echo 'KR Copied!' | red --fg cyan
|
||
|
||
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
|
||
}
|