From 2ee10774a0271607053fedf79a60fb452734de4d Mon Sep 17 00:00:00 2001 From: "Brandon T. Kowalski" Date: Thu, 26 Mar 2026 19:25:00 -0400 Subject: [PATCH] fix: inject version from CI instead of reading pak.json Pass GROUT_VERSION build arg from the release workflow into Docker builds so beta releases get the correct version number. Falls back to pak.json for local dev builds when the arg is not set. --- .github/workflows/release.yml | 8 ++++++++ docker/32.Dockerfile | 4 +++- docker/Dockerfile | 4 +++- docker/Dockerfile.miyoo-full | 4 +++- taskfile.yml | 13 +++++++------ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5326144..dcb9e75 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,6 +86,8 @@ jobs: - name: Build ARM64 run: task build extract + env: + GROUT_VERSION: ${{ needs.prepare.outputs.version }} - name: Package ARM64 platforms run: task package-next package-muos package-knulli package-spruce package-rocknix package-trimui package-minui package-batocera @@ -135,6 +137,8 @@ jobs: - name: Build AMD64 run: task build-amd64 extract-amd64 + env: + GROUT_VERSION: ${{ needs.prepare.outputs.version }} - name: Package Batocera AMD64 run: task package-batocera-amd64 @@ -172,6 +176,8 @@ jobs: - name: Build x86 run: task build-x86 extract-x86 + env: + GROUT_VERSION: ${{ needs.prepare.outputs.version }} - name: Package Batocera x86 run: task package-batocera-x86 @@ -209,6 +215,8 @@ jobs: - name: Build ARM32 run: task build-32 extract-32 + env: + GROUT_VERSION: ${{ needs.prepare.outputs.version }} - name: Package ARM32 platforms run: task package-allium package-onion package-minui-arm32 diff --git a/docker/32.Dockerfile b/docker/32.Dockerfile index a45f89b..ca6ce1c 100644 --- a/docker/32.Dockerfile +++ b/docker/32.Dockerfile @@ -41,6 +41,7 @@ RUN if [ "$USE_LOCAL_GABAGOOL" = "true" ]; then \ fi ARG GITHUB_ACTIONS=false +ARG GROUT_VERSION="" # Build for ARM32 (Miyoo Mini Plus) # Note: When using --platform=linux/arm/v7, Go automatically targets ARM32 @@ -48,7 +49,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ BUILD_TYPE="Dev"; \ if [ "$GITHUB_ACTIONS" = "true" ]; then BUILD_TYPE="Release"; fi; \ - VERSION=$(jq -r '.version // "dev"' pak.json 2>/dev/null || echo "dev"); \ + if [ -n "$GROUT_VERSION" ]; then VERSION="$GROUT_VERSION"; \ + else VERSION=$(jq -r '.version // "dev"' pak.json 2>/dev/null || echo "dev"); fi; \ GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \ BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ); \ LDFLAGS="-X 'grout/version.Version=$VERSION' \ diff --git a/docker/Dockerfile b/docker/Dockerfile index 1feba4e..218d7d3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -41,12 +41,14 @@ RUN if [ "$USE_LOCAL_GABAGOOL" = "true" ]; then \ fi ARG GITHUB_ACTIONS=false +ARG GROUT_VERSION="" RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg/mod \ BUILD_TYPE="Dev"; \ if [ "$GITHUB_ACTIONS" = "true" ]; then BUILD_TYPE="Release"; fi; \ - VERSION=$(jq -r '.version // "dev"' pak.json 2>/dev/null || echo "dev"); \ + if [ -n "$GROUT_VERSION" ]; then VERSION="$GROUT_VERSION"; \ + else VERSION=$(jq -r '.version // "dev"' pak.json 2>/dev/null || echo "dev"); fi; \ GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \ BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ); \ LDFLAGS="-X 'grout/version.Version=$VERSION' \ diff --git a/docker/Dockerfile.miyoo-full b/docker/Dockerfile.miyoo-full index 95f8e5b..abb72a3 100644 --- a/docker/Dockerfile.miyoo-full +++ b/docker/Dockerfile.miyoo-full @@ -162,11 +162,13 @@ RUN if [ "$USE_LOCAL_GABAGOOL" = "true" ]; then \ fi ARG GITHUB_ACTIONS=false +ARG GROUT_VERSION="" # Cross-compile grout for ARM32 with CGO using Miyoo toolchain RUN BUILD_TYPE="Dev"; \ if [ "$GITHUB_ACTIONS" = "true" ]; then BUILD_TYPE="Release"; fi; \ - VERSION=$(jq -r '.version // "dev"' pak.json 2>/dev/null || echo "dev"); \ + if [ -n "$GROUT_VERSION" ]; then VERSION="$GROUT_VERSION"; \ + else VERSION=$(jq -r '.version // "dev"' pak.json 2>/dev/null || echo "dev"); fi; \ GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \ BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ); \ LDFLAGS="-X 'grout/version.Version=$VERSION' \ diff --git a/taskfile.yml b/taskfile.yml index 09d7da7..ec546d8 100644 --- a/taskfile.yml +++ b/taskfile.yml @@ -5,6 +5,7 @@ vars: CONTAINER_NAME: grout-extract LABEL: app.romm.grout.build=true NO_CACHE: "" + VERSION_ARG: '{{if .GROUT_VERSION}}--build-arg GROUT_VERSION={{.GROUT_VERSION}}{{end}}' tasks: @@ -12,42 +13,42 @@ tasks: desc: Build for ARM64 cmds: - rm -rf build64 - - docker buildx build {{.NO_CACHE}} --platform=linux/arm64 --build-arg GITHUB_ACTIONS=false --label {{.LABEL}} --load -t {{.IMAGE_NAME}} -f docker/Dockerfile . + - docker buildx build {{.NO_CACHE}} --platform=linux/arm64 --build-arg GITHUB_ACTIONS=false {{.VERSION_ARG}} --label {{.LABEL}} --load -t {{.IMAGE_NAME}} -f docker/Dockerfile . silent: true build-amd64: desc: Build for AMD64 (x86_64) cmds: - rm -rf build64 - - docker buildx build {{.NO_CACHE}} --load --platform=linux/amd64 --build-arg GITHUB_ACTIONS=false --label {{.LABEL}} -t {{.IMAGE_NAME}}-amd64 -f docker/Dockerfile . + - docker buildx build {{.NO_CACHE}} --load --platform=linux/amd64 --build-arg GITHUB_ACTIONS=false {{.VERSION_ARG}} --label {{.LABEL}} -t {{.IMAGE_NAME}}-amd64 -f docker/Dockerfile . silent: true build-x86: desc: Build for x86 (32-bit) cmds: - rm -rf buildx86 - - docker buildx build {{.NO_CACHE}} --load --platform=linux/386 --build-arg GITHUB_ACTIONS=false --label {{.LABEL}} -t {{.IMAGE_NAME}}-x86 -f docker/Dockerfile . + - docker buildx build {{.NO_CACHE}} --load --platform=linux/386 --build-arg GITHUB_ACTIONS=false {{.VERSION_ARG}} --label {{.LABEL}} -t {{.IMAGE_NAME}}-x86 -f docker/Dockerfile . silent: true build-32: desc: Build for ARM32 cmds: - rm -rf build32 - - docker buildx build {{.NO_CACHE}} --platform=linux/arm/v7 --build-arg GITHUB_ACTIONS=false --label {{.LABEL}} --load -t {{.IMAGE_NAME}} -f docker/32.Dockerfile . + - docker buildx build {{.NO_CACHE}} --platform=linux/arm/v7 --build-arg GITHUB_ACTIONS=false {{.VERSION_ARG}} --label {{.LABEL}} --load -t {{.IMAGE_NAME}} -f docker/32.Dockerfile . silent: true build-local: desc: Build for ARM64 using local gabagool workspace cmds: - rm -rf build64 - - cd .. && docker buildx build {{.NO_CACHE}} --platform=linux/arm64 --build-arg USE_LOCAL_GABAGOOL=true --build-arg GITHUB_ACTIONS=false --label {{.LABEL}} --load -f grout/docker/Dockerfile -t {{.IMAGE_NAME}} . + - cd .. && docker buildx build {{.NO_CACHE}} --platform=linux/arm64 --build-arg USE_LOCAL_GABAGOOL=true --build-arg GITHUB_ACTIONS=false {{.VERSION_ARG}} --label {{.LABEL}} --load -f grout/docker/Dockerfile -t {{.IMAGE_NAME}} . silent: true build-32-local: desc: Build for ARM32 using local gabagool workspace cmds: - rm -rf build32 - - cd .. && docker buildx build {{.NO_CACHE}} --platform=linux/arm/v7 --build-arg USE_LOCAL_GABAGOOL=true --build-arg GITHUB_ACTIONS=false --label {{.LABEL}} --load -f grout/docker/32.Dockerfile -t {{.IMAGE_NAME}} . + - cd .. && docker buildx build {{.NO_CACHE}} --platform=linux/arm/v7 --build-arg USE_LOCAL_GABAGOOL=true --build-arg GITHUB_ACTIONS=false {{.VERSION_ARG}} --label {{.LABEL}} --load -f grout/docker/32.Dockerfile -t {{.IMAGE_NAME}} . silent: true extract: