From 1115d30030bcb67cc4b982bbb48f8cd390e990d5 Mon Sep 17 00:00:00 2001 From: zwtesttt <107228797+zwtesttt@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:56:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E6=96=87=E4=BB=B6=20(#27)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-android.yaml | 101 +++++++++++++++++++++++++++ .gitignore | 4 ++ Dockerfile | 3 +- 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-android.yaml diff --git a/.github/workflows/build-android.yaml b/.github/workflows/build-android.yaml new file mode 100644 index 00000000..3878c215 --- /dev/null +++ b/.github/workflows/build-android.yaml @@ -0,0 +1,101 @@ +name: Build Android +run-name: Creating Production Ready Android App 🚀 +on: push + +jobs: + build: + name: Build APK + runs-on: ubuntu-latest + # TODO: add the default directory - COMMENT IF IT'S NOT IN SUBFOLDER + # defaults: + # run: + # working-directory: ./frontend + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: "17" + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + + - name: Install pnpm + run: npm install -g pnpm --registry http://registry.npmmirror.com + + - name: install dependencies + run: pnpm i + + - name: Create Build Folder + run: npm run build + + - name: Add android folder if not present + run: if [ ! -d "./android" ]; then npx cap add android; fi + + - name: Capacitor update + run: npx cap update + + - name: Capacitor copy + run: npx cap copy + + # TODO: Check for folder structure in README for generating splash screen + - name: Generate icons and splash screen to android folder + run: if [ -d "./resources" ]; then npm install @capacitor/assets --save-dev && npx capacitor-assets generate --android; fi + + - name: Build app bundle + run: cd android && ./gradlew bundle && ./gradlew assembleDebug + + - name: Extract Android signing key from env + run: | + echo "${{ secrets.RELEASE_KEYSTORE }}" > android/release.jks.base64 + base64 -d android/release.jks.base64 > android/release.decrypted.jks + + - name: Sign dev build + run: jarsigner -keystore android/release.decrypted.jks -storepass "${{ secrets.RELEASE_KEYSTORE_PASSWORD }}" -signedjar ./android/app/build/outputs/bundle/release/app-release-signed.aab ./android/app/build/outputs/bundle/release/app-release.aab release + + - name: Check folder content of android output + run: ls ./android/app/build/outputs/bundle/release + + - name: Set version + id: version + run: echo "VERSION=v0.0.${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + with: + tag_name: ${{ steps.version.outputs.VERSION }} + release_name: Release ${{ steps.version.outputs.VERSION }} + draft: false + prerelease: true + + - name: Upload Release Asset .aab + id: upload-release-asset-aab + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./android/app/build/outputs/bundle/release/app-release-signed.aab + # Customize the asset name. If not specified, the file name is used. + asset_name: app-release-signed.aab + asset_content_type: application/zip + + - name: Upload Release Asset .apk + id: upload-release-asset-apk + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./android/app/build/outputs/apk/debug/app-debug.apk + # Customize the asset name. If not specified, the file name is used. + asset_name: app-debug.apk + asset_content_type: application/vnd.android.package-archive \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6d4f8d2e..edf64563 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,7 @@ release *.njsproj *.sln *.sw? + +#build-android +release.jks +release.jks.base64 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ed182a4b..3a408fdc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,9 @@ WORKDIR /app COPY package*.json ./ # 安装依赖 -RUN npm install --registry http://registry.npmmirror.com +RUN npm install -g pnpm --registry http://registry.npmmirror.com +RUN pnpm i # 复制项目文件到工作目录 COPY . .