Skip to content

Commit a677df2

Browse files
committed
Add live update info
1 parent 58c0051 commit a677df2

File tree

5 files changed

+47
-12
lines changed

5 files changed

+47
-12
lines changed

android/capawesome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": 12
2+
"version": 13
33
}

scripts/android_live_update.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,38 @@ set -e
44

55
cd "$(dirname "$0")"/..
66

7-
yarn build-web-view
7+
COMMIT_SHA=$(git rev-parse HEAD)
8+
COMMIT_REF=$(git branch --show-current)
9+
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
10+
COMMIT_DATE=$(git log -1 --pretty=format:"%cI")
11+
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
12+
13+
cat <<EOF > web/public/live-update.json
14+
{
15+
"commitSha": "$COMMIT_SHA",
16+
"commitRef": "$COMMIT_REF",
17+
"commitMessage": "$COMMIT_MESSAGE",
18+
"commitDate": "$COMMIT_DATE",
19+
"buildDate": "$BUILD_DATE"
20+
}
21+
EOF
22+
23+
cat web/public/live-update.json
24+
25+
#yarn build-web-view
826

927
echo npx @capawesome/cli apps:bundles:create \
1028
--app-id 969bc540-8077-492f-8403-b554bee5de50 \
1129
--channel default \
12-
--commitMessage "$(git log -1 --pretty=format:"%s")" \
13-
--commitRef $commitRef \
14-
--commitSha $commitSha \
30+
--commitMessage "$COMMIT_MESSAGE" \
31+
--commitRef $COMMIT_REF \
32+
--commitSha $COMMIT_SHA \
1533
--path web/out
1634

1735
npx @capawesome/cli apps:bundles:create \
1836
--app-id 969bc540-8077-492f-8403-b554bee5de50 \
1937
--channel default \
20-
--commitMessage "$(git log -1 --pretty=format:"%s")" \
21-
--commitRef $commitRef \
22-
--commitSha $commitSha \
38+
--commitMessage "$COMMIT_MESSAGE" \
39+
--commitRef $COMMIT_REF \
40+
--commitSha $COMMIT_SHA \
2341
--path web/out

web/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ tsconfig.tsbuildinfo
88
testing
99

1010
.env
11-
.env.local
11+
.env.local
12+
/public/live-update.json

web/components/about-settings.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {api} from "web/lib/api"
1010
import {githubRepo} from "common/constants"
1111
import {CustomLink} from "web/components/links"
1212
import {Button} from "web/components/buttons/button"
13+
import {getLiveUpdateInfo} from "web/lib/live-update";
1314

1415
export type WebBuild = {
1516
gitSha?: string
@@ -22,6 +23,7 @@ export type LiveUpdateInfo = {
2223
bundleId?: string | null
2324
commitSha?: string
2425
commitMessage?: string
26+
commitDate?: string
2527
}
2628

2729
export type Android = {
@@ -75,13 +77,15 @@ function useDiagnostics() {
7577
if (Capacitor.isNativePlatform()) {
7678
const appInfo = await App.getInfo()
7779
const bundle = await LiveUpdate.getCurrentBundle().catch(() => {return {bundleId: null}})
80+
const buildInfo = await getLiveUpdateInfo().catch(() => null)
7881
diagnostics.android = {
7982
appVersion: appInfo.version,
8083
buildNumber: appInfo.build,
8184
liveUpdate: {
82-
bundleId: bundle.bundleId,
83-
commitSha: process.env.CAPAWESOME_BUILD_GIT_COMMIT_SHA || 'N/A',
84-
commitMessage: process.env.CAPAWESOME_BUILD_GIT_COMMIT_MESSAGE || 'N/A',
85+
bundleId: bundle?.bundleId,
86+
commitSha: buildInfo?.commitSha,
87+
commitMessage: buildInfo?.commitMessage,
88+
commitDate: buildInfo?.commitDate
8589
}
8690
}
8791
}

web/lib/live-update.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type BuildInfo = {
2+
commitSha: string;
3+
commitRef: string;
4+
commitMessage: string;
5+
commitDate: string;
6+
buildDate: string;
7+
};
8+
9+
export async function getLiveUpdateInfo(): Promise<BuildInfo> {
10+
const res = await fetch("/live-update.json", { cache: "no-store" });
11+
return res.json();
12+
}

0 commit comments

Comments
 (0)