Copy justfile from other repo and split up into common, containers, and python tasks

This commit is contained in:
2026-08-23 22:48:31 -05:00
parent b31e43f5b4
commit 926293c316
3 changed files with 231 additions and 0 deletions
+83
View File
@@ -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