Add community post and reply moderation #250
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Android APK | |
| on: | |
| workflow_dispatch: # 手动触发 | |
| pull_request: | |
| branches: ["main"] | |
| paths: | |
| - 'lib/**' | |
| - 'android/**' | |
| - 'rust/**' | |
| - 'pubspec.yaml' | |
| - 'pubspec.lock' | |
| - '.github/workflows/build_android_apk.yml' | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - 'lib/**' | |
| - 'android/**' | |
| - 'rust/**' | |
| - 'pubspec.yaml' | |
| - 'pubspec.lock' | |
| - '.github/workflows/build_android_apk.yml' | |
| jobs: | |
| build-unsigned-apk: | |
| name: Build Unsigned APK | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v5 | |
| with: | |
| lfs: false | |
| fetch-depth: 0 | |
| - name: Restore Git LFS Cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: .git/lfs/objects | |
| key: lfs-android-${{ runner.os }}-${{ hashFiles('android/app/src/main/jniLibs/**', 'android/app/src/main/res/**') }} | |
| restore-keys: | | |
| lfs-android-${{ runner.os }}- | |
| - name: Pull Required Git LFS Files | |
| run: | | |
| git lfs install --local | |
| git lfs pull --include="android/app/src/main/jniLibs,android/app/src/main/res" --exclude="" | |
| - name: Set Build Metadata | |
| run: | | |
| set -euo pipefail | |
| git fetch --no-tags origin main:refs/remotes/origin/main | |
| if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
| BUILD_NUMBER="$(git rev-list --count origin/main)" | |
| BUILD_CHANNEL="pr" | |
| BUILD_LABEL="PR #${{ github.event.pull_request.number }}" | |
| elif [ "$GITHUB_REF_NAME" = "main" ]; then | |
| BUILD_NUMBER="$(git rev-list --count HEAD)" | |
| BUILD_CHANNEL="main" | |
| BUILD_LABEL="Build $BUILD_NUMBER" | |
| else | |
| BUILD_NUMBER="$(git rev-list --count origin/main)" | |
| BUILD_CHANNEL="branch" | |
| BUILD_LABEL="$GITHUB_REF_NAME" | |
| fi | |
| { | |
| echo "BUILD_NUMBER=$BUILD_NUMBER" | |
| echo "BUILD_CHANNEL=$BUILD_CHANNEL" | |
| echo "BUILD_LABEL=$BUILD_LABEL" | |
| } >> "$GITHUB_ENV" | |
| # 配置 Java 环境 | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| # 配置 Flutter | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| flutter-version: '3.44.0' | |
| cache: true | |
| # 获取依赖 | |
| - name: Flutter Pub Get | |
| run: flutter pub get | |
| # 构建免签 APK | |
| - name: Build Unsigned APK | |
| env: | |
| RENA_ENDPOINT: ${{ secrets.RENA_ENDPOINT }} | |
| RENA_PUBLIC_WRITE_KEY: ${{ secrets.RENA_PUBLIC_WRITE_KEY }} | |
| run: | | |
| flutter build apk --release --verbose \ | |
| --build-number="$BUILD_NUMBER" \ | |
| --dart-define=BUILD_CHANNEL="$BUILD_CHANNEL" \ | |
| --dart-define=BUILD_LABEL="$BUILD_LABEL" \ | |
| --dart-define=RENA_ENDPOINT="$RENA_ENDPOINT" \ | |
| --dart-define=RENA_PUBLIC_WRITE_KEY="$RENA_PUBLIC_WRITE_KEY" | |
| # 重命名 APK | |
| - name: Rename APK | |
| run: | | |
| APK_PATH="$(find build/app/outputs/flutter-apk -maxdepth 1 -type f -name 'app-release*.apk' -print -quit)" | |
| test -n "$APK_PATH" | |
| cp "$APK_PATH" novella-unsigned.apk | |
| # 上传产物 | |
| - name: Upload APK | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: novella-android-unsigned-apk | |
| path: novella-unsigned.apk | |
| build-signed-apk: | |
| name: Build Signed APK | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v5 | |
| with: | |
| lfs: false | |
| fetch-depth: 0 | |
| - name: Restore Git LFS Cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: .git/lfs/objects | |
| key: lfs-android-${{ runner.os }}-${{ hashFiles('android/app/src/main/jniLibs/**', 'android/app/src/main/res/**') }} | |
| restore-keys: | | |
| lfs-android-${{ runner.os }}- | |
| - name: Pull Required Git LFS Files | |
| run: | | |
| git lfs install --local | |
| git lfs pull --include="android/app/src/main/jniLibs,android/app/src/main/res" --exclude="" | |
| - name: Set Build Metadata | |
| run: | | |
| set -euo pipefail | |
| git fetch --no-tags origin main:refs/remotes/origin/main | |
| if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
| BUILD_NUMBER="$(git rev-list --count origin/main)" | |
| BUILD_CHANNEL="pr" | |
| BUILD_LABEL="PR #${{ github.event.pull_request.number }}" | |
| elif [ "$GITHUB_REF_NAME" = "main" ]; then | |
| BUILD_NUMBER="$(git rev-list --count HEAD)" | |
| BUILD_CHANNEL="main" | |
| BUILD_LABEL="Build $BUILD_NUMBER" | |
| else | |
| BUILD_NUMBER="$(git rev-list --count origin/main)" | |
| BUILD_CHANNEL="branch" | |
| BUILD_LABEL="$GITHUB_REF_NAME" | |
| fi | |
| { | |
| echo "BUILD_NUMBER=$BUILD_NUMBER" | |
| echo "BUILD_CHANNEL=$BUILD_CHANNEL" | |
| echo "BUILD_LABEL=$BUILD_LABEL" | |
| } >> "$GITHUB_ENV" | |
| # 配置 Java 环境 | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| # 配置 Flutter | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| flutter-version: '3.44.0' | |
| cache: true | |
| # 获取依赖 | |
| - name: Flutter Pub Get | |
| run: flutter pub get | |
| # 还原 Release Keystore | |
| - name: Decode Keystore | |
| env: | |
| ENCODED_STRING: ${{ secrets.KEYSTORE_BASE64 }} | |
| run: | | |
| printf '%s' "$ENCODED_STRING" | base64 --decode > android/app/release.keystore | |
| # 构建 APK | |
| - name: Build Android APK | |
| env: | |
| KEYSTORE_FILE: release.keystore | |
| KEYSTORE_PASSWORD: ${{ secrets.STORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| RENA_ENDPOINT: ${{ secrets.RENA_ENDPOINT }} | |
| RENA_PUBLIC_WRITE_KEY: ${{ secrets.RENA_PUBLIC_WRITE_KEY }} | |
| run: | | |
| set -euo pipefail | |
| if [ -z "${RENA_ENDPOINT:-}" ]; then | |
| echo "::error::Missing RENA_ENDPOINT secret." | |
| exit 1 | |
| fi | |
| if [ -z "${RENA_PUBLIC_WRITE_KEY:-}" ]; then | |
| echo "::error::Missing RENA_PUBLIC_WRITE_KEY secret." | |
| exit 1 | |
| fi | |
| flutter build apk --release --verbose \ | |
| --build-number="$BUILD_NUMBER" \ | |
| --dart-define=BUILD_CHANNEL="$BUILD_CHANNEL" \ | |
| --dart-define=BUILD_LABEL="$BUILD_LABEL" \ | |
| --dart-define=RENA_ENDPOINT="$RENA_ENDPOINT" \ | |
| --dart-define=RENA_PUBLIC_WRITE_KEY="$RENA_PUBLIC_WRITE_KEY" | |
| # 重命名 APK | |
| - name: Rename APK | |
| run: | | |
| cp build/app/outputs/flutter-apk/app-release.apk novella.apk | |
| # 上传产物 | |
| - name: Upload APK | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: novella-android-signed-apk | |
| path: novella.apk |