|
98 | 98 | sleep 5 |
99 | 99 | curl -sf https://entropydecrease.com/pwa/ | grep -q "熵减" || exit 1 |
100 | 100 | 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 |
0 commit comments