From 97189d41f3b9fd148312bc3e3c4a6295ff34fef5 Mon Sep 17 00:00:00 2001
From: Earl Warren <contact@earl-warren.org>
Date: Wed, 17 Apr 2024 16:36:53 +0200
Subject: [PATCH] fix(release): add missing ARG RELEASE_VERSION

The ARG RELEASE_VERSION set in the build-env image does not propagate
to the images that follow. As a result the value of the version label
is always empty.

This should have been caught by the test in the CI but although it
notified the problem in the output, it did not fail. Upgrade to the
forgejo-build-publish version that fixes this false positive.
---
 .forgejo/testdata/build-release/Dockerfile | 2 ++
 .forgejo/workflows/build-release.yml       | 4 ++--
 Dockerfile                                 | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.forgejo/testdata/build-release/Dockerfile b/.forgejo/testdata/build-release/Dockerfile
index 8dccad281c..f798448261 100644
--- a/.forgejo/testdata/build-release/Dockerfile
+++ b/.forgejo/testdata/build-release/Dockerfile
@@ -1,4 +1,6 @@
 FROM code.forgejo.org/oci/alpine:3.19
 ARG RELEASE_VERSION=unkown
+LABEL maintainer="contact@forgejo.org" \
+      org.opencontainers.image.version="${RELEASE_VERSION}"
 RUN mkdir -p /app/gitea
 RUN ( echo '#!/bin/sh' ; echo "echo forgejo v$RELEASE_VERSION" ) > /app/gitea/gitea ; chmod +x /app/gitea/gitea
diff --git a/.forgejo/workflows/build-release.yml b/.forgejo/workflows/build-release.yml
index 4a46ff31a2..eb4297c7ef 100644
--- a/.forgejo/workflows/build-release.yml
+++ b/.forgejo/workflows/build-release.yml
@@ -159,7 +159,7 @@ jobs:
 
       - name: build container & release
         if: ${{ secrets.TOKEN != '' }}
-        uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1
+        uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1.1
         with:
           forgejo: "${{ env.GITHUB_SERVER_URL }}"
           owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
@@ -178,7 +178,7 @@ jobs:
 
       - name: build rootless container
         if: ${{ secrets.TOKEN != '' }}
-        uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1
+        uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1.1
         with:
           forgejo: "${{ env.GITHUB_SERVER_URL }}"
           owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
diff --git a/Dockerfile b/Dockerfile
index 475164481a..3c455a5411 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -52,6 +52,7 @@ RUN chmod 755 /tmp/local/usr/bin/entrypoint \
 RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
 
 FROM docker.io/library/alpine:3.19
+ARG RELEASE_VERSION
 LABEL maintainer="contact@forgejo.org" \
       org.opencontainers.image.authors="Forgejo" \
       org.opencontainers.image.url="https://forgejo.org" \