2023-11-29 18:01:01 +01:00
|
|
|
#!/bin/sh -eu
|
|
|
|
|
|
|
|
|
|
: "${DOCKER_BIN:=docker}"
|
|
|
|
|
|
|
|
|
|
cd "$RUN_DIR"
|
|
|
|
|
|
|
|
|
|
builddir=build
|
|
|
|
|
|
2024-05-10 17:01:18 +02:00
|
|
|
_latest_python_version() {
|
|
|
|
|
filter="$1"
|
|
|
|
|
filter_regex=$(echo "$filter" | sed 's/\./\\\\./')
|
|
|
|
|
curl -sfL https://api.github.com/repos/python/cpython/git/refs/tags \
|
|
|
|
|
| jq -r 'map(select(.ref | test("^refs/tags/v?'"$filter_regex"'($|\\.)")) | .ref | match("refs/tags/v?(.*)").captures[0].string)[]' \
|
|
|
|
|
| grep -xE '[.0-9]+' \
|
|
|
|
|
| sort --version-sort \
|
|
|
|
|
| tail -n 1
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 18:01:01 +01:00
|
|
|
[ -z "${DEBUG:-}" ] || set -x
|
|
|
|
|
|
|
|
|
|
mkdir -p "$builddir"
|
|
|
|
|
|
2024-05-10 17:01:18 +02:00
|
|
|
python_version_filter=$(cat .python-version)
|
|
|
|
|
python_version=$(_latest_python_version "$python_version_filter")
|
|
|
|
|
|
|
|
|
|
if [ -z "$python_version" ]; then
|
|
|
|
|
echo >&2 "No Python version found matching the filter: $python_version_filter"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
githash_short=$(git rev-parse --short HEAD)
|
|
|
|
|
githash_long=$(git rev-parse HEAD)
|
|
|
|
|
version="$githash_short"
|
|
|
|
|
echo "$version" >"$builddir"/version
|
|
|
|
|
|
2025-05-15 21:56:57 +02:00
|
|
|
uv export \
|
|
|
|
|
--frozen \
|
|
|
|
|
--format=requirements.txt \
|
|
|
|
|
--no-dev \
|
|
|
|
|
--no-emit-project \
|
|
|
|
|
>"$builddir"/requirements.txt
|
2023-11-29 18:01:01 +01:00
|
|
|
|
|
|
|
|
$DOCKER_BIN build \
|
|
|
|
|
--pull \
|
2024-05-10 17:01:18 +02:00
|
|
|
--build-arg="PYTHON_VERSION=$python_version" \
|
|
|
|
|
--label="python.version=$python_version" \
|
|
|
|
|
--label="git.hash=$githash_long" \
|
|
|
|
|
--tag="code.dumpr.org/ducklet/unwind":"$version" \
|
2023-11-29 18:01:01 +01:00
|
|
|
.
|