Merge pull request #32 from ethereum/latest-releases-downloads
feat: latest releases downloads logic
This commit is contained in:
commit
1d89df8cc1
|
@ -1,21 +1,11 @@
|
|||
import {
|
||||
Box,
|
||||
Center,
|
||||
Button,
|
||||
Grid,
|
||||
Image,
|
||||
Link,
|
||||
Stack,
|
||||
HStack,
|
||||
Text
|
||||
} from '@chakra-ui/react';
|
||||
import { Box, Center, Button, Grid, Image, Link, Stack, HStack, Text } from '@chakra-ui/react';
|
||||
import { FC } from 'react';
|
||||
import NextLink from 'next/link';
|
||||
|
||||
import { DOWNLOAD_HEADER_BUTTONS } from '../../../constants';
|
||||
|
||||
interface DownloadsHero {
|
||||
currentBuildName: string;
|
||||
currentBuild: string;
|
||||
currentBuildVersion: string;
|
||||
linuxBuildURL: string;
|
||||
macOSBuildURL: string;
|
||||
|
@ -25,7 +15,7 @@ interface DownloadsHero {
|
|||
}
|
||||
|
||||
export const DownloadsHero: FC<DownloadsHero> = ({
|
||||
currentBuildName,
|
||||
currentBuild,
|
||||
currentBuildVersion,
|
||||
linuxBuildURL,
|
||||
macOSBuildURL,
|
||||
|
@ -62,9 +52,9 @@ export const DownloadsHero: FC<DownloadsHero> = ({
|
|||
// TODO: move text style to theme
|
||||
fontFamily='"JetBrains Mono", monospace'
|
||||
lineHeight='21px'
|
||||
mb={{base: '4 !important', md: '8 !important'}}
|
||||
mb={{ base: '4 !important', md: '8 !important' }}
|
||||
>
|
||||
{currentBuildName} ({currentBuildVersion})
|
||||
{currentBuild}
|
||||
</Text>
|
||||
|
||||
<Text mb={4}>
|
||||
|
@ -80,7 +70,7 @@ export const DownloadsHero: FC<DownloadsHero> = ({
|
|||
px={{ base: 8 }}
|
||||
flex={{ base: 'none' }}
|
||||
display={{ base: 'block', lg: 'none' }}
|
||||
order={{base: -1, md: 1}}
|
||||
order={{ base: -1, md: 1 }}
|
||||
>
|
||||
<Center>
|
||||
<Image
|
||||
|
@ -120,14 +110,12 @@ export const DownloadsHero: FC<DownloadsHero> = ({
|
|||
|
||||
<Box textAlign={'center'}>
|
||||
<Link href={releaseNotesURL} isExternal variant='light'>
|
||||
Release notes for {currentBuildName} {currentBuildVersion}
|
||||
Release notes for {currentBuild}
|
||||
</Link>
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
<Center
|
||||
display={{ base: 'none', lg: 'flex' }}
|
||||
>
|
||||
<Center display={{ base: 'none', lg: 'flex' }}>
|
||||
<Image
|
||||
src='/images/pages/gopher-downloads-front-light.svg'
|
||||
alt='Gopher plugged in'
|
||||
|
|
|
@ -82,7 +82,7 @@ export const Footer: FC = () => {
|
|||
}}
|
||||
borderColor='brand.light.primary !important'
|
||||
_hover={{
|
||||
bg: 'brand.light.primary',
|
||||
bg: 'brand.light.primary'
|
||||
}}
|
||||
alignItems='center'
|
||||
p={4}
|
||||
|
@ -91,10 +91,10 @@ export const Footer: FC = () => {
|
|||
<Link isExternal>
|
||||
<TwitterIcon
|
||||
w={8}
|
||||
height={8}
|
||||
height={8}
|
||||
_groupHover={{
|
||||
svg: {
|
||||
path:{fill: 'yellow.50 !important'}
|
||||
path: { fill: 'yellow.50 !important' }
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
@ -106,7 +106,7 @@ export const Footer: FC = () => {
|
|||
data-group
|
||||
flex={1}
|
||||
_hover={{
|
||||
bg: 'brand.light.primary',
|
||||
bg: 'brand.light.primary'
|
||||
}}
|
||||
alignItems='center'
|
||||
borderWidth='2px'
|
||||
|
@ -118,10 +118,10 @@ export const Footer: FC = () => {
|
|||
<Link isExternal>
|
||||
<DiscordIcon
|
||||
w={8}
|
||||
height={8}
|
||||
height={8}
|
||||
_groupHover={{
|
||||
svg: {
|
||||
path:{fill: 'yellow.50 !important'}
|
||||
path: { fill: 'yellow.50 !important' }
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
@ -133,7 +133,7 @@ export const Footer: FC = () => {
|
|||
data-group
|
||||
flex={1}
|
||||
_hover={{
|
||||
bg: 'brand.light.primary',
|
||||
bg: 'brand.light.primary'
|
||||
}}
|
||||
alignItems='center'
|
||||
p={4}
|
||||
|
@ -142,10 +142,10 @@ export const Footer: FC = () => {
|
|||
<Link isExternal>
|
||||
<GitHubIcon
|
||||
w={7}
|
||||
height={7}
|
||||
height={7}
|
||||
_groupHover={{
|
||||
svg: {
|
||||
path:{fill: 'yellow.50 !important'}
|
||||
path: { fill: 'yellow.50 !important' }
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -66,3 +66,19 @@ export const DOWNLOAD_OPENPGP_DEVELOPER_HEADERS = [
|
|||
'OpenPGP Key',
|
||||
'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,5 +1,5 @@
|
|||
import { Center, Code, Flex, 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 {
|
||||
|
@ -11,17 +11,90 @@ import {
|
|||
import { DataTable } from '../components/UI';
|
||||
|
||||
import {
|
||||
ALL_GETH_COMMITS_URL,
|
||||
DEFAULT_BUILD_AMOUNT_TO_SHOW,
|
||||
DOWNLOAD_OPENPGP_BUILD_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';
|
||||
|
||||
import { testDownloadData } from '../data/test/download-testdata';
|
||||
import { pgpBuildTestData } from '../data/test/pgpbuild-testdata';
|
||||
import { pgpDeveloperTestData } from '../data/test/pgpdeveloper-testdata';
|
||||
|
||||
const DownloadsPage: NextPage = () => {
|
||||
export const getServerSideProps: GetServerSideProps = async () => {
|
||||
// Latest release name & version number
|
||||
const { versionNumber, releaseName } = await fetch(LATEST_GETH_RELEASE_URL)
|
||||
.then(response => response.json())
|
||||
.then(release => {
|
||||
return {
|
||||
versionNumber: release.tag_name,
|
||||
releaseName: 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 interfaces after adding the rest of the logic
|
||||
LATEST_RELEASES_DATA: {
|
||||
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 [amountDevelopBuilds, updateAmountDevelopBuilds] = useState(DEFAULT_BUILD_AMOUNT_TO_SHOW);
|
||||
|
||||
|
@ -33,27 +106,24 @@ const DownloadsPage: NextPage = () => {
|
|||
updateAmountDevelopBuilds(amountDevelopBuilds + 10);
|
||||
};
|
||||
|
||||
const {
|
||||
LATEST_RELEASES_DATA: { releaseName, versionNumber, urls }
|
||||
} = data;
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* TODO: add PageMetadata */}
|
||||
|
||||
<main>
|
||||
<Stack spacing={4}>
|
||||
{/* TODO: replace hardcoded strings with build information */}
|
||||
<DownloadsHero
|
||||
currentBuildName={'Sentry Omega'}
|
||||
currentBuildVersion={'v1.10.23'}
|
||||
linuxBuildURL={
|
||||
'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.25-69568c55.tar.gz'
|
||||
}
|
||||
macOSBuildURL={
|
||||
'https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-1.10.25-69568c55.tar.gz'
|
||||
}
|
||||
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'
|
||||
}
|
||||
currentBuild={releaseName}
|
||||
currentBuildVersion={versionNumber}
|
||||
linuxBuildURL={urls.LATEST_LINUX_BINARY_URL}
|
||||
macOSBuildURL={urls.LATEST_MACOS_BINARY_URL}
|
||||
windowsBuildURL={urls.LATEST_WINDOWS_BINARY_URL}
|
||||
sourceCodeURL={urls.LATEST_SOURCES_URL}
|
||||
releaseNotesURL={urls.RELEASE_NOTES_URL}
|
||||
/>
|
||||
|
||||
<SpecificVersionsSection>
|
||||
|
@ -177,7 +247,7 @@ const DownloadsPage: NextPage = () => {
|
|||
sx={{ mt: '0 !important' }}
|
||||
borderLeft={{ base: 'none', md: '2px solid #11866f' }}
|
||||
>
|
||||
<Link as='button' variant='button-link-secondary' onClick={showMoreStableReleases}>
|
||||
<Link as='button' variant='button-link-secondary' onClick={showMoreDevelopBuilds}>
|
||||
<Text
|
||||
fontFamily='"JetBrains Mono", monospace'
|
||||
fontWeight={700}
|
||||
|
|
|
@ -67,13 +67,13 @@ export const textStyles = {
|
|||
'downloads-button-label': {
|
||||
fontFamily: '"JetBrains Mono", monospace',
|
||||
color: 'yellow.50',
|
||||
fontSize: {base: 'md', lg: 'xl'},
|
||||
fontSize: { base: 'md', lg: 'xl' },
|
||||
textTransform: 'uppercase'
|
||||
},
|
||||
'downloads-button-sublabel': {
|
||||
fontFamily: '"JetBrains Mono", monospace',
|
||||
color: 'yellow.50',
|
||||
fontSize: {base: 'xs', lg: 'sm'},
|
||||
fontSize: { base: 'xs', lg: 'sm' },
|
||||
textTransform: 'uppercase'
|
||||
},
|
||||
'download-tab-label': {
|
||||
|
|
Loading…
Reference in New Issue