feat(versioning): show runtime version and git hash in app footers
This commit is contained in:
@@ -4,6 +4,7 @@ import type { ReactNode } from "react"
|
||||
|
||||
import { LogoutButton } from "@/app/logout-button"
|
||||
import { AdminLocaleSwitcher } from "@/components/admin-locale-switcher"
|
||||
import { getBuildInfo } from "@/lib/build-info"
|
||||
|
||||
type AdminShellProps = {
|
||||
role: Role
|
||||
@@ -57,6 +58,8 @@ export function AdminShell({
|
||||
actions,
|
||||
children,
|
||||
}: AdminShellProps) {
|
||||
const buildInfo = getBuildInfo()
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex min-h-screen w-full max-w-7xl gap-8 px-6 py-10">
|
||||
<aside className="sticky top-0 hidden h-fit w-64 shrink-0 space-y-4 lg:block">
|
||||
@@ -111,6 +114,10 @@ export function AdminShell({
|
||||
</header>
|
||||
|
||||
{children}
|
||||
|
||||
<footer className="border-t border-neutral-200 pt-4 text-xs text-neutral-500">
|
||||
Build v{buildInfo.version} +sha.{buildInfo.sha}
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
21
apps/admin/src/lib/build-info.ts
Normal file
21
apps/admin/src/lib/build-info.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
const FALLBACK_VERSION = "0.0.1-dev"
|
||||
const FALLBACK_SHA = "local"
|
||||
|
||||
function shortenSha(input: string): string {
|
||||
const value = input.trim()
|
||||
if (!value) {
|
||||
return FALLBACK_SHA
|
||||
}
|
||||
|
||||
return value.slice(0, 7)
|
||||
}
|
||||
|
||||
export function getBuildInfo() {
|
||||
const version = process.env.NEXT_PUBLIC_APP_VERSION?.trim() || FALLBACK_VERSION
|
||||
const sha = shortenSha(process.env.NEXT_PUBLIC_GIT_SHA ?? "")
|
||||
|
||||
return {
|
||||
version,
|
||||
sha,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user