diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9e3eebf..47540f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,3 +83,5 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | OCULAR_GENESIS_HOST=${{ env.OCULAR_GENESIS_HOST }} + OCULAR_BUILD_VERSION=${{ github.ref_name }} + OCULAR_BUILD_SHA=${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index 0508ff5..6306851 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ FROM --platform=$BUILDPLATFORM node:20-alpine AS build ARG OCULAR_GENESIS_HOST +ARG OCULAR_BUILD_VERSION +ARG OCULAR_BUILD_SHA ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" +ENV OCULAR_BUILD_VERSION=${OCULAR_BUILD_VERSION} +ENV OCULAR_BUILD_SHA=${OCULAR_BUILD_SHA} + RUN npx pnpm install --global pnpm@8 WORKDIR /app diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 3d9aa96..5695758 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -31,8 +31,8 @@ interface ImportMetaEnv { // Build information readonly OCULAR_BUILD_TIMESTAMP: number; - readonly OCULAR_BUILD_SHA: string; - readonly OCULAR_BUILD_VERSION: string; + readonly OCULAR_BUILD_VERSION?: string; + readonly OCULAR_BUILD_SHA?: string; } interface ImportMeta { diff --git a/vite.config.ts b/vite.config.ts index fe11593..1229b3d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -18,11 +18,7 @@ export default defineConfig({ } }, define: { - 'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now(), - 'import.meta.env.OCULAR_BUILD_SHA': JSON.stringify(execSync('git rev-parse --short HEAD').toString().trim()), - 'import.meta.env.OCULAR_BUILD_VERSION': JSON.stringify( - execSync('git describe --tags --always --abbrev=0').toString().trim() - ) + 'import.meta.env.OCULAR_BUILD_TIMESTAMP': Date.now() }, plugins: [ tsconfigPaths({ loose: true }),