Skip to content

Commit 8afea75

Browse files
committed
Merge branch 'dev'
2 parents 1445900 + d5d3d04 commit 8afea75

5 files changed

Lines changed: 322 additions & 129 deletions

File tree

‎.github/workflows/mobile-release.yml‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,75 @@ jobs:
9898
sleep 5
9999
curl -sf https://entropydecrease.com/pwa/ | grep -q "熵减" || exit 1
100100
echo "PWA deployed: ${{ github.ref_name }}"
101+
102+
# ---------------------------------------------------------------------------
103+
# Android APK(B 方案:TWA 打包):bubblewrap 基于已部署的 PWA manifest
104+
# 生成 TWA 工程并构建签名 APK,上传 GitHub Release + 服务器下载目录
105+
# (官网「下载 Android APK」直链 = entropydecrease.com/downloads/entropydecrease.apk)。
106+
#
107+
# ⚠️ 首次设置(一次性,需 Android/Java 环境,完成后 CI 全自动):
108+
# 1. 生成 keystore:keytool -genkey -v -keystore entropydecrease.keystore
109+
# -alias entropydecrease -keyalg RSA -keysize 2048 -validity 10000
110+
# 2. 生成 TWA 工程(读 android/twa-manifest.json 配置):
111+
# npx @bubblewrap/cli init --manifest
112+
# https://entropydecrease.com/pwa/manifest.webmanifest --directory android/twa
113+
# 并把生成的 android/twa/ 提交到仓库(CI 只做非交互 update + build)
114+
# 3. GitHub Secrets:ANDROID_KEYSTORE_BASE64(keystore base64)、
115+
# ANDROID_KEYSTORE_PASS(keystore 密码)、ANDROID_KEY_PASS(key 密码)
116+
# ---------------------------------------------------------------------------
117+
build-apk:
118+
needs: deploy
119+
runs-on: ubuntu-latest
120+
timeout-minutes: 30
121+
steps:
122+
- uses: actions/checkout@v4
123+
- uses: actions/setup-java@v4
124+
with:
125+
distribution: temurin
126+
java-version: '17'
127+
- uses: actions/setup-node@v4
128+
with:
129+
node-version: 20
130+
- uses: android-actions/setup-android@v3
131+
- name: Install bubblewrap
132+
run: npm i -g @bubblewrap/cli
133+
- name: Write signing keystore from secrets
134+
env:
135+
KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
136+
run: |
137+
if [ -z "$KEYSTORE_B64" ]; then
138+
echo "::error::ANDROID_KEYSTORE_BASE64 未配置(见 job 注释首次设置),跳过 APK 构建"
139+
exit 0
140+
fi
141+
echo "$KEYSTORE_B64" | base64 -d > /tmp/entropydecrease.keystore
142+
- name: Update TWA project to latest PWA
143+
run: |
144+
cd android
145+
bubblewrap update \
146+
--manifest https://entropydecrease.com/pwa/manifest.webmanifest \
147+
--directory twa
148+
- name: Build signed APK
149+
env:
150+
KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
151+
KEY_PASS: ${{ secrets.ANDROID_KEY_PASS }}
152+
run: |
153+
cd android/twa
154+
bubblewrap build \
155+
--keystorePath /tmp/entropydecrease.keystore \
156+
--keystorePass "$KEYSTORE_PASS" \
157+
--keyAlias entropydecrease \
158+
--keyPass "$KEY_PASS"
159+
- name: Verify APK artifact
160+
run: test -f android/twa/app-release-signed.apk && echo "APK OK"
161+
- name: Upload APK to GitHub Release
162+
uses: softprops/action-gh-release@v2
163+
with:
164+
files: android/twa/app-release-signed.apk
165+
- name: Upload APK to server downloads
166+
uses: appleboy/scp-action@v0.1.7
167+
with:
168+
host: ${{ secrets.SERVER_HOST }}
169+
username: ${{ secrets.SERVER_USER }}
170+
key: ${{ secrets.SSH_PRIVATE_KEY }}
171+
source: android/twa/app-release-signed.apk
172+
target: /opt/Entropydecrease/downloads

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,6 @@ missing_ai_context.txt
7373

7474
# 音效源文件备份(42 个 wav,零代码引用,勿再提交)
7575
client/public/sounds/_backup_original/
76+
77+
# Android ǩ����Կ���Ͻ��ύ��
78+
android/keystore/

‎android/twa-manifest.json‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"packageId": "com.entropydecrease.app",
3+
"host": "entropydecrease.com",
4+
"name": "熵减",
5+
"launcherName": "熵减",
6+
"display": "standalone",
7+
"themeColor": "#3B82F6",
8+
"navigationColor": "#111827",
9+
"backgroundColor": "#111827",
10+
"enableNotifications": true,
11+
"startUrl": "/pwa/",
12+
"iconUrl": "https://entropydecrease.com/pwa/pwa-512x512.png",
13+
"maskableIconUrl": "https://entropydecrease.com/pwa/pwa-512x512.png",
14+
"splashScreenFadeOutDuration": 300,
15+
"signingKey": {
16+
"path": "/tmp/entropydecrease.keystore",
17+
"alias": "entropydecrease"
18+
},
19+
"appVersionName": "0.37.0",
20+
"appVersionCode": 37,
21+
"shortcuts": [],
22+
"generatorApp": "bubblewrap-cli",
23+
"webManifestUrl": "https://entropydecrease.com/pwa/manifest.webmanifest",
24+
"fallbackType": "customtabs",
25+
"features": {},
26+
"alphaDependencies": {
27+
"enabled": false
28+
},
29+
"enableSiteSettingsShortcut": true,
30+
"isChromeOSOnly": false,
31+
"isMetaQuest": false,
32+
"fullScopeUrl": "https://entropydecrease.com/pwa/",
33+
"minSdkVersion": 21,
34+
"orientation": "portrait",
35+
"fingerprints": [],
36+
"additionalTrustedOrigins": [],
37+
"retainedBundles": []
38+
}

0 commit comments

Comments
 (0)