feat: show live build version in web UI
Build & Push Docker Image / build (push) Successful in 2m36s
Build & Push Docker Image / build (push) Successful in 2m36s
- /api/version returns version, commitSha, buildDate, trashRetentionDays - CI passes COMMIT_SHA (full), BUILD_DATE and VERSION (git tag) as docker build args; Dockerfile bakes them as env - sidebar footer shows version/sha linked to the Gitea commit - admin System tab shows version, commit link, build date, trash retention
This commit is contained in:
@@ -9,6 +9,15 @@ export interface HealthStatus {
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface VersionInfo {
|
||||
version: string;
|
||||
/** @nullable */
|
||||
commitSha?: string | null;
|
||||
/** @nullable */
|
||||
buildDate?: string | null;
|
||||
trashRetentionDays?: number;
|
||||
}
|
||||
|
||||
export type AuthModeMode = typeof AuthModeMode[keyof typeof AuthModeMode];
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ import type {
|
||||
TrashToolsInput,
|
||||
User,
|
||||
UserCreateInput,
|
||||
UserRoleUpdate
|
||||
UserRoleUpdate,
|
||||
VersionInfo
|
||||
} from './api.schemas';
|
||||
|
||||
import { customFetch } from '../custom-fetch';
|
||||
@@ -140,6 +141,84 @@ export function useHealthCheck<TData = Awaited<ReturnType<typeof healthCheck>>,
|
||||
|
||||
|
||||
|
||||
export const getGetVersionUrl = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
return `/api/version`
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the running build version, commit SHA and build date
|
||||
* @summary Build version information
|
||||
*/
|
||||
export const getVersion = async ( options?: RequestInit): Promise<VersionInfo> => {
|
||||
|
||||
return customFetch<VersionInfo>(getGetVersionUrl(),
|
||||
{
|
||||
...options,
|
||||
method: 'GET'
|
||||
|
||||
|
||||
}
|
||||
);}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const getGetVersionQueryKey = () => {
|
||||
return [
|
||||
`/api/version`
|
||||
] as const;
|
||||
}
|
||||
|
||||
|
||||
export const getGetVersionQueryOptions = <TData = Awaited<ReturnType<typeof getVersion>>, TError = ErrorType<unknown>>( options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getVersion>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
||||
) => {
|
||||
|
||||
const {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryKey = queryOptions?.queryKey ?? getGetVersionQueryKey();
|
||||
|
||||
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getVersion>>> = ({ signal }) => getVersion({ signal, ...requestOptions });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getVersion>>, TError, TData> & { queryKey: QueryKey }
|
||||
}
|
||||
|
||||
export type GetVersionQueryResult = NonNullable<Awaited<ReturnType<typeof getVersion>>>
|
||||
export type GetVersionQueryError = ErrorType<unknown>
|
||||
|
||||
|
||||
/**
|
||||
* @summary Build version information
|
||||
*/
|
||||
|
||||
export function useGetVersion<TData = Awaited<ReturnType<typeof getVersion>>, TError = ErrorType<unknown>>(
|
||||
options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getVersion>>, TError, TData>, request?: SecondParameter<typeof customFetch>}
|
||||
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
|
||||
const queryOptions = getGetVersionQueryOptions(options)
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
||||
|
||||
return { ...query, queryKey: queryOptions.queryKey };
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const getListToolsUrl = (params?: ListToolsParams,) => {
|
||||
const normalizedParams = new URLSearchParams();
|
||||
|
||||
|
||||
@@ -37,6 +37,20 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/HealthStatus"
|
||||
|
||||
/version:
|
||||
get:
|
||||
operationId: getVersion
|
||||
tags: [health]
|
||||
summary: Build version information
|
||||
description: Returns the running build version, commit SHA and build date
|
||||
responses:
|
||||
"200":
|
||||
description: Version information
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/VersionInfo"
|
||||
|
||||
/tools:
|
||||
get:
|
||||
operationId: listTools
|
||||
@@ -660,6 +674,19 @@ components:
|
||||
required:
|
||||
- status
|
||||
|
||||
VersionInfo:
|
||||
type: object
|
||||
required: [version]
|
||||
properties:
|
||||
version:
|
||||
type: string
|
||||
commitSha:
|
||||
type: ["string", "null"]
|
||||
buildDate:
|
||||
type: ["string", "null"]
|
||||
trashRetentionDays:
|
||||
type: integer
|
||||
|
||||
AuthMode:
|
||||
type: object
|
||||
required: [mode]
|
||||
|
||||
@@ -17,6 +17,18 @@ export const HealthCheckResponse = zod.object({
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* Returns the running build version, commit SHA and build date
|
||||
* @summary Build version information
|
||||
*/
|
||||
export const GetVersionResponse = zod.object({
|
||||
"version": zod.string(),
|
||||
"commitSha": zod.string().nullish(),
|
||||
"buildDate": zod.string().nullish(),
|
||||
"trashRetentionDays": zod.number().optional()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @summary List all tools
|
||||
*/
|
||||
|
||||
@@ -46,3 +46,4 @@ export * from './userRoleUpdate';
|
||||
export * from './userRoleUpdateRole';
|
||||
export * from './userRoleUpdateTier';
|
||||
export * from './userTier';
|
||||
export * from './versionInfo';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Generated by orval v8.9.1 🍺
|
||||
* Do not edit manually.
|
||||
* Api
|
||||
* ToolRate API — Tool listing and rating platform
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface VersionInfo {
|
||||
version: string;
|
||||
/** @nullable */
|
||||
commitSha?: string | null;
|
||||
/** @nullable */
|
||||
buildDate?: string | null;
|
||||
trashRetentionDays?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user