Add live update info

This commit is contained in:
MartinBraquet
2025-12-15 16:49:15 +02:00
parent 58c005194c
commit a677df2fdd
5 changed files with 47 additions and 12 deletions

View File

@@ -1,3 +1,3 @@
{
"version": 12
"version": 13
}

View File

@@ -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 <<EOF > 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

3
web/.gitignore vendored
View File

@@ -8,4 +8,5 @@ tsconfig.tsbuildinfo
testing
.env
.env.local
.env.local
/public/live-update.json

View File

@@ -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
}
}
}

12
web/lib/live-update.ts Normal file
View File

@@ -0,0 +1,12 @@
type BuildInfo = {
commitSha: string;
commitRef: string;
commitMessage: string;
commitDate: string;
buildDate: string;
};
export async function getLiveUpdateInfo(): Promise<BuildInfo> {
const res = await fetch("/live-update.json", { cache: "no-store" });
return res.json();
}