From 3d394ddbab856a81f41da53500ca87bdb1900c2b Mon Sep 17 00:00:00 2001 From: abel <67806187+theo-abel@users.noreply.github.com> Date: Tue, 10 Mar 2026 12:33:33 +0100 Subject: [PATCH] build(makefile): fix build-modules version parsing and image tag Use grep -m1 with '^version\s*=' and improved sed to extract and trim package versions. Default to 0.0.1 when no version is found. Introduce SDK_IMG so BASE_IMG_PREFIX is applied to the SDK image tag and use it as the --build-arg BASE_IMAGE for module builds. Skip the SDK directory and the module template directory when iterating modules. --- Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9368534..cf70228 100644 --- a/Makefile +++ b/Makefile @@ -83,22 +83,25 @@ build-modules: BASE_IMG_PREFIX=""; \ fi; \ SDK_DIR="fuzzforge-modules/fuzzforge-modules-sdk/"; \ - SDK_VERSION=$$(grep 'version' "$${SDK_DIR}pyproject.toml" 2>/dev/null | head -1 | sed 's/version = //;s/"//g' || echo "0.0.1"); \ + SDK_VERSION=$$(grep -m1 '^version\s*=' "$${SDK_DIR}pyproject.toml" 2>/dev/null | sed 's/^version\s*=\s*//;s/"//g;s/\s*$$//' ); \ + [ -n "$$SDK_VERSION" ] || SDK_VERSION="0.0.1"; \ echo "Building wheels for fuzzforge-modules-sdk..."; \ (cd "$$SDK_DIR" && uv build --wheel --out-dir .wheels) || exit 1; \ - echo "Building fuzzforge-modules-sdk:$$SDK_VERSION..."; \ - $$CONTAINER_CMD build -t "fuzzforge-modules-sdk:$$SDK_VERSION" "$$SDK_DIR" || exit 1; \ + SDK_IMG="$${BASE_IMG_PREFIX}fuzzforge-modules-sdk:$$SDK_VERSION"; \ + echo "Building $$SDK_IMG..."; \ + $$CONTAINER_CMD build -t "$$SDK_IMG" "$$SDK_DIR" || exit 1; \ for module in fuzzforge-modules/*/; do \ - [ "$$module" = "$$SDK_DIR" ] || [ ! -f "$$module/Dockerfile" ] && continue; \ + if [ "$$module" = "$$SDK_DIR" ] || [ "$$module" = "fuzzforge-modules/fuzzforge-module-template/" ] || [ ! -f "$$module/Dockerfile" ]; then continue; fi; \ name=$$(basename $$module); \ - version=$$(grep 'version' "$$module/pyproject.toml" 2>/dev/null | head -1 | sed 's/version = //;s/"//g'); \ + version=$$(grep -m1 '^version\s*=' "$$module/pyproject.toml" 2>/dev/null | sed 's/^version\s*=\s*//;s/"//g;s/\s*$$//'); \ + [ -n "$$version" ] || version="0.0.1"; \ case $$name in \ fuzzforge-*) tag="$$name:$$version" ;; \ *) tag="fuzzforge-$$name:$$version" ;; \ esac; \ echo "Building $$tag..."; \ $$CONTAINER_CMD build \ - --build-arg BASE_IMAGE="$${BASE_IMG_PREFIX}fuzzforge-modules-sdk:$$SDK_VERSION" \ + --build-arg BASE_IMAGE="$$SDK_IMG" \ -t "$$tag" "$$module" || exit 1; \ done @echo ""