fix(website): support stable AppImage asset names
This commit is contained in:
@@ -6,17 +6,18 @@ export function releaseBase(version: string) {
|
|||||||
|
|
||||||
export interface ReleaseAssetInfo {
|
export interface ReleaseAssetInfo {
|
||||||
version: string;
|
version: string;
|
||||||
|
linuxAppImageAsset: string;
|
||||||
windowsX64Asset: string | null;
|
windowsX64Asset: string | null;
|
||||||
windowsArm64Asset: string | null;
|
windowsArm64Asset: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function downloadUrls(release: ReleaseAssetInfo) {
|
export function downloadUrls(release: ReleaseAssetInfo) {
|
||||||
const { version, windowsX64Asset, windowsArm64Asset } = release;
|
const { version, linuxAppImageAsset, windowsX64Asset, windowsArm64Asset } = release;
|
||||||
const base = releaseBase(version);
|
const base = releaseBase(version);
|
||||||
return {
|
return {
|
||||||
macAppleSilicon: `${base}/Paseo-${version}-arm64.dmg`,
|
macAppleSilicon: `${base}/Paseo-${version}-arm64.dmg`,
|
||||||
macIntel: `${base}/Paseo-${version}-x64.dmg`,
|
macIntel: `${base}/Paseo-${version}-x64.dmg`,
|
||||||
linuxAppImage: `${base}/Paseo-${version}-x86_64.AppImage`,
|
linuxAppImage: `${base}/${linuxAppImageAsset}`,
|
||||||
linuxDeb: `${base}/Paseo-${version}-amd64.deb`,
|
linuxDeb: `${base}/Paseo-${version}-amd64.deb`,
|
||||||
linuxRpm: `${base}/Paseo-${version}-x86_64.rpm`,
|
linuxRpm: `${base}/Paseo-${version}-x86_64.rpm`,
|
||||||
windowsExeX64: `${base}/${windowsX64Asset ?? `Paseo-Setup-${version}.exe`}`,
|
windowsExeX64: `${base}/${windowsX64Asset ?? `Paseo-Setup-${version}.exe`}`,
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ interface GitHubRelease {
|
|||||||
draft: boolean;
|
draft: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const LINUX_APPIMAGE_ASSET_PATTERN =
|
||||||
|
/^Paseo-(?:\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)-)?x86_64\.AppImage$/;
|
||||||
|
|
||||||
const REQUIRED_ASSET_PATTERNS = [
|
const REQUIRED_ASSET_PATTERNS = [
|
||||||
/Paseo-.*-arm64\.dmg$/, // Mac Apple Silicon
|
/Paseo-.*-arm64\.dmg$/, // Mac Apple Silicon
|
||||||
/Paseo-.*-x86_64\.AppImage$/, // Linux AppImage
|
LINUX_APPIMAGE_ASSET_PATTERN, // Linux AppImage
|
||||||
/Paseo-Setup-.*\.exe$/, // Windows (any arch)
|
/Paseo-Setup-.*\.exe$/, // Windows (any arch)
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -39,12 +42,17 @@ function pickWindowsAssets(assets: GitHubAsset[]) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pickLinuxAppImageAsset(assets: GitHubAsset[]) {
|
||||||
|
return assets.find((a) => LINUX_APPIMAGE_ASSET_PATTERN.test(a.name))?.name ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
function versionFromTag(tag: string): string {
|
function versionFromTag(tag: string): string {
|
||||||
return tag.replace(/^v/, "");
|
return tag.replace(/^v/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ReleaseInfo {
|
interface ReleaseInfo {
|
||||||
version: string;
|
version: string;
|
||||||
|
linuxAppImageAsset: string;
|
||||||
windowsX64Asset: string | null;
|
windowsX64Asset: string | null;
|
||||||
windowsArm64Asset: string | null;
|
windowsArm64Asset: string | null;
|
||||||
}
|
}
|
||||||
@@ -70,8 +78,11 @@ async function fetchLatestReadyRelease(): Promise<ReleaseInfo> {
|
|||||||
const ready = releases.find((r) => !r.prerelease && !r.draft && hasRequiredAssets(r));
|
const ready = releases.find((r) => !r.prerelease && !r.draft && hasRequiredAssets(r));
|
||||||
if (!ready) throw new Error("no ready GitHub release found");
|
if (!ready) throw new Error("no ready GitHub release found");
|
||||||
const win = pickWindowsAssets(ready.assets);
|
const win = pickWindowsAssets(ready.assets);
|
||||||
|
const linuxAppImageAsset = pickLinuxAppImageAsset(ready.assets);
|
||||||
|
if (!linuxAppImageAsset) throw new Error("ready release missing Linux AppImage asset");
|
||||||
return {
|
return {
|
||||||
version: versionFromTag(ready.tag_name),
|
version: versionFromTag(ready.tag_name),
|
||||||
|
linuxAppImageAsset,
|
||||||
windowsX64Asset: win.x64,
|
windowsX64Asset: win.x64,
|
||||||
windowsArm64Asset: win.arm64,
|
windowsArm64Asset: win.arm64,
|
||||||
};
|
};
|
||||||
@@ -83,6 +94,11 @@ function isReleaseInfo(value: unknown): value is ReleaseInfo {
|
|||||||
return (
|
return (
|
||||||
typeof record.version === "string" &&
|
typeof record.version === "string" &&
|
||||||
/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(record.version) &&
|
/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(record.version) &&
|
||||||
|
typeof record.linuxAppImageAsset === "string" &&
|
||||||
|
(record.linuxAppImageAsset === "Paseo-x86_64.AppImage" ||
|
||||||
|
new RegExp(`^Paseo-${record.version.replaceAll(".", "\\.")}-x86_64\\.AppImage$`).test(
|
||||||
|
record.linuxAppImageAsset,
|
||||||
|
)) &&
|
||||||
(typeof record.windowsX64Asset === "string" || record.windowsX64Asset === null) &&
|
(typeof record.windowsX64Asset === "string" || record.windowsX64Asset === null) &&
|
||||||
(typeof record.windowsArm64Asset === "string" || record.windowsArm64Asset === null) &&
|
(typeof record.windowsArm64Asset === "string" || record.windowsArm64Asset === null) &&
|
||||||
(record.windowsX64Asset === null ||
|
(record.windowsX64Asset === null ||
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { getStarCount } from "~/stars";
|
|||||||
|
|
||||||
interface ReleaseContext {
|
interface ReleaseContext {
|
||||||
version: string;
|
version: string;
|
||||||
|
linuxAppImageAsset: string;
|
||||||
windowsX64Asset: string | null;
|
windowsX64Asset: string | null;
|
||||||
windowsArm64Asset: string | null;
|
windowsArm64Asset: string | null;
|
||||||
}
|
}
|
||||||
@@ -16,6 +17,7 @@ interface StarsContext {
|
|||||||
|
|
||||||
const ReleaseCtx = createContext<ReleaseContext>({
|
const ReleaseCtx = createContext<ReleaseContext>({
|
||||||
version: "",
|
version: "",
|
||||||
|
linuxAppImageAsset: "",
|
||||||
windowsX64Asset: null,
|
windowsX64Asset: null,
|
||||||
windowsArm64Asset: null,
|
windowsArm64Asset: null,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user