From e3e67f5b293f92d04ea9e5f7a70c21f9827a8347 Mon Sep 17 00:00:00 2001 From: HendrikRauh <114620133+HendrikRauh@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:40:54 +0100 Subject: [PATCH] Refactor Android CI workflow to use Nix actions and improve translation file collection --- .github/actions/nix-devshell/action.yml | 50 +++++++++++++++++++++++++ .github/workflows/android.yaml | 40 ++++++++++---------- 2 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 .github/actions/nix-devshell/action.yml diff --git a/.github/actions/nix-devshell/action.yml b/.github/actions/nix-devshell/action.yml new file mode 100644 index 0000000..d0f47b1 --- /dev/null +++ b/.github/actions/nix-devshell/action.yml @@ -0,0 +1,50 @@ +name: "nix-devshell" +description: + "Set up Nix, prebuild the devshell and run commands inside the devshell." +inputs: + prebuild: + description: + "Whether to prebuild the devshell (nix develop --command true)." + required: false + default: "false" + commands: + description: + "Commands to run inside the devshell (executed with bash -lc)." + required: false + default: "" + +runs: + using: "composite" + steps: + - name: Install Nix (idempotent) + shell: bash + run: | + set -euo pipefail + if ! command -v nix >/dev/null 2>&1; then + curl -L https://nixos.org/nix/install | sh -s -- --no-daemon + fi + # source the nix profile if present + if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then + . "$HOME/.nix-profile/etc/profile.d/nix.sh" + fi + nix --version + + - name: Prebuild devshell + if: ${{ inputs.prebuild == 'true' }} + shell: bash + run: | + set -euo pipefail + if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then + . "$HOME/.nix-profile/etc/profile.d/nix.sh" + fi + nix --extra-experimental-features 'nix-command flakes' develop --command true + + - name: Run commands in devshell + if: ${{ inputs.commands != '' }} + shell: bash + run: | + set -euo pipefail + if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then + . "$HOME/.nix-profile/etc/profile.d/nix.sh" + fi + nix --extra-experimental-features 'nix-command flakes' develop --command bash -lc "${{ inputs.commands }}" diff --git a/.github/workflows/android.yaml b/.github/workflows/android.yaml index 67afa0c..bc751fe 100644 --- a/.github/workflows/android.yaml +++ b/.github/workflows/android.yaml @@ -11,28 +11,30 @@ jobs: runs-on: ubuntu-latest steps: - - name: Install Nix (for nix usage) - run: | - set -euo pipefail - curl -L https://nixos.org/nix/install | sh -s -- --no-daemon - . "$HOME/.nix-profile/etc/profile.d/nix.sh" - nix --version - - name: Checkout code uses: actions/checkout@v6 + - name: Prepare Nix devshell + uses: ./.github/actions/nix-devshell + with: + prebuild: "true" + - name: Collect Translation Files - run: | - set -euo pipefail - . "$HOME/.nix-profile/etc/profile.d/nix.sh" - nix --version - cd lib/l10n - nix --extra-experimental-features 'nix-command flakes' develop --command python3 collect_translations.py - cd ../.. + uses: ./.github/actions/nix-devshell + with: + commands: | + cd lib/l10n + python3 collect_translations.py - name: Build Debug APK - run: | - set -euo pipefail - . "$HOME/.nix-profile/etc/profile.d/nix.sh" - nix --version - nix --extra-experimental-features 'nix-command flakes' develop --command flutter build apk --debug + uses: ./.github/actions/nix-devshell + with: + commands: | + flutter build apk --debug --target-platform android-arm64 + + - name: Upload APK artifact + uses: actions/upload-artifact@v4 + with: + name: app-debug-apk + path: build/app/outputs/flutter-apk/*.apk + # retention-days: 90