fix(website): fetch desktop version from latest GitHub release

The download page was showing pre-release versions because it read
the version directly from package.json. Now fetches the latest
non-prerelease from the GitHub Releases API at build time, with
fallback to package.json for local dev.
This commit is contained in:
Mohamed Boudra
2026-03-29 21:12:30 +07:00
parent 971f74e2ab
commit fb42c8eea2
2 changed files with 43 additions and 19 deletions
+4 -1
View File
@@ -1,7 +1,10 @@
import * as React from "react"; import * as React from "react";
import websitePackage from "../package.json"; import websitePackage from "../package.json";
export const desktopVersion = websitePackage.version; declare const __DESKTOP_VERSION__: string | undefined;
export const desktopVersion =
typeof __DESKTOP_VERSION__ !== "undefined" ? __DESKTOP_VERSION__ : websitePackage.version;
export const releaseBase = `https://github.com/getpaseo/paseo/releases/download/v${desktopVersion}`; export const releaseBase = `https://github.com/getpaseo/paseo/releases/download/v${desktopVersion}`;
export const macAppleSiliconDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-arm64.dmg`; export const macAppleSiliconDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-arm64.dmg`;
export const macIntelDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-x64.dmg`; export const macIntelDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-x64.dmg`;
+23 -2
View File
@@ -1,5 +1,5 @@
import path from "node:path"; import path from "node:path";
import { defineConfig } from "vite"; import { defineConfig, type UserConfig } from "vite";
import tsConfigPaths from "vite-tsconfig-paths"; import tsConfigPaths from "vite-tsconfig-paths";
import { tanstackStart } from "@tanstack/react-start/plugin/vite"; import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import { cloudflare } from "@cloudflare/vite-plugin"; import { cloudflare } from "@cloudflare/vite-plugin";
@@ -28,7 +28,27 @@ const sitemapPages = [
path: routePath, path: routePath,
})); }));
export default defineConfig({ async function fetchLatestReleaseVersion(): Promise<string | undefined> {
try {
const res = await fetch(
"https://api.github.com/repos/getpaseo/paseo/releases/latest",
{ headers: { Accept: "application/vnd.github+json" }, signal: AbortSignal.timeout(5000) },
);
if (!res.ok) return undefined;
const data = (await res.json()) as { tag_name: string };
return data.tag_name.replace(/^v/, "");
} catch {
return undefined;
}
}
export default defineConfig(async (): Promise<UserConfig> => {
const latestVersion = await fetchLatestReleaseVersion();
return {
define: {
...(latestVersion && { __DESKTOP_VERSION__: JSON.stringify(latestVersion) }),
},
server: { server: {
port: 8082, port: 8082,
fs: { fs: {
@@ -47,4 +67,5 @@ export default defineConfig({
react(), react(),
tailwindcss(), tailwindcss(),
], ],
};
}); });