refactor(download): remove checksum handling and simplify release data retrieval

This commit is contained in:
taroj1205 2025-06-22 18:24:42 +12:00
parent ec6e361d74
commit f1f02464e7
No known key found for this signature in database
GPG key ID: 0FCB6CFFE0981AB7
5 changed files with 54 additions and 7 deletions

View file

@ -1,5 +1,4 @@
---
import h3 from '~/components/Description.astro'
import { getLocale, getUI } from '~/utils/i18n'
const locale = getLocale(Astro)

View file

@ -5,7 +5,6 @@ import Button from '../Button.astro'
interface ReleaseInfo {
label?: string
link: string
checksum?: string
}
interface PlatformReleases {

View file

@ -59,3 +59,55 @@ export function getReleasesWithChecksums(locale: string) {
}
}
}
/**
* Returns the releases object, without checksums.
* @param locale The locale to use for labels
*/
export function getReleases(locale: string) {
const {
routes: {
download: {
links: { macos, windows, linux },
},
},
} = getUI(locale)
return {
macos: {
universal: {
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.macos-universal.dmg',
label: macos.universal,
},
},
windows: {
x86_64: {
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.installer.exe',
label: windows['64bit'],
},
arm64: {
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.installer-arm64.exe',
label: windows.ARM64,
},
},
linux: {
x86_64: {
tarball: {
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-x86_64.tar.xz',
label: linux.x86_64,
},
},
aarch64: {
tarball: {
link: 'https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-aarch64.tar.xz',
label: linux.aarch64,
},
},
flathub: {
all: {
link: 'https://flathub.org/apps/app.zen_browser.zen',
label: linux.flathub,
},
},
},
}
}

View file

@ -2,9 +2,8 @@
import Description from '~/components/Description.astro'
import DownloadScript from '~/components/download/DownloadScript.astro'
import PlatformDownload from '~/components/download/PlatformDownload.astro'
import { getReleasesWithChecksums } from '~/components/download/release-data'
import { getReleases } from '~/components/download/release-data'
import Layout from '~/layouts/Layout.astro'
import { getChecksums } from '~/utils/githubChecksums'
import { getLocale, getUI } from '~/utils/i18n'
import { icon, library } from '@fortawesome/fontawesome-svg-core'
@ -27,8 +26,7 @@ const windowsIcon = icon({ prefix: 'fab', iconName: 'windows' })
const linuxIcon = icon({ prefix: 'fab', iconName: 'linux' })
const appleIcon = icon({ prefix: 'fab', iconName: 'apple' })
const checksums = await getChecksums()
const releases = getReleasesWithChecksums(locale)(checksums)
const releases = getReleases(locale)
const platformDescriptions = download.platformDescriptions
---

View file

@ -18,7 +18,6 @@ export async function getChecksums() {
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
'User-Agent': 'zen-browser-checksum-fetcher',
...(process.env.GITHUB_TOKEN ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {}),
},
})
if (!res.ok) throw new Error(`Failed to fetch GitHub release: ${res.statusText}`)