Browse Source

Changed logic to the sequence:

package version
git tag version
development version -> hidden

closes #162
master
Silberengel 11 months ago
parent
commit
52a353ebe1
  1. 6
      src/routes/about/+page.svelte
  2. 10
      vite.config.ts

6
src/routes/about/+page.svelte

@ -3,13 +3,16 @@
// Get the git tag version from environment variables // Get the git tag version from environment variables
const appVersion = import.meta.env.APP_VERSION || 'development'; const appVersion = import.meta.env.APP_VERSION || 'development';
const isVersionKnown = appVersion !== 'development';
</script> </script>
<div class='w-full flex justify-center'> <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'> <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"> <div class="flex justify-between items-center">
<Heading tag='h1' class='h-leather mb-2'>About</Heading> <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> {#if isVersionKnown}
<span class="text-sm bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded text-nowrap">Version: {appVersion}</span>
{/if}
</div> </div>
<P class="mb-3"> <P class="mb-3">
@ -102,4 +105,3 @@
</main> </main>
</div> </div>

10
vite.config.ts

@ -5,18 +5,16 @@ import { execSync } from "child_process";
// Function to get the latest git tag // Function to get the latest git tag
function getAppVersionString() { function getAppVersionString() {
// if running in ci context, we can assume the package has been properly versioned // if running in ci context, we can assume the package has been properly versioned
if (process.env.ALEXANDIRA_IS_CI_BUILD) { if (process.env.ALEXANDIRA_IS_CI_BUILD && process.env.npm_package_version && process.env.npm_package_version.trim() !== '') {
return process.env.npm_package_version; return process.env.npm_package_version;
} }
try { try {
// Get the latest git tag, assuming git is installed and tagged branch is available // Get the latest git tag, assuming git is installed and tagged branch is available
const tag = execSync('git describe --tags --abbrev=0').toString().trim(); const tag = execSync('git describe --tags --abbrev=0').toString().trim();
return tag; return tag;
} catch (error) { } catch (error) {
console.error("Failed to get git tag:", error); return 'development';
// Fallback to package version
return process.env.npm_package_version;
} }
} }

Loading…
Cancel
Save