Build for Linux #14
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 for Linux | |
| on: | |
| # Enable manual run | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - "**" | |
| branches: | |
| - "**" | |
| paths: | |
| - .github/workflows/linux.yml | |
| jobs: | |
| build-linux: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - runs-on: ubuntu-latest | |
| cache-name: TimingTrainer | |
| target-platform: linux-x64 | |
| flutter-output-folder: build/linux/x64/release/bundle | |
| archive-suffix: x86_64 | |
| - runs-on: ubuntu-24.04-arm | |
| cache-name: TimingTrainerArm64 | |
| target-platform: linux-arm64 | |
| flutter-output-folder: build/linux/arm64/release/bundle | |
| archive-suffix: arm64 | |
| runs-on: ${{ matrix.arch.runs-on }} | |
| permissions: | |
| contents: write | |
| timeout-minutes: 20 | |
| name: Build Linux (${{ matrix.arch.target-platform }}) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Install apt dependencies | |
| uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev | |
| version: 1.0 | |
| execute_install_scripts: true | |
| - name: Setup cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| .dart_tool/ | |
| build/ | |
| linux/flutter/ephemeral/ | |
| macos/Flutter/ephemeral/ | |
| windows/flutter/ephemeral/ | |
| .flutter-plugins-dependencies | |
| key: ${{ runner.OS }}-${{ matrix.arch.cache-name }}-${{ hashFiles('**/pubspec.lock') }}-${{ hashFiles('**/*.dart') }} | |
| restore-keys: | | |
| ${{ runner.OS }}-${{ matrix.arch.cache-name }}- | |
| - name: Remove dev dependencies | |
| run: ./patches/remove_dev_dependencies.sh | |
| - name: Setup Flutter submodule | |
| uses: adil192/setup-flutter-submodule@v1 | |
| with: | |
| flutter-path: submodules/flutter | |
| - name: Disable Flutter CLI animations | |
| run: flutter config --no-cli-animations | |
| - run: flutter pub get | |
| - name: Build Linux (${{ matrix.arch.target-platform }}) | |
| run: | | |
| flutter build linux \ | |
| --target-platform ${{ matrix.arch.target-platform }} | |
| - name: Compress Flutter build | |
| id: compress | |
| run: | | |
| buildName=$(grep -oP '(?<=version: ).*(?=\+)' pubspec.yaml) | |
| archiveName="TimingTrainer_v${buildName}_Linux_${{ matrix.arch.archive-suffix }}.tar.gz" | |
| echo "archiveName=$archiveName" >> $GITHUB_OUTPUT | |
| mkdir -p AppDir | |
| mv ${{ matrix.arch.flutter-output-folder }}/* AppDir | |
| chmod +x AppDir/timing_flutter | |
| install -Dm644 flatpak/com.adilhanney.timing.metainfo.xml -t AppDir/share/metainfo/ | |
| install -Dm644 flatpak/com.adilhanney.timing.metainfo.xml -t AppDir/usr/share/metainfo/ | |
| install -Dm644 assets/icon/icon.svg AppDir/share/icons/hicolor/scalable/apps/com.adilhanney.timing.svg | |
| install -Dm644 assets/icon/icon.svg AppDir/usr/share/icons/hicolor/scalable/apps/com.adilhanney.timing.svg | |
| install -Dm644 flatpak/com.adilhanney.timing.desktop -t AppDir/share/applications/ | |
| tar -C AppDir -czvf $archiveName . | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: TimingTrainer-Archive-${{ matrix.arch.archive-suffix }} | |
| path: ${{ steps.compress.outputs.archiveName }} | |
| - name: Upload to GitHub release | |
| uses: svenstaro/upload-release-action@v2 | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ${{ steps.compress.outputs.archiveName }} |