diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 5f1efd9..903e626 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -218,6 +218,7 @@ jobs: build-args: | BUILD_VERSION=${{ steps.meta.outputs.version }} BUILD_COMMIT=${{ gitea.sha }} + BUILD_TIME=${{ gitea.event.head_commit.timestamp }} cache-from: type=registry,ref=${{ secrets.DOCKER_USER }}/libnovel-ui:latest cache-to: type=inline diff --git a/ui/Dockerfile b/ui/Dockerfile index 582885c..36e29a8 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -14,10 +14,12 @@ COPY . . # Build-time version info — injected by docker-compose or CI via --build-arg. ARG BUILD_VERSION=dev ARG BUILD_COMMIT=unknown +ARG BUILD_TIME=unknown # Expose as PUBLIC_ env vars so SvelteKit's $env/dynamic/public can read them. ENV PUBLIC_BUILD_VERSION=$BUILD_VERSION ENV PUBLIC_BUILD_COMMIT=$BUILD_COMMIT +ENV PUBLIC_BUILD_TIME=$BUILD_TIME RUN npm run build @@ -40,5 +42,16 @@ ENV NODE_ENV=production ENV PORT=3000 ENV HOST=0.0.0.0 +# Carry build-time metadata into the runtime image so the UI footer can +# display the version, commit SHA, and build timestamp. +# These must be re-declared after the second FROM — ARG values do not +# cross stage boundaries, but ENV values set here persist at runtime. +ARG BUILD_VERSION=dev +ARG BUILD_COMMIT=unknown +ARG BUILD_TIME=unknown +ENV PUBLIC_BUILD_VERSION=$BUILD_VERSION +ENV PUBLIC_BUILD_COMMIT=$BUILD_COMMIT +ENV PUBLIC_BUILD_TIME=$BUILD_TIME + EXPOSE $PORT CMD ["node", "build"] diff --git a/ui/src/routes/+layout.svelte b/ui/src/routes/+layout.svelte index c9a45c6..db4231e 100644 --- a/ui/src/routes/+layout.svelte +++ b/ui/src/routes/+layout.svelte @@ -433,7 +433,15 @@ DMCA © {new Date().getFullYear()} libnovel - + + {#snippet buildTime()} + {#if env.PUBLIC_BUILD_TIME && env.PUBLIC_BUILD_TIME !== 'unknown'} + {@const d = new Date(env.PUBLIC_BUILD_TIME)} + + · {d.toUTCString().replace(' GMT', ' UTC').replace(/:\d\d /, ' ')} + + {/if} + {/snippet}
{#if env.PUBLIC_BUILD_VERSION && env.PUBLIC_BUILD_VERSION !== 'dev'} {env.PUBLIC_BUILD_VERSION} @@ -442,6 +450,7 @@ >+{env.PUBLIC_BUILD_COMMIT.slice(0, 7)} {/if} + {@render buildTime()} {:else} dev {/if}