Copy justfile from other repo and split up into common, containers, and python tasks
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
# Container runtime. Defaults to podman.
|
||||
container_engine := env("CONTAINER_ENGINE", "podman")
|
||||
|
||||
# Space-separated list of registries.
|
||||
#
|
||||
# Examples:
|
||||
# REGISTRIES="ghcr.io/battlesnake"
|
||||
# REGISTRIES="ghcr.io/battlesnake quay.io/battlesnake registry.example.com/battlesnake"
|
||||
registries := env("REGISTRIES", "")
|
||||
|
||||
# Image name
|
||||
image := env("IMAGE", "")
|
||||
|
||||
# Use the exact Git tag when HEAD is tagged.
|
||||
# Otherwise use the current Git commit SHA.
|
||||
version := ```
|
||||
git describe --tags --exact-match HEAD 2>/dev/null || \
|
||||
git rev-parse --short HEAD 2>/dev/null || \
|
||||
echo dev
|
||||
```
|
||||
|
||||
# Local image reference.
|
||||
image_ref := image + ":" + version
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Help
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Print version that would be used for artifacts.
|
||||
[group('help')]
|
||||
version:
|
||||
@echo "{{ version }}"
|
||||
|
||||
# Print current configuration.
|
||||
[group('help')]
|
||||
config:
|
||||
@echo "Version: {{ version }}"
|
||||
@echo "Container engine: {{ container_engine }}"
|
||||
@echo "Image: {{ image_ref }}"
|
||||
@echo "Registries:"
|
||||
@if [ -z "{{ registries }}" ]; then \
|
||||
echo " (none)"; \
|
||||
else \
|
||||
for registry in {{ registries }}; do \
|
||||
echo " $registry"; \
|
||||
done; \
|
||||
fi
|
||||
|
||||
# Check for environment issues.
|
||||
[group('help')]
|
||||
doctor:
|
||||
@command -v {{ container_engine }} >/dev/null || { \
|
||||
echo "{{ container_engine }} is not installed"; \
|
||||
exit 1; \
|
||||
}
|
||||
@{{ container_engine }} --version
|
||||
@echo "Container environment looks good."
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Containers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Build one immutable local image identified by Git tag or commit SHA.
|
||||
[group('container')]
|
||||
build:
|
||||
{{ container_engine }} build \
|
||||
--pull \
|
||||
--tag {{ image_ref }} \
|
||||
.
|
||||
|
||||
# Push the immutable image to every configured registry.
|
||||
[group('container')]
|
||||
push: build
|
||||
@test -n "{{ registries }}" || { \
|
||||
echo "Set REGISTRIES before pushing"; \
|
||||
exit 1; \
|
||||
}
|
||||
@for registry in {{ registries }}; do \
|
||||
target="$registry/{{ image_ref }}"; \
|
||||
echo "Pushing $target"; \
|
||||
{{ container_engine }} tag {{ image_ref }} "$target"; \
|
||||
{{ container_engine }} push "$target"; \
|
||||
done
|
||||
Reference in New Issue
Block a user