feat: 添加日志导出功能并统一使用全局logger #13
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 and Release | |
| permissions: | |
| contents: write | |
| actions: read | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| - "v*.*.*-beta*" | |
| jobs: | |
| build: | |
| name: Build and Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "zulu" | |
| java-version: "17" | |
| - name: Cache Flutter SDK | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.pub-cache | |
| ${{ runner.tool_cache }}/flutter | |
| key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-flutter- | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: "3.32.2" | |
| channel: "stable" | |
| cache: true | |
| - name: Cache Pub dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.pub-cache | |
| .dart_tool | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| TAG=${GITHUB_REF#refs/tags/v} | |
| echo "version=$TAG" >> $GITHUB_OUTPUT | |
| echo "Version: $TAG" | |
| - name: Update version in pubspec.yaml | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| sed -i "s/^version: .*/version: $VERSION/" pubspec.yaml | |
| - name: Commit version updates | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add pubspec.yaml | |
| git commit -m "chore: update version to ${{ steps.version.outputs.version }}" || exit 0 | |
| git push origin HEAD:main || exit 0 | |
| - name: Cache Gradle dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| ~/.android/build-cache | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Setup signingQueue | |
| run: | | |
| echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/release-key.jks | |
| echo "storeFile=release-key.jks" > key.properties | |
| echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" >> key.properties | |
| echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> key.properties | |
| echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> key.properties | |
| - name: Build signed APK | |
| run: flutter build apk --release | |
| - name: Build App Bundle | |
| continue-on-error: true | |
| run: flutter build appbundle --release | |
| - name: Clean up signing files | |
| run: | | |
| rm -f android/app/release-key.jks | |
| rm -f android/key.properties | |
| - name: Build iOS (if on macOS) | |
| if: runner.os == 'macOS' | |
| continue-on-error: true | |
| run: | | |
| flutter build ios --release --no-codesign | |
| - name: Build Web | |
| continue-on-error: true | |
| run: flutter build web --release | |
| - name: Cache Linux dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| /var/cache/apt | |
| /var/lib/apt | |
| key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/release.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt- | |
| - name: Build Linux | |
| continue-on-error: true | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev | |
| flutter build linux --release | |
| - name: Create release archive | |
| run: | | |
| mkdir -p release-files | |
| cp build/app/outputs/flutter-apk/app-release.apk release-files/readeck-app-${{ steps.version.outputs.version }}.apk | |
| cp build/app/outputs/bundle/release/app-release.aab release-files/readeck-app-${{ steps.version.outputs.version }}.aab | |
| # Package web build | |
| cd build/web | |
| tar -czf ../../release-files/readeck-app-web-${{ steps.version.outputs.version }}.tar.gz . | |
| cd ../.. | |
| # Package Linux build | |
| cd build/linux/x64/release/bundle | |
| tar -czf ../../../../../release-files/readeck-app-linux-${{ steps.version.outputs.version }}.tar.gz . | |
| cd ../../../../.. | |
| - name: Determine if prerelease | |
| id: prerelease | |
| run: | | |
| if [[ "${{ steps.version.outputs.version }}" == *"beta"* ]]; then | |
| echo "prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "prerelease=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Release v${{ steps.version.outputs.version }} | |
| body: | | |
| ## Readeck APP v${{ steps.version.outputs.version }} | |
| ### 📱 下载链接 | |
| - **Android APK**: readeck-app-${{ steps.version.outputs.version }}.apk | |
| - **Android App Bundle**: readeck-app-${{ steps.version.outputs.version }}.aab | |
| - **Web版本**: readeck-app-web-${{ steps.version.outputs.version }}.tar.gz | |
| - **Linux版本**: readeck-app-linux-${{ steps.version.outputs.version }}.tar.gz | |
| ### 🔄 更新内容 | |
| 请查看提交历史了解详细更新内容。 | |
| ### 📋 安装说明 | |
| - **Android**: 下载APK文件直接安装 | |
| - **Web**: 解压tar.gz文件并部署到Web服务器 | |
| - **Linux**: 解压tar.gz文件并运行可执行文件 | |
| files: | | |
| release-files/* | |
| prerelease: ${{ steps.prerelease.outputs.prerelease }} | |
| draft: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |