Build Platform-Specific Artifacts #37
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 Platform-Specific Artifacts | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| os: | |
| description: 'OS to build for (windows-latest, ubuntu-22.04, macos-latest)' | |
| required: false | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - windows-latest | |
| - ubuntu-22.04 | |
| - macos-latest | |
| jobs: | |
| build-windows: | |
| if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.os == 'all' || github.event.inputs.os == 'windows-latest' }} | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Strawberry Perl | |
| run: choco install strawberryperl | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| flutter-version: 3.35.1 | |
| cache: true | |
| - name: Prepare pubspec.yaml for Windows | |
| shell: pwsh | |
| run: | | |
| (Get-Content pubspec.yaml) | ForEach-Object { | |
| $_ -replace ' - assets/exec/linux/', '# - assets/exec/linux/' ` | |
| -replace ' - assets/exec/mac-intel/', '# - assets/exec/mac-intel/' ` | |
| -replace ' - assets/exec/mac-apple/', '# - assets/exec/mac-apple/' | |
| } | Set-Content pubspec.yaml | |
| echo "--- Modified pubspec.yaml for Windows build ---" | |
| type pubspec.yaml | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build application (Windows) | |
| run: flutter build windows --release | |
| - name: Upload Windows Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: build/windows/x64/runner/Release/ | |
| if-no-files-found: error | |
| build-linux: | |
| if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.os == 'all' || github.event.inputs.os == 'ubuntu-22.04' }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| flutter-version: 3.35.1 | |
| cache: true | |
| - name: Prepare pubspec.yaml for Linux | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libayatana-appindicator3-dev | |
| sed -i -e 's| - assets/exec/windows/|# - assets/exec/windows/|' \ | |
| -e 's| - assets/exec/mac-intel/|# - assets/exec/mac-intel/|' \ | |
| -e 's| - assets/exec/mac-apple/|# - assets/exec/mac-apple/|' pubspec.yaml | |
| echo "--- Modified pubspec.yaml for Linux build ---" | |
| cat pubspec.yaml | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build application (Linux) | |
| run: flutter build linux --release | |
| - name: Upload Linux Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: build/linux/x64/release/bundle/ | |
| if-no-files-found: error | |
| build-macos: | |
| if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.os == 'all' || github.event.inputs.os == 'macos-latest' }} | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| flutter-version: 3.35.1 | |
| cache: true | |
| - name: Prepare pubspec.yaml for macOS | |
| run: | | |
| sed -i '' -e 's| - assets/exec/windows/|# - assets/exec/windows/|' \ | |
| -e 's| - assets/exec/linux/|# - assets/exec/linux/|' pubspec.yaml | |
| echo "--- Modified pubspec.yaml for macOS build ---" | |
| cat pubspec.yaml | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build application (macOS) | |
| run: flutter build macos --release | |
| - name: Zip macOS App Bundle | |
| run: | | |
| APP_PATH="build/macos/Build/Products/Release/Scrcpy GUI.app" | |
| ZIP_NAME="macos-Scrcpy-GUI.zip" | |
| cd "$(dirname "$APP_PATH")" | |
| zip -r "$ZIP_NAME" "$(basename "$APP_PATH")" | |
| echo "Zip file created at: $(pwd)/$ZIP_NAME" | |
| - name: Upload macOS Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: build/macos/Build/Products/Release/macos-Scrcpy-GUI.zip | |
| if-no-files-found: error |