From a677df2fdd613f4f7febe079ab3f7b34a91f1130 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Mon, 15 Dec 2025 16:49:15 +0200 Subject: [PATCH] Add live update info --- android/capawesome.json | 2 +- scripts/android_live_update.sh | 32 ++++++++++++++++++++++++------- web/.gitignore | 3 ++- web/components/about-settings.tsx | 10 +++++++--- web/lib/live-update.ts | 12 ++++++++++++ 5 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 web/lib/live-update.ts diff --git a/android/capawesome.json b/android/capawesome.json index 4b4f7e60..36c5909b 100644 --- a/android/capawesome.json +++ b/android/capawesome.json @@ -1,3 +1,3 @@ { - "version": 12 + "version": 13 } \ No newline at end of file diff --git a/scripts/android_live_update.sh b/scripts/android_live_update.sh index f99e097c..a92d2e91 100755 --- a/scripts/android_live_update.sh +++ b/scripts/android_live_update.sh @@ -4,20 +4,38 @@ set -e cd "$(dirname "$0")"/.. -yarn build-web-view +COMMIT_SHA=$(git rev-parse HEAD) +COMMIT_REF=$(git branch --show-current) +COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") +COMMIT_DATE=$(git log -1 --pretty=format:"%cI") +BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + +cat < web/public/live-update.json +{ + "commitSha": "$COMMIT_SHA", + "commitRef": "$COMMIT_REF", + "commitMessage": "$COMMIT_MESSAGE", + "commitDate": "$COMMIT_DATE", + "buildDate": "$BUILD_DATE" +} +EOF + +cat web/public/live-update.json + +#yarn build-web-view echo npx @capawesome/cli apps:bundles:create \ --app-id 969bc540-8077-492f-8403-b554bee5de50 \ --channel default \ - --commitMessage "$(git log -1 --pretty=format:"%s")" \ - --commitRef $commitRef \ - --commitSha $commitSha \ + --commitMessage "$COMMIT_MESSAGE" \ + --commitRef $COMMIT_REF \ + --commitSha $COMMIT_SHA \ --path web/out npx @capawesome/cli apps:bundles:create \ --app-id 969bc540-8077-492f-8403-b554bee5de50 \ --channel default \ - --commitMessage "$(git log -1 --pretty=format:"%s")" \ - --commitRef $commitRef \ - --commitSha $commitSha \ + --commitMessage "$COMMIT_MESSAGE" \ + --commitRef $COMMIT_REF \ + --commitSha $COMMIT_SHA \ --path web/out diff --git a/web/.gitignore b/web/.gitignore index c612bc22..5a8cd64e 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -8,4 +8,5 @@ tsconfig.tsbuildinfo testing .env -.env.local \ No newline at end of file +.env.local +/public/live-update.json diff --git a/web/components/about-settings.tsx b/web/components/about-settings.tsx index f69b2677..9fcbb599 100644 --- a/web/components/about-settings.tsx +++ b/web/components/about-settings.tsx @@ -10,6 +10,7 @@ import {api} from "web/lib/api" import {githubRepo} from "common/constants" import {CustomLink} from "web/components/links" import {Button} from "web/components/buttons/button" +import {getLiveUpdateInfo} from "web/lib/live-update"; export type WebBuild = { gitSha?: string @@ -22,6 +23,7 @@ export type LiveUpdateInfo = { bundleId?: string | null commitSha?: string commitMessage?: string + commitDate?: string } export type Android = { @@ -75,13 +77,15 @@ function useDiagnostics() { if (Capacitor.isNativePlatform()) { const appInfo = await App.getInfo() const bundle = await LiveUpdate.getCurrentBundle().catch(() => {return {bundleId: null}}) + const buildInfo = await getLiveUpdateInfo().catch(() => null) diagnostics.android = { appVersion: appInfo.version, buildNumber: appInfo.build, liveUpdate: { - bundleId: bundle.bundleId, - commitSha: process.env.CAPAWESOME_BUILD_GIT_COMMIT_SHA || 'N/A', - commitMessage: process.env.CAPAWESOME_BUILD_GIT_COMMIT_MESSAGE || 'N/A', + bundleId: bundle?.bundleId, + commitSha: buildInfo?.commitSha, + commitMessage: buildInfo?.commitMessage, + commitDate: buildInfo?.commitDate } } } diff --git a/web/lib/live-update.ts b/web/lib/live-update.ts new file mode 100644 index 00000000..0ade2162 --- /dev/null +++ b/web/lib/live-update.ts @@ -0,0 +1,12 @@ +type BuildInfo = { + commitSha: string; + commitRef: string; + commitMessage: string; + commitDate: string; + buildDate: string; +}; + +export async function getLiveUpdateInfo(): Promise { + const res = await fetch("/live-update.json", { cache: "no-store" }); + return res.json(); +}