mirror of
https://github.com/zen-browser/www.git
synced 2025-07-07 17:05:32 +02:00
feat(checksum): add checksum support to download components and update workflow
- Enhanced ButtonCard component to accept and display SHA-256 checksums. - Updated PlatformDownload and release-data to include checksum information for each release. - Modified DownloadScript to apply twilight mode to new checksum buttons. - Adjusted download page to retrieve and display checksums dynamically.
This commit is contained in:
parent
59974742e9
commit
3816206f6b
7 changed files with 234 additions and 76 deletions
31
src/utils/githubChecksums.ts
Normal file
31
src/utils/githubChecksums.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Fetches the latest release notes from GitHub and parses the SHA-256 checksums.
|
||||
* Returns a mapping from filename to checksum.
|
||||
*/
|
||||
export async function getChecksums() {
|
||||
const token = import.meta.env.GITHUB_TOKEN;
|
||||
if (!token) throw new Error('GITHUB_TOKEN is not set in environment variables');
|
||||
|
||||
const res = await fetch('https://api.github.com/repos/zen-browser/desktop/releases/latest', {
|
||||
headers: {
|
||||
'Accept': 'application/vnd.github+json',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'X-GitHub-Api-Version': '2022-11-28',
|
||||
'User-Agent': 'zen-browser-checksum-fetcher',
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to fetch GitHub release: ' + res.statusText);
|
||||
const data = await res.json();
|
||||
const body = data.body as string;
|
||||
|
||||
// Extract the checksum block
|
||||
const match = body.match(/File Checksums \(SHA-256\)[\s\S]*?```([\s\S]*?)```/);
|
||||
const checksums: Record<string, string> = {};
|
||||
if (match && match[1]) {
|
||||
match[1].split('\n').forEach(line => {
|
||||
const [hash, filename] = line.trim().split(/\s+/, 2);
|
||||
if (hash && filename) checksums[filename] = hash;
|
||||
});
|
||||
}
|
||||
return checksums;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue