Browse Source

Merge branch 'Issue#162' of ssh://onedev.gitcitadel.eu:6611/Alexandria/gc-alexandria into Issue#162

master
Silberengel 11 months ago
parent
commit
e095af8c03
  1. 6
      src/routes/about/+page.svelte
  2. 16
      vite.config.ts

6
src/routes/about/+page.svelte

@ -2,14 +2,14 @@ @@ -2,14 +2,14 @@
import { Heading, Img, P, A } from "flowbite-svelte";
// Get the git tag version from environment variables
const gitTagVersion = import.meta.env.GIT_TAG || 'development';
const appVersion = import.meta.env.APP_VERSION || 'development';
</script>
<div class='w-full flex justify-center'>
<main class='main-leather flex flex-col space-y-6 max-w-2xl w-full my-6 px-4'>
<div class="flex justify-between items-center">
<Heading tag='h1' class='h-leather text-left mb-4'>About</Heading>
<span class="text-sm bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">Version: {gitTagVersion}</span>
<Heading tag='h1' class='h-leather mb-2'>About</Heading>
<span class="text-sm bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded text-nowrap">Version: {appVersion}</span>
</div>
<P class="mb-3">

16
vite.config.ts

@ -3,14 +3,20 @@ import { defineConfig } from "vite"; @@ -3,14 +3,20 @@ import { defineConfig } from "vite";
import { execSync } from "child_process";
// Function to get the latest git tag
function getLatestGitTag() {
function getAppVersionString() {
// if running in ci context, we can assume the package has been properly versioned
if (process.env.ALEXANDIRA_IS_CI_BUILD) {
return process.env.npm_package_version;
}
try {
// Get the latest git tag
// Get the latest git tag, assuming git is installed and tagged branch is available
const tag = execSync('git describe --tags --abbrev=0').toString().trim();
return tag;
} catch (error) {
console.error("Failed to get git tag:", error);
return "unknown";
// Fallback to package version
return process.env.npm_package_version;
}
}
@ -26,7 +32,7 @@ export default defineConfig({ @@ -26,7 +32,7 @@ export default defineConfig({
include: ['./tests/unit/**/*.unit-test.js']
},
define: {
// Expose the git tag as a global variable
'import.meta.env.GIT_TAG': JSON.stringify(getLatestGitTag())
// Expose the app version as a global variable
'import.meta.env.APP_VERSION': JSON.stringify(getAppVersionString())
}
});

Loading…
Cancel
Save