fix(build): fix macOS release crash and reduce Android APK sizes #6
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'pubspec.yaml' | |
| - '.github/workflows/release.yml' | |
| permissions: | |
| contents: write | |
| jobs: | |
| check-version: | |
| name: Check Version or Workflow Change | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| version_changed: ${{ steps.check.outputs.changed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Get current version | |
| id: version | |
| run: | | |
| VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Check if version or workflow changed | |
| id: check | |
| run: | | |
| if git diff HEAD^ HEAD -- pubspec.yaml | grep -q '^+version:'; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| elif git diff HEAD^ HEAD -- .github/workflows/release.yml | grep -q '.'; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Workflow file changed, triggering release" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: check-version | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create and push tag | |
| run: | | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| git tag -a v${{ needs.check-version.outputs.version }} -m "Alpha Release v${{ needs.check-version.outputs.version }}" | |
| git push origin v${{ needs.check-version.outputs.version }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| name: Dester v${{ needs.check-version.outputs.version }} (Alpha) | |
| draft: false | |
| prerelease: true | |
| generate_release_notes: true | |
| body: | | |
| 🚧 **Alpha Development Build** | |
| **Build Information:** | |
| - Commit: ${{ github.sha }} | |
| - Branch: ${{ github.ref_name }} | |
| - Workflow Run: ${{ github.run_number }} | |
| - Build Date: ${{ github.event.head_commit.timestamp }} | |
| **Platform Downloads:** | |
| - **Android**: Download the APK matching your device architecture: | |
| - `arm64-v8a`: Modern 64-bit devices (2017+) - ~30MB | |
| - `armeabi-v7a`: Older 32-bit devices - ~28MB | |
| - `x86_64`: Emulators/Intel devices - ~32MB | |
| - **iOS**: Universal binary for all iOS devices | |
| - **macOS**: Universal binary (Apple Silicon + Intel) - ~103MB | |
| - **Linux**: x64 build - ~32MB | |
| - **Windows**: x64 build - ~25MB | |
| ⚠️ This is an automated alpha release. Expect bugs and breaking changes. | |
| For stable releases, please wait for beta/stable versions. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-android: | |
| name: Build Android | |
| runs-on: ubuntu-latest | |
| needs: [check-version, release] | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build Split APKs (per architecture) | |
| run: flutter build apk --release --split-per-abi | |
| - name: Rename APKs | |
| run: | | |
| cd build/app/outputs/flutter-apk | |
| mv app-armeabi-v7a-release.apk Dester-${{ needs.check-version.outputs.version }}-alpha-Android-armeabi-v7a.apk | |
| mv app-arm64-v8a-release.apk Dester-${{ needs.check-version.outputs.version }}-alpha-Android-arm64-v8a.apk | |
| mv app-x86_64-release.apk Dester-${{ needs.check-version.outputs.version }}-alpha-Android-x86_64.apk | |
| - name: Upload Split APKs to Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| files: | | |
| build/app/outputs/flutter-apk/Dester-${{ needs.check-version.outputs.version }}-alpha-Android-armeabi-v7a.apk | |
| build/app/outputs/flutter-apk/Dester-${{ needs.check-version.outputs.version }}-alpha-Android-arm64-v8a.apk | |
| build/app/outputs/flutter-apk/Dester-${{ needs.check-version.outputs.version }}-alpha-Android-x86_64.apk | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-ios: | |
| name: Build iOS | |
| runs-on: macos-latest | |
| needs: [check-version, release] | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build iOS IPA (no codesign) | |
| run: flutter build ipa --release --no-codesign | |
| - name: Rename IPA | |
| run: | | |
| if ls build/ios/ipa/*.ipa 1> /dev/null 2>&1; then | |
| mv build/ios/ipa/*.ipa build/ios/ipa/Dester-${{ needs.check-version.outputs.version }}-alpha-iOS.ipa | |
| else | |
| echo "No IPA found, creating archive from .app" | |
| cd build/ios/archive/Runner.xcarchive/Products/Applications | |
| zip -r Dester-${{ needs.check-version.outputs.version }}-alpha-iOS.zip Runner.app | |
| mkdir -p ../../../../ipa | |
| mv Dester-${{ needs.check-version.outputs.version }}-alpha-iOS.zip ../../../../ipa/Dester-${{ needs.check-version.outputs.version }}-alpha-iOS.ipa | |
| fi | |
| - name: Upload IPA to Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| files: build/ios/ipa/Dester-${{ needs.check-version.outputs.version }}-alpha-iOS.ipa | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-macos: | |
| name: Build macOS | |
| runs-on: macos-latest | |
| needs: [check-version, release] | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build macOS | |
| run: flutter build macos --release | |
| - name: Create ZIP archive | |
| run: | | |
| cd build/macos/Build/Products/Release | |
| zip -r Dester-${{ needs.check-version.outputs.version }}-alpha-macOS.zip Dester.app | |
| - name: Upload macOS build | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| files: build/macos/Build/Products/Release/Dester-${{ needs.check-version.outputs.version }}-alpha-macOS.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-linux: | |
| name: Build Linux | |
| runs-on: ubuntu-latest | |
| needs: [check-version, release] | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libasound2-dev libmpv-dev | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| - name: Install Flutter dependencies | |
| run: flutter pub get | |
| - name: Build Linux | |
| run: flutter build linux --release | |
| - name: Create archive | |
| run: | | |
| cd build/linux/x64/release/bundle | |
| tar -czf Dester-${{ needs.check-version.outputs.version }}-alpha-Linux.tar.gz * | |
| - name: Upload Linux build | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| files: build/linux/x64/release/bundle/Dester-${{ needs.check-version.outputs.version }}-alpha-Linux.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-windows: | |
| name: Build Windows | |
| runs-on: windows-latest | |
| needs: [check-version, release] | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build Windows | |
| run: flutter build windows --release | |
| - name: Create archive | |
| run: | | |
| Compress-Archive -Path build\windows\x64\runner\Release\* -DestinationPath Dester-${{ needs.check-version.outputs.version }}-alpha-Windows.zip | |
| - name: Upload Windows build | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| files: Dester-${{ needs.check-version.outputs.version }}-alpha-Windows.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |