From 7e26a31d40341956d317560aa49909f446e39b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ri=C3=9Fe?= Date: Sat, 2 Nov 2024 15:00:59 +0000 Subject: [PATCH] Fix Forgejo version in published OCI images (#51) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Forgejo version is derived from the git history, so the image build needs to happen in the context of a full repository clone. Also, the post-processing of the version string needs to remove the second occurrence of "-g", as the first one is now part of the added "-git-annex" part. Reviewed-on: https://codeberg.org/forgejo-aneksajo/forgejo-aneksajo/pulls/51 Co-authored-by: Matthias Riße Co-committed-by: Matthias Riße --- .forgejo/workflows/build-oci-image.yml | 4 ++++ Makefile | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/build-oci-image.yml b/.forgejo/workflows/build-oci-image.yml index 9eabdf3eab..8e843b41ee 100644 --- a/.forgejo/workflows/build-oci-image.yml +++ b/.forgejo/workflows/build-oci-image.yml @@ -12,6 +12,9 @@ jobs: matrix: type: ["rootful", "rootless"] steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch the full history so that the Forgejo version is determined properly - name: Determine registry and username id: determine-registry-and-username run: | @@ -32,6 +35,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: + context: . file: ${{ (matrix.type == 'rootful' && 'Dockerfile') || (matrix.type == 'rootless' && 'Dockerfile.rootless') }} push: true tags: ${{ steps.determine-registry-and-username.outputs.registry }}/${{ github.repository }}:${{ github.ref_name }}${{ (matrix.type == 'rootful' && ' ') || (matrix.type == 'rootless' && '-rootless') }} diff --git a/Makefile b/Makefile index a74ff55202..5cf50bbc20 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ else FORGEJO_VERSION_API ?= $(GITEA_VERSION)+${GITEA_COMPATIBILITY} else # drop the "g" prefix prepended by git describe to the commit hash - FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//' | sed 's/\-g/-/')+${GITEA_COMPATIBILITY} + FORGEJO_VERSION ?= $(shell git describe --exclude '*-test' --tags --always | sed 's/^v//' | sed 's/\-g/-/2')+${GITEA_COMPATIBILITY} endif endif FORGEJO_VERSION_MAJOR=$(shell echo $(FORGEJO_VERSION) | sed -e 's/\..*//')