feat: implement version UI and short-sha CI versioning

This commit is contained in:
neon
2026-05-13 21:59:15 +00:00
parent 4fb157cc3b
commit f9c1e29911
25 changed files with 1107 additions and 63 deletions
+16 -8
View File
@@ -82,6 +82,7 @@ jobs:
packages: read
outputs:
source_sha: ${{ steps.ctx.outputs.source_sha }}
source_sha_short: ${{ steps.ctx.outputs.source_sha_short }}
update_main: ${{ steps.ctx.outputs.update_main }}
skip_build: ${{ steps.ctx.outputs.skip_build }}
steps:
@@ -108,14 +109,20 @@ jobs:
SOURCE_SHA="$GH_SHA"
echo "update_main=false" >> "$GITHUB_OUTPUT"
fi
SOURCE_SHA_SHORT="${SOURCE_SHA:0:12}"
echo "source_sha=${SOURCE_SHA}" >> "$GITHUB_OUTPUT"
echo "source_sha_short=${SOURCE_SHA_SHORT}" >> "$GITHUB_OUTPUT"
IMAGE_LOWER=$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
HTTP_STATUS_SHORT=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.oci.image.index.v1+json" \
"https://ghcr.io/v2/${IMAGE_LOWER}/manifests/sha-${SOURCE_SHA_SHORT}")
HTTP_STATUS_FULL=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.oci.image.index.v1+json" \
"https://ghcr.io/v2/${IMAGE_LOWER}/manifests/sha-${SOURCE_SHA}")
if [[ "$HTTP_STATUS" == "200" && "${FORCE_REBUILD}" != "true" ]]; then
echo "Image sha-${SOURCE_SHA} already exists in GHCR, skipping rebuild."
if [[ ("$HTTP_STATUS_SHORT" == "200" || "$HTTP_STATUS_FULL" == "200") && "${FORCE_REBUILD}" != "true" ]]; then
echo "Image sha-${SOURCE_SHA_SHORT} already exists in GHCR, skipping rebuild."
echo "skip_build=true" >> "$GITHUB_OUTPUT"
else
echo "skip_build=false" >> "$GITHUB_OUTPUT"
@@ -159,6 +166,7 @@ jobs:
file: ./Dockerfile
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
platforms: linux/amd64
build-args: APP_VERSION=sha-${{ needs.prepare.outputs.source_sha_short }}
cache-from: type=gha,scope=container-image-yml-amd64
cache-to: type=gha,mode=max,scope=container-image-yml-amd64
@@ -212,6 +220,7 @@ jobs:
file: ./Dockerfile
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
platforms: linux/arm64
build-args: APP_VERSION=sha-${{ needs.prepare.outputs.source_sha_short }}
cache-from: type=gha,scope=container-image-yml-arm64
cache-to: type=gha,mode=max,scope=container-image-yml-arm64
@@ -255,13 +264,13 @@ jobs:
env:
REGISTRY: ${{ env.REGISTRY }}
IMAGE: ${{ env.IMAGE_NAME }}
SHA: ${{ needs.prepare.outputs.source_sha }}
SHA_SHORT: ${{ needs.prepare.outputs.source_sha_short }}
AMD64_DIGEST: ${{ needs.build-amd64.outputs.digest }}
ARM64_DIGEST: ${{ needs.build-arm64.outputs.digest }}
run: |
FULL_IMAGE="${REGISTRY}/${IMAGE}"
docker buildx imagetools create \
--tag "${FULL_IMAGE}:sha-${SHA}" \
--tag "${FULL_IMAGE}:sha-${SHA_SHORT}" \
"${FULL_IMAGE}@${AMD64_DIGEST}" \
"${FULL_IMAGE}@${ARM64_DIGEST}"
@@ -271,7 +280,6 @@ jobs:
env:
REGISTRY: ${{ env.REGISTRY }}
IMAGE: ${{ env.IMAGE_NAME }}
SHA: ${{ needs.prepare.outputs.source_sha }}
AMD64_DIGEST: ${{ needs.build-amd64.outputs.digest }}
ARM64_DIGEST: ${{ needs.build-arm64.outputs.digest }}
run: |
@@ -286,5 +294,5 @@ jobs:
env:
REGISTRY: ${{ env.REGISTRY }}
IMAGE: ${{ env.IMAGE_NAME }}
SHA: ${{ needs.prepare.outputs.source_sha }}
run: docker buildx imagetools inspect "${REGISTRY}/${IMAGE}:sha-${SHA}"
SHA_SHORT: ${{ needs.prepare.outputs.source_sha_short }}
run: docker buildx imagetools inspect "${REGISTRY}/${IMAGE}:sha-${SHA_SHORT}"