Skip to content

Commit a619510

Browse files
Enhance webapp version with build info (#2146)
* improve app version output * set build info * fix typo * always show additional build info when self-hosting * Update apps/webapp/app/routes/_app.orgs.$organizationSlug.settings/route.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update apps/webapp/app/components/navigation/OrganizationSettingsSideMenu.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix build timestamp name --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 7ee0992 commit a619510

File tree

4 files changed

+78
-8
lines changed

4 files changed

+78
-8
lines changed

.github/workflows/publish-webapp.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ jobs:
5656
5757
echo "image_tags=${image_tags}" >> "$GITHUB_OUTPUT"
5858
59+
- name: 📝 Set the build info
60+
id: set_build_info
61+
run: |
62+
tag=${{ steps.get_tag.outputs.tag }}
63+
if [[ "${{ steps.get_tag.outputs.is_semver }}" == true ]]; then
64+
echo "BUILD_APP_VERSION=${tag}" >> "$GITHUB_OUTPUT"
65+
fi
66+
echo "BUILD_GIT_SHA=${{ github.sha }}" >> "$GITHUB_OUTPUT"
67+
echo "BUILD_GIT_REF_NAME=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
68+
echo "BUILD_TIMESTAMP_SECONDS=$(date +%s)" >> "$GITHUB_OUTPUT"
69+
5970
- name: 🐙 Login to GitHub Container Registry
6071
uses: docker/login-action@v3
6172
with:
@@ -70,3 +81,8 @@ jobs:
7081
platforms: linux/amd64,linux/arm64
7182
tags: ${{ steps.set_tags.outputs.image_tags }}
7283
push: true
84+
build-args: |
85+
BUILD_APP_VERSION=${{ steps.set_build_info.outputs.BUILD_APP_VERSION }}
86+
BUILD_GIT_SHA=${{ steps.set_build_info.outputs.BUILD_GIT_SHA }}
87+
BUILD_GIT_REF_NAME=${{ steps.set_build_info.outputs.BUILD_GIT_REF_NAME }}
88+
BUILD_TIMESTAMP_SECONDS=${{ steps.set_build_info.outputs.BUILD_TIMESTAMP_SECONDS }}

apps/webapp/app/components/navigation/OrganizationSettingsSideMenu.tsx

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,27 @@ import { SideMenuItem } from "./SideMenuItem";
2222
import { useCurrentPlan } from "~/routes/_app.orgs.$organizationSlug/route";
2323
import { Paragraph } from "../primitives/Paragraph";
2424
import { Badge } from "../primitives/Badge";
25+
import { useHasAdminAccess } from "~/hooks/useUser";
26+
27+
export type BuildInfo = {
28+
appVersion: string | undefined;
29+
packageVersion: string;
30+
buildTimestampSeconds: string | undefined;
31+
gitSha: string | undefined;
32+
gitRefName: string | undefined;
33+
};
2534

2635
export function OrganizationSettingsSideMenu({
2736
organization,
28-
version,
37+
buildInfo,
2938
}: {
3039
organization: MatchedOrganization;
31-
version: string;
40+
buildInfo: BuildInfo;
3241
}) {
3342
const { isManagedCloud } = useFeatures();
3443
const currentPlan = useCurrentPlan();
44+
const isAdmin = useHasAdminAccess();
45+
const showBuildInfo = isAdmin || !isManagedCloud;
3546

3647
return (
3748
<div
@@ -94,9 +105,33 @@ export function OrganizationSettingsSideMenu({
94105
<div className="flex flex-col gap-1">
95106
<SideMenuHeader title="App version" />
96107
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
97-
v{version}
108+
{buildInfo.appVersion || `v${buildInfo.packageVersion}`}
98109
</Paragraph>
99110
</div>
111+
{showBuildInfo && buildInfo.buildTimestampSeconds && (
112+
<div className="flex flex-col gap-1">
113+
<SideMenuHeader title="Build timestamp" />
114+
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
115+
{new Date(Number(buildInfo.buildTimestampSeconds) * 1000).toISOString()}
116+
</Paragraph>
117+
</div>
118+
)}
119+
{showBuildInfo && buildInfo.gitRefName && (
120+
<div className="flex flex-col gap-1">
121+
<SideMenuHeader title="Git ref" />
122+
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
123+
{buildInfo.gitRefName}
124+
</Paragraph>
125+
</div>
126+
)}
127+
{showBuildInfo && buildInfo.gitSha && (
128+
<div className="flex flex-col gap-1">
129+
<SideMenuHeader title="Git sha" />
130+
<Paragraph variant="extra-small" className="px-2 text-text-dimmed">
131+
{buildInfo.gitSha.slice(0, 9)}
132+
</Paragraph>
133+
</div>
134+
)}
100135
</div>
101136
<div className="flex flex-col gap-1 border-t border-grid-bright p-1">
102137
<HelpAndFeedback />

apps/webapp/app/routes/_app.orgs.$organizationSlug.settings/route.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
import { Outlet } from "@remix-run/react";
22
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
3-
import { VERSION } from "@trigger.dev/core";
3+
import { VERSION as coreVersion } from "@trigger.dev/core";
44
import { typedjson, useTypedLoaderData } from "remix-typedjson";
55
import { AppContainer, MainBody } from "~/components/layout/AppLayout";
6-
import { OrganizationSettingsSideMenu } from "~/components/navigation/OrganizationSettingsSideMenu";
6+
import {
7+
type BuildInfo,
8+
OrganizationSettingsSideMenu,
9+
} from "~/components/navigation/OrganizationSettingsSideMenu";
710
import { useOrganization } from "~/hooks/useOrganizations";
811

912
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
1013
return typedjson({
11-
version: VERSION,
14+
buildInfo: {
15+
appVersion: process.env.BUILD_APP_VERSION,
16+
packageVersion: coreVersion,
17+
gitSha: process.env.BUILD_GIT_SHA,
18+
gitRefName: process.env.BUILD_GIT_REF_NAME,
19+
buildTimestampSeconds: process.env.BUILD_TIMESTAMP_SECONDS,
20+
} satisfies BuildInfo,
1221
});
1322
};
1423

1524
export default function Page() {
16-
const { version } = useTypedLoaderData<typeof loader>();
25+
const { buildInfo } = useTypedLoaderData<typeof loader>();
1726
const organization = useOrganization();
1827

1928
return (
2029
<AppContainer>
2130
<div className="grid grid-cols-[14rem_1fr] overflow-hidden">
22-
<OrganizationSettingsSideMenu organization={organization} version={version} />
31+
<OrganizationSettingsSideMenu organization={organization} buildInfo={buildInfo} />
2332
<MainBody>
2433
<Outlet />
2534
</MainBody>

docker/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ COPY --from=builder --chown=node:node /triggerdotdev/scripts ./scripts
8282
COPY --from=builder /usr/local/bin/goose /usr/local/bin/goose
8383
COPY --from=builder --chown=node:node /triggerdotdev/internal-packages/clickhouse/schema /triggerdotdev/internal-packages/clickhouse/schema
8484

85+
# Build info
86+
ARG BUILD_APP_VERSION
87+
ARG BUILD_GIT_SHA
88+
ARG BUILD_GIT_REF_NAME
89+
ARG BUILD_TIMESTAMP_SECONDS
90+
ENV BUILD_APP_VERSION=${BUILD_APP_VERSION} \
91+
BUILD_GIT_SHA=${BUILD_GIT_SHA} \
92+
BUILD_GIT_REF_NAME=${BUILD_GIT_REF_NAME} \
93+
BUILD_TIMESTAMP_SECONDS=${BUILD_TIMESTAMP_SECONDS}
94+
8595
EXPOSE 3000
8696

8797
USER node

0 commit comments

Comments
 (0)