chore(mobile): 瘦身移动端包体积(预期减少 50%~60%) #39
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: Test Build (feat/test) | |
| on: | |
| push: | |
| branches: | |
| - "feat/test" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-desktop: | |
| name: Build Desktop (${{ matrix.platform }}) | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| platform: mac | |
| command: build:mac | |
| - os: windows-latest | |
| platform: win | |
| command: build:win | |
| - os: ubuntu-latest | |
| platform: linux | |
| command: build:linux | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| env: | |
| NPM_CONFIG_REGISTRY: https://registry.npmjs.org/ | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build Desktop App | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: pnpm --filter @bookdock/desktop run ${{ matrix.command }} | |
| - name: Upload Release Assets (Draft) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: test-build | |
| name: Test Build (feat/test) | |
| draft: true | |
| files: | | |
| apps/desktop/release/*.dmg | |
| apps/desktop/release/*.zip | |
| apps/desktop/release/*.exe | |
| apps/desktop/release/*.AppImage | |
| apps/desktop/release/*.deb | |
| apps/desktop/release/*.blockmap | |
| apps/desktop/release/latest*.yml | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-android: | |
| name: Build Android | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "zulu" | |
| java-version: "17" | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| env: | |
| NPM_CONFIG_REGISTRY: https://registry.npmjs.org/ | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build Android APK | |
| run: | | |
| cd apps/mobile/android | |
| chmod +x gradlew | |
| ./gradlew assembleRelease | |
| - name: Rename and Prepare APK | |
| id: prepare_apk | |
| run: | | |
| VERSION=$(node -p "require('./apps/mobile/app.json').expo.version") | |
| OLD_PATH="apps/mobile/android/app/build/outputs/apk/release/app-release.apk" | |
| NEW_NAME="BookDock-${VERSION}-test.apk" | |
| NEW_PATH="apps/mobile/android/app/build/outputs/apk/release/${NEW_NAME}" | |
| mv "$OLD_PATH" "$NEW_PATH" | |
| echo "apk_path=$NEW_PATH" >> $GITHUB_OUTPUT | |
| - name: Upload Release Assets (Draft) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: test-build | |
| name: Test Build (feat/test) | |
| draft: true | |
| files: | | |
| ${{ steps.prepare_apk.outputs.apk_path }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| build-server-docker: | |
| name: Build & Push Server Docker (feat-test) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Log in to Harbor | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ secrets.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Set lowercase image name | |
| id: image_name | |
| run: | | |
| REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| NAME_LOWER=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]') | |
| OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | |
| DOCKERHUB_USER_LOWER=$(echo "${{ secrets.DOCKERHUB_USERNAME }}" | tr '[:upper:]' '[:lower:]') | |
| echo "ghcr=${REGISTRY}/${REPO_LOWER}" >> $GITHUB_OUTPUT | |
| echo "dockerhub=${DOCKERHUB_USER_LOWER}/${NAME_LOWER}" >> $GITHUB_OUTPUT | |
| echo "harbor=${{ secrets.HARBOR_REGISTRY }}/audiodock/${NAME_LOWER}" >> $GITHUB_OUTPUT | |
| env: | |
| REGISTRY: ghcr.io | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| target: runner | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ steps.image_name.outputs.ghcr }}:feat-test | |
| ${{ steps.image_name.outputs.dockerhub }}:feat-test | |
| ${{ steps.image_name.outputs.harbor }}:feat-test |