mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-04-14 13:48:37 +00:00
feat: add latest releases downloads logic
This commit is contained in:
parent
0686ef1bee
commit
83a2c81290
3 changed files with 107 additions and 22 deletions
|
|
@ -5,7 +5,7 @@ import NextLink from 'next/link';
|
||||||
import { DOWNLOAD_HEADER_BUTTONS } from '../../../constants';
|
import { DOWNLOAD_HEADER_BUTTONS } from '../../../constants';
|
||||||
|
|
||||||
interface DownloadsHero {
|
interface DownloadsHero {
|
||||||
currentBuildName: string;
|
currentBuild: string;
|
||||||
currentBuildVersion: string;
|
currentBuildVersion: string;
|
||||||
linuxBuildURL: string;
|
linuxBuildURL: string;
|
||||||
macOSBuildURL: string;
|
macOSBuildURL: string;
|
||||||
|
|
@ -15,7 +15,7 @@ interface DownloadsHero {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DownloadsHero: FC<DownloadsHero> = ({
|
export const DownloadsHero: FC<DownloadsHero> = ({
|
||||||
currentBuildName,
|
currentBuild,
|
||||||
currentBuildVersion,
|
currentBuildVersion,
|
||||||
linuxBuildURL,
|
linuxBuildURL,
|
||||||
macOSBuildURL,
|
macOSBuildURL,
|
||||||
|
|
@ -45,7 +45,7 @@ export const DownloadsHero: FC<DownloadsHero> = ({
|
||||||
lineHeight='21px'
|
lineHeight='21px'
|
||||||
mb={8}
|
mb={8}
|
||||||
>
|
>
|
||||||
{currentBuildName} ({currentBuildVersion})
|
{currentBuild}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Text mb={4}>
|
<Text mb={4}>
|
||||||
|
|
@ -70,7 +70,7 @@ export const DownloadsHero: FC<DownloadsHero> = ({
|
||||||
<Text textStyle='downloads-button-label'>
|
<Text textStyle='downloads-button-label'>
|
||||||
For {DOWNLOAD_HEADER_BUTTONS[key].name}
|
For {DOWNLOAD_HEADER_BUTTONS[key].name}
|
||||||
</Text>
|
</Text>
|
||||||
<Text textStyle='downloads-button-label'>geth {currentBuildName}</Text>
|
<Text textStyle='downloads-button-label'>geth {currentBuildVersion}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</HStack>
|
</HStack>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -80,7 +80,7 @@ export const DownloadsHero: FC<DownloadsHero> = ({
|
||||||
|
|
||||||
<Box textAlign={'center'}>
|
<Box textAlign={'center'}>
|
||||||
<Link href={releaseNotesURL} isExternal variant='light'>
|
<Link href={releaseNotesURL} isExternal variant='light'>
|
||||||
Release notes for {currentBuildName} {currentBuildVersion}
|
Release notes for {currentBuild}
|
||||||
</Link>
|
</Link>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
|
|
@ -66,3 +66,19 @@ export const DOWNLOAD_OPENPGP_DEVELOPER_HEADERS = [
|
||||||
'OpenPGP Key',
|
'OpenPGP Key',
|
||||||
'Fingerprint'
|
'Fingerprint'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// GitHub urls
|
||||||
|
export const LATEST_GETH_RELEASE_URL =
|
||||||
|
'https://api.github.com/repos/ethereum/go-ethereum/releases/latest';
|
||||||
|
export const ALL_GETH_RELEASES_URL = 'https://api.github.com/repos/ethereum/go-ethereum/releases';
|
||||||
|
export const ALL_GETH_COMMITS_URL = 'https://api.github.com/repos/ethereum/go-ethereum/commits/';
|
||||||
|
|
||||||
|
export const LINUX_BINARY_BASE_URL =
|
||||||
|
'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-';
|
||||||
|
export const MACOS_BINARY_BASE_URL =
|
||||||
|
'https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-';
|
||||||
|
export const WINDOWS_BINARY_BASE_URL =
|
||||||
|
'https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-';
|
||||||
|
|
||||||
|
export const LATEST_SOURCES_BASE_URL = 'https://github.com/ethereum/go-ethereum/archive/';
|
||||||
|
export const RELEASE_NOTES_BASE_URL = 'https://github.com/ethereum/go-ethereum/releases/tag/';
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,92 @@
|
||||||
import { Code, Link, ListItem, Stack, Text, UnorderedList } from '@chakra-ui/react';
|
import { Code, Link, ListItem, Stack, Text, UnorderedList } from '@chakra-ui/react';
|
||||||
import type { NextPage } from 'next';
|
import type { GetServerSideProps, NextPage } from 'next';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { DownloadsHero, DownloadsSection, DownloadsTable } from '../components/UI/downloads';
|
import { DownloadsHero, DownloadsSection, DownloadsTable } from '../components/UI/downloads';
|
||||||
import { DataTable } from '../components/UI';
|
import { DataTable } from '../components/UI';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ALL_GETH_COMMITS_URL,
|
||||||
DEFAULT_BUILD_AMOUNT_TO_SHOW,
|
DEFAULT_BUILD_AMOUNT_TO_SHOW,
|
||||||
DOWNLOAD_OPENPGP_BUILD_HEADERS,
|
DOWNLOAD_OPENPGP_BUILD_HEADERS,
|
||||||
DOWNLOAD_OPENPGP_DEVELOPER_HEADERS,
|
DOWNLOAD_OPENPGP_DEVELOPER_HEADERS,
|
||||||
GETH_REPO_URL
|
GETH_REPO_URL,
|
||||||
|
LATEST_GETH_RELEASE_URL,
|
||||||
|
LATEST_SOURCES_BASE_URL,
|
||||||
|
LINUX_BINARY_BASE_URL,
|
||||||
|
MACOS_BINARY_BASE_URL,
|
||||||
|
RELEASE_NOTES_BASE_URL,
|
||||||
|
WINDOWS_BINARY_BASE_URL
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
|
|
||||||
import { testDownloadData } from '../data/test/download-testdata';
|
import { testDownloadData } from '../data/test/download-testdata';
|
||||||
import { pgpBuildTestData } from '../data/test/pgpbuild-testdata';
|
import { pgpBuildTestData } from '../data/test/pgpbuild-testdata';
|
||||||
import { pgpDeveloperTestData } from '../data/test/pgpdeveloper-testdata';
|
import { pgpDeveloperTestData } from '../data/test/pgpdeveloper-testdata';
|
||||||
|
|
||||||
const DownloadsPage: NextPage = () => {
|
export const getServerSideProps: GetServerSideProps = async () => {
|
||||||
|
// Latest release version number
|
||||||
|
const versionNumber = await fetch(LATEST_GETH_RELEASE_URL)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(release => release.tag_name);
|
||||||
|
// Latest release name
|
||||||
|
const releaseName = await fetch(LATEST_GETH_RELEASE_URL)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(release => release.name);
|
||||||
|
// Latest release commit hash
|
||||||
|
const commit = await fetch(`${ALL_GETH_COMMITS_URL}/${versionNumber}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(commit => commit.sha.slice(0, 8));
|
||||||
|
|
||||||
|
// Latest binaries urls
|
||||||
|
const LATEST_LINUX_BINARY_URL = `${LINUX_BINARY_BASE_URL}${versionNumber.slice(
|
||||||
|
1
|
||||||
|
)}-${commit}.tar.gz`;
|
||||||
|
const LATEST_MACOS_BINARY_URL = `${MACOS_BINARY_BASE_URL}${versionNumber.slice(
|
||||||
|
1
|
||||||
|
)}-${commit}.tar.gz`;
|
||||||
|
const LATEST_WINDOWS_BINARY_URL = `${WINDOWS_BINARY_BASE_URL}${versionNumber.slice(
|
||||||
|
1
|
||||||
|
)}-${commit}.exe`;
|
||||||
|
|
||||||
|
// Sources urls
|
||||||
|
const LATEST_SOURCES_URL = `${LATEST_SOURCES_BASE_URL}${versionNumber}.tar.gz`;
|
||||||
|
const RELEASE_NOTES_URL = `${RELEASE_NOTES_BASE_URL}${versionNumber}`;
|
||||||
|
|
||||||
|
const LATEST_RELEASES_DATA = {
|
||||||
|
versionNumber,
|
||||||
|
releaseName,
|
||||||
|
urls: {
|
||||||
|
LATEST_LINUX_BINARY_URL,
|
||||||
|
LATEST_MACOS_BINARY_URL,
|
||||||
|
LATEST_WINDOWS_BINARY_URL,
|
||||||
|
LATEST_SOURCES_URL,
|
||||||
|
RELEASE_NOTES_URL
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
data: LATEST_RELEASES_DATA
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
data: {
|
||||||
|
// TODO: define interface
|
||||||
|
versionNumber: string;
|
||||||
|
releaseName: string;
|
||||||
|
urls: {
|
||||||
|
LATEST_LINUX_BINARY_URL: string;
|
||||||
|
LATEST_MACOS_BINARY_URL: string;
|
||||||
|
LATEST_WINDOWS_BINARY_URL: string;
|
||||||
|
LATEST_SOURCES_URL: string;
|
||||||
|
RELEASE_NOTES_URL: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const DownloadsPage: NextPage<Props> = ({ data }) => {
|
||||||
const [amountStableReleases, updateAmountStables] = useState(DEFAULT_BUILD_AMOUNT_TO_SHOW);
|
const [amountStableReleases, updateAmountStables] = useState(DEFAULT_BUILD_AMOUNT_TO_SHOW);
|
||||||
const [amountDevelopBuilds, updateAmountDevelopBuilds] = useState(DEFAULT_BUILD_AMOUNT_TO_SHOW);
|
const [amountDevelopBuilds, updateAmountDevelopBuilds] = useState(DEFAULT_BUILD_AMOUNT_TO_SHOW);
|
||||||
|
|
||||||
|
|
@ -28,27 +98,22 @@ const DownloadsPage: NextPage = () => {
|
||||||
updateAmountDevelopBuilds(amountDevelopBuilds + 10);
|
updateAmountDevelopBuilds(amountDevelopBuilds + 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { releaseName, versionNumber, urls } = data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* TODO: add PageMetadata */}
|
{/* TODO: add PageMetadata */}
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
{/* TODO: replace hardcoded strings with build information */}
|
|
||||||
<DownloadsHero
|
<DownloadsHero
|
||||||
currentBuildName={'Sentry Omega'}
|
currentBuild={releaseName}
|
||||||
currentBuildVersion={'v1.10.23'}
|
currentBuildVersion={versionNumber}
|
||||||
linuxBuildURL={
|
linuxBuildURL={urls.LATEST_LINUX_BINARY_URL}
|
||||||
'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.25-69568c55.tar.gz'
|
macOSBuildURL={urls.LATEST_MACOS_BINARY_URL}
|
||||||
}
|
releaseNotesURL={urls.RELEASE_NOTES_URL}
|
||||||
macOSBuildURL={
|
sourceCodeURL={urls.LATEST_SOURCES_URL}
|
||||||
'https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-1.10.25-69568c55.tar.gz'
|
windowsBuildURL={urls.LATEST_WINDOWS_BINARY_URL}
|
||||||
}
|
|
||||||
releaseNotesURL={''}
|
|
||||||
sourceCodeURL={'https://github.com/ethereum/go-ethereum/archive/v1.10.25.tar.gz'}
|
|
||||||
windowsBuildURL={
|
|
||||||
'https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.10.25-69568c55.exe'
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DownloadsSection
|
<DownloadsSection
|
||||||
|
|
@ -205,6 +270,10 @@ const DownloadsPage: NextPage = () => {
|
||||||
<Code p={4}>gpg --verify geth-linux-amd64-1.5.0-d0c820ac.tar.gz.asc</Code>
|
<Code p={4}>gpg --verify geth-linux-amd64-1.5.0-d0c820ac.tar.gz.asc</Code>
|
||||||
</Stack>
|
</Stack>
|
||||||
</DownloadsSection>
|
</DownloadsSection>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<pre>{JSON.stringify(data, null, 2)}</pre>
|
||||||
|
</div>
|
||||||
</Stack>
|
</Stack>
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue