Skip to content

Commit 35f8d78

Browse files
authored
feat(BuildInfo): show build date and commit (commaai#574)
1 parent 50e0bef commit 35f8d78

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ jobs:
3838
- uses: actions/checkout@v4
3939
- uses: oven-sh/setup-bun@v2
4040

41+
- name: get commit date
42+
run: echo "VITE_APP_GIT_TIMESTAMP=$(git show -s --format=%cI)" >> $GITHUB_ENV
43+
4144
- run: bun install --frozen-lockfile
4245
- run: bun run build
4346
env:
4447
VITE_SENTRY_ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }}
48+
VITE_APP_GIT_SHA: ${{ github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }}
4549

4650
- name: Bundle size breakdown
4751
run: bun dependency-report | column -t -s ":"
@@ -93,7 +97,7 @@ jobs:
9397
env:
9498
DOCKER_METADATA_PR_HEAD_SHA: true
9599

96-
- name: get date
100+
- name: get commit date
97101
run: echo "GIT_TIMESTAMP=$(git show -s --format=%cI)" >> $GITHUB_ENV
98102

99103
- uses: docker/build-push-action@v6

src/components/BuildInfo.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { VoidComponent } from 'solid-js'
2+
import clsx from 'clsx'
3+
4+
import { dayjs } from '~/utils/format'
5+
6+
const sha = import.meta.env.VITE_APP_GIT_SHA || 'develop'
7+
const timestamp = import.meta.env.VITE_APP_GIT_TIMESTAMP
8+
const formattedTimestamp = timestamp ? dayjs(timestamp).format('YYYY-MM-DD HH:mm') : 'local'
9+
console.debug('BuildInfo', { sha, timestamp, formattedTimestamp })
10+
11+
const BuildInfo: VoidComponent<{ class?: string }> = (props) => {
12+
return (
13+
<div class={clsx('text-xs text-on-surface opacity-25 select-text', props.class)}>
14+
<span class="font-mono cursor-text select-all selection:bg-primary-container">{sha.substring(0, 7)}</span>
15+
<span class="mx-1"></span>
16+
<span>{formattedTimestamp}</span>
17+
</div>
18+
)
19+
}
20+
21+
export default BuildInfo

src/pages/dashboard/Dashboard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import DeviceList from './components/DeviceList'
2121
import DeviceActivity from './activities/DeviceActivity'
2222
import RouteActivity from './activities/RouteActivity'
2323
import SettingsActivity from './activities/SettingsActivity'
24+
import BuildInfo from '~/components/BuildInfo'
2425

2526
const PairActivity = lazy(() => import('./activities/PairActivity'))
2627

@@ -170,6 +171,7 @@ const Dashboard: Component<RouteSectionProps> = () => {
170171
<div class="hidden size-full flex-col items-center justify-center gap-4 md:flex">
171172
<Icon name="search" size="48" />
172173
<span class="text-md">Select a route to view</span>
174+
<BuildInfo class="absolute bottom-4" />
173175
</div>
174176
}
175177
>

0 commit comments

Comments
 (0)