gitscope
← marzneshin / Diff · c9419fe → c9419fe
Changes c9419fe..c9419fe
Patch commit
diff --git a/.github/workflows/dashboard-ci.yml b/.github/workflows/dashboard-ci.yml
index 1ef2dab..a898726 100644
--- a/.github/workflows/dashboard-ci.yml
+++ b/.github/workflows/dashboard-ci.yml
@@ -55,6 +55,8 @@ jobs:
working-directory: ./dashboard
steps:
- uses: actions/checkout@v4
+ with:
+ fetch-depth: '0'
- uses: pnpm/action-setup@v3
name: Install pnpm
@@ -77,6 +79,21 @@ jobs:
- name: 📥 Install deps
run: pnpm install
+ - name: Set Git version for PRs
+ if: github.event_name == 'pull_request'
+ id: get_version
+ run: |
+ LATEST_TAG=${{ github.ref_name }}
+ LATEST_COMMIT=${{ github.sha }}
+ echo "VITE_LATEST_APP_VERSION=${LATEST_TAG}-${LATEST_COMMIT:0:7}" >> $GITHUB_ENV
+
+ - name: Set Git version for main branch
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
+ id: get_version
+ run: |
+ LATEST_TAG=${{ github.ref_name }}
+ echo "VITE_LATEST_APP_VERSION=${LATEST_TAG}" >> $GITHUB_ENV
+
- name: Build Dashboard
run: pnpm build --base '/dashboard/'
diff --git a/Dockerfile b/Dockerfile
index 62a18cd..e9511cd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,7 +7,7 @@ WORKDIR /app
COPY . /app
RUN apt-get update -y \
- && apt-get install make gcc g++ python3-dev -y --no-install-recommends \
+ && apt-get install make git gcc g++ python3-dev -y --no-install-recommends \
&& pip install --no-cache-dir -r /app/requirements.txt \
&& apt-get clean -y \
&& apt-get remove g++ gcc python3-dev -y \
diff --git a/dashboard/src/components/page/index.tsx b/dashboard/src/components/page/index.tsx
index cabbeae..383e2fd 100644
--- a/dashboard/src/components/page/index.tsx
+++ b/dashboard/src/components/page/index.tsx
@@ -10,7 +10,7 @@ interface PageProps extends PropsWithChildren { }
export const Page: FC<PageProps> = ({ children }) => {
return (
- <ScrollArea style={{ height: `calc(100vh - 4.8rem)` }} className="sm:w-screen md:p-3 md:w-[100%]">
+ <ScrollArea style={{ height: `calc(100vh - 5rem)` }} className="sm:w-screen md:p-3 md:w-[100%]">
<div className="flex flex-col justify-center items-center h-full sm:w-screen md:w-[100%]">
{children}
</div>
diff --git a/dashboard/src/features/footer/index.tsx b/dashboard/src/features/footer/index.tsx
index d73adbe..0df1006 100644
--- a/dashboard/src/features/footer/index.tsx
+++ b/dashboard/src/features/footer/index.tsx
@@ -1,9 +1,11 @@
-import packageJson from '@marzneshin/../package.json' assert { type: 'json' };
+import { Badge } from "@marzneshin/components";
export const DashboardFooter = () => {
return (
<div className="size-full flex justify-center items-center dark:text-neutral-300 text-neutral-800">
- v{packageJson.version} Marzneshin
+ <Badge >
+ {import.meta.env.VITE_LATEST_APP_VERSION} Marzneshin
+ </Badge>
</div>
)
}
diff --git a/dashboard/vite.config.ts b/dashboard/vite.config.ts
index 5814d73..9b882d7 100644
--- a/dashboard/vite.config.ts
+++ b/dashboard/vite.config.ts
@@ -3,25 +3,43 @@ import react from '@vitejs/plugin-react-swc'
import { TanStackRouterVite } from '@tanstack/router-vite-plugin';
import tsconfigPaths from 'vite-tsconfig-paths';
import path from 'path';
+import { execSync } from 'child_process';
-// https://vitejs.dev/config/
-export default defineConfig({
- plugins: [
- TanStackRouterVite(),
- tsconfigPaths(),
- react()
- ],
- root: '.',
- build: {
- assetsDir: 'static',
- outDir: 'dist'
- },
- resolve: {
- alias: [
- {
- find: '@marzneshin',
- replacement: path.resolve(__dirname, './src/'),
- },
+export default defineConfig(({ mode }) => {
+ const dev = mode === "development";
+
+ let latestVersion = process.env.VITE_LATEST_APP_VERSION;
+
+ if (!latestVersion) {
+ try {
+ latestVersion = dev ?
+ execSync("/usr/bin/git describe --tags").toString().trimEnd() :
+ execSync("/usr/bin/git describe --tags --abbrev=0").toString().trimEnd();
+ } catch (e) {
+ console.error("Git versioning failed:", e);
+ latestVersion = "unknown";
+ }
+ process.env.VITE_LATEST_APP_VERSION = latestVersion;
+ }
+
+ return {
+ plugins: [
+ TanStackRouterVite(),
+ tsconfigPaths(),
+ react()
],
- },
+ root: '.',
+ build: {
+ assetsDir: 'static',
+ outDir: 'dist'
+ },
+ resolve: {
+ alias: [
+ {
+ find: '@marzneshin',
+ replacement: path.resolve(__dirname, './src/'),
+ },
+ ],
+ },
+ }
})