Skip to content

Commit 76b6239

Browse files
committed
Set version number in build
1 parent f3d0abe commit 76b6239

File tree

12 files changed

+38
-89
lines changed

12 files changed

+38
-89
lines changed

.github/workflows/production.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
BASE_PATH=/chat
2929
GIT_SHA=${{ github.sha }}
3030
STAGING=false
31+
VERSION=${{ github.ref_name }}
3132
extra-args: --ulimit nofile=4096:4096
3233

3334
- name: Push to quay.io

Containerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ WORKDIR /opt/app-root/src
77
ARG GIT_SHA
88
ENV REACT_APP_GIT_SHA=$GIT_SHA
99

10+
ARG VERSION
11+
ENV VERSION=$VERSION
12+
ENV VITE_VERSION=$VERSION
13+
1014
ARG BASE_PATH
1115
ENV PUBLIC_URL=$BASE_PATH
1216

dev.Containerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ENV TZ="Europe/Helsinki"
44

55
WORKDIR /opt/app-root/src
66

7+
ENV VERSION=development
8+
ENV VITE_VERSION=development
9+
710
COPY package* ./
811
RUN npm i
912

src/client/components/Footer/index.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { Box, Typography, Link } from '@mui/material'
22
import { Trans, useTranslation } from 'react-i18next'
33

44
import toskaColor from '../../assets/toscalogo_color.svg'
5-
import { useQuery } from '@tanstack/react-query'
6-
import { maxBy } from 'lodash'
7-
import { Release } from '../../../shared/types'
8-
import { formatDistanceToNow } from 'date-fns'
5+
import { formatDistanceToNow, formatDuration, interval } from 'date-fns'
96
import { locales } from '../../locales/locales'
7+
import useCurrentUser from '../../hooks/useCurrentUser'
108

119
const supportEmail = '[email protected]'
1210

@@ -21,16 +19,11 @@ const styles = {
2119

2220
const Footer = () => {
2321
const { t, i18n } = useTranslation()
22+
const { user } = useCurrentUser()
2423

25-
const { data: changelog } = useQuery<Release[]>({
26-
queryKey: ['/changelog'],
27-
select: (data) => {
28-
const last = maxBy(data, (d) => Date.parse(d.time))
29-
return last ? [last] : []
30-
},
31-
})
32-
33-
const publishedAgo = formatDistanceToNow(changelog?.[0]?.time ?? new Date().getTime(), { addSuffix: true, locale: locales[i18n.language] })
24+
const uptime = formatDistanceToNow(user?.lastRestart ?? Date.now(), { locale: locales[i18n.language] })
25+
const serverVersion = user?.serverVersion
26+
const clientVersion = import.meta.env.VITE_VERSION as string | undefined
3427

3528
return (
3629
<Box
@@ -50,8 +43,13 @@ const Footer = () => {
5043
}}
5144
/>
5245
</Typography>
53-
<Box display="flex" gap="1rem">
54-
<Typography variant="caption">{t('footer:version', { version: changelog?.[0]?.version, publishedAgo })}</Typography>
46+
<Box display="flex" gap="1rem" mt="1rem">
47+
<Box display="flex" flexDirection="column">
48+
<Typography variant="caption">{t('footer:server', { version: serverVersion })}</Typography>
49+
<Typography variant="caption">{t('footer:client', { version: clientVersion })}</Typography>
50+
{user?.isAdmin && <Typography variant="caption">{t('footer:uptime', { uptime })}</Typography>}
51+
{serverVersion !== clientVersion && <Typography variant="caption">{t('footer:mismatch')}</Typography>}
52+
</Box>
5553
<Link href="https://toska.dev" target="_blank" rel="noopener" underline="hover">
5654
<img src={toskaColor} alt="Toska" width="40" />
5755
</Link>

src/client/locales/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
},
6464
"footer": {
6565
"contactSupport": "Contact support: <mailTo>{{supportEmail}}</mailTo>",
66-
"version": "Version {{version}}"
66+
"server": "Server version {{version}}",
67+
"client": "Client version {{version}}",
68+
"uptime": "Uptime: {{uptime}}",
69+
"mismatch": "Reload for latest changes"
6770
},
6871
"chat": {
6972
"start": "Start the conversation by sending a message...",
@@ -350,4 +353,4 @@
350353
"nameLabel": "Collection name",
351354
"nameHelperText": "Use a descriptive name (for example the full name of the course)"
352355
}
353-
}
356+
}

src/client/locales/fi.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
},
6464
"footer": {
6565
"contactSupport": "Ota yhteyttä tukeen: <mailTo>{{supportEmail}}</mailTo>",
66-
"version": "Versio {{version}} - julkaistu {{publishedAgo}}"
66+
"server": "Palvelinversio {{version}}",
67+
"client": "Selainversio {{version}}",
68+
"uptime": "Uptime: {{uptime}}",
69+
"mismatch": "Lataa sivu uudelleen"
6770
},
6871
"chat": {
6972
"start": "Aloita keskustelu lähettämällä viesti...",
@@ -350,4 +353,4 @@
350353
"nameLabel": "Kokoelman nimi",
351354
"nameHelperText": "Käytä kuvaavaa nimeä (esim. kurssin koko nimi)"
352355
}
353-
}
356+
}

src/client/locales/sv.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
},
7070
"footer": {
7171
"contactSupport": "Kontakta support: <mailTo>{{supportEmail}}</mailTo>",
72-
"version": "Version {{version}}"
72+
"server": "Server version {{version}}",
73+
"client": "Klient version {{version}}",
74+
"uptime": "Uptime: {{uptime}}",
75+
"mismatch": "Ladda sida om"
7376
},
7477
"chat": {
7578
"start": "Starta konversationen genom att skicka ett meddelande...",

src/client/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface User {
5757
isStatsViewer: boolean
5858
termsAcceptedAt?: string | null
5959
preferences?: UserPreferences
60+
serverVersion?: string
6061
}
6162

6263
export type Prompt = {

src/server/routes/changeLog.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/server/routes/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import emailRouter from './email'
1717
import adminRouter from './admin'
1818
import facultyRouter from './faculty'
1919
import infoTextRouter from './infotext'
20-
import changeLogRouter from './changeLog'
2120
import feedbackRouter from './feedback'
2221
import testUtilsRouter from './testUtils'
2322
import { inProduction } from '../../config'
@@ -54,7 +53,6 @@ router.use('/email', emailRouter)
5453
router.use('/admin', adminRouter)
5554
router.use('/faculties', facultyRouter)
5655
router.use('/infotexts', infoTextRouter)
57-
router.use('/changelog', changeLogRouter)
5856
router.use('/feedback', feedbackRouter)
5957

6058
Sentry.setupExpressErrorHandler(router)

0 commit comments

Comments
 (0)