mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-28 17:08:29 +01:00
221 lines
8.6 KiB
YAML
221 lines
8.6 KiB
YAML
name: Update screenshots
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
commit_screenshots:
|
|
description: 'Commit and push screenshots to the repository'
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
screenshots_apple:
|
|
name: 'Apple - ${{ matrix.device.name }}'
|
|
runs-on: macos-latest
|
|
# A clean run takes about 30 minutes, the script may retry a block twice
|
|
timeout-minutes: 75
|
|
strategy:
|
|
# The jobs write into separate folders and a flaky one should not take
|
|
# the healthy ones down with it
|
|
fail-fast: false
|
|
matrix:
|
|
device:
|
|
# Apple only needs the largest device per family, the smaller ones
|
|
# are scaled down by App Store Connect
|
|
- name: "iPhone 6.9in"
|
|
simulator: iPhone 17 Pro Max
|
|
device_type: iOSPhoneBig
|
|
folder: iPhone 6.9
|
|
- name: "iPad 13in"
|
|
simulator: iPad Pro 13-inch
|
|
device_type: iOSTabletBig
|
|
folder: iPad 13
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Common flutter setup
|
|
uses: ./.github/actions/flutter-common
|
|
|
|
- name: Boot iOS simulator
|
|
id: boot
|
|
run: |
|
|
# Match the UDID explicitly, some device names contain parentheses themselves
|
|
SIMULATOR=$(xcrun simctl list devices available \
|
|
| grep -m1 '${{ matrix.device.simulator }}' \
|
|
| grep -oE '[0-9A-F]{8}(-[0-9A-F]{4}){3}-[0-9A-F]{12}')
|
|
if [ -z "$SIMULATOR" ]; then
|
|
echo "No available simulator matching '${{ matrix.device.simulator }}'"
|
|
xcrun simctl list devices available
|
|
exit 1
|
|
fi
|
|
echo "SIMULATOR=$SIMULATOR" >> $GITHUB_ENV
|
|
xcrun simctl boot "$SIMULATOR" || true
|
|
open -a Simulator || true
|
|
n=0; until xcrun simctl bootstatus "$SIMULATOR" -b || [ $n -ge 60 ]; do sleep 1; n=$((n+1)); done
|
|
|
|
# The image ships no GNU coreutils, take-screenshots.sh needs gtimeout
|
|
- name: Install coreutils
|
|
run: brew install coreutils
|
|
|
|
- name: Generate screenshots
|
|
run: .github/scripts/take-screenshots.sh ${{ matrix.device.device_type }} -d "$SIMULATOR"
|
|
|
|
- name: Upload screenshots
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: screenshots-ios-${{ matrix.device.device_type }}
|
|
path: fastlane/metadata/ios/**/images/${{ matrix.device.folder }}/*.png
|
|
|
|
screenshots_android:
|
|
name: 'Android - ${{ matrix.device.name }}'
|
|
runs-on: ubuntu-latest
|
|
# A clean run takes about 25 minutes, the script may retry a block twice
|
|
timeout-minutes: 60
|
|
strategy:
|
|
# The jobs write into separate folders and a flaky one should not take
|
|
# the healthy ones down with it
|
|
fail-fast: false
|
|
matrix:
|
|
device:
|
|
- name: "Phone"
|
|
profile: pixel_10
|
|
device_type: androidPhone
|
|
folder: phoneScreenshots
|
|
- name: "Tablet 7in"
|
|
profile: small_tablet
|
|
device_type: androidTabletSmall
|
|
folder: sevenInchScreenshots
|
|
- name: "Tablet 10in"
|
|
profile: pixel_tablet
|
|
device_type: androidTabletBig
|
|
folder: tenInchScreenshots
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Common flutter setup
|
|
uses: ./.github/actions/flutter-common
|
|
|
|
- name: Enable KVM
|
|
run: |
|
|
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
|
sudo udevadm control --reload-rules
|
|
sudo udevadm trigger --name-match=kvm
|
|
|
|
- name: Accept Android SDK licenses
|
|
run: yes | "${ANDROID_HOME:?}/cmdline-tools/latest/bin/sdkmanager" --licenses || true
|
|
|
|
# The runner image ships command line tools 12.0, which does not have the
|
|
# device definitions we need.
|
|
- name: Install current SDK command line tools
|
|
run: |
|
|
SDK="${ANDROID_HOME:?}/cmdline-tools"
|
|
yes | "$SDK/latest/bin/sdkmanager" --install "cmdline-tools;22.0"
|
|
rm -rf "$SDK/latest"
|
|
mv "$SDK/22.0" "$SDK/latest"
|
|
"$SDK/latest/bin/sdkmanager" --version
|
|
|
|
# Fail here rather than after the system image download
|
|
- name: Check the device profile exists
|
|
run: |
|
|
"${ANDROID_HOME:?}/cmdline-tools/latest/bin/avdmanager" list device --compact \
|
|
| grep -qx '${{ matrix.device.profile }}'
|
|
|
|
# Free up disk space on the runner. List taken from
|
|
# https://github.com/flathub-infra/vorarbeiter/blob/main/.github/workflows/build.yml
|
|
#
|
|
# If needed, consult the list of available software for other candidates to remove:
|
|
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
|
|
- name: Free up disk space
|
|
run: |
|
|
sudo swapoff -a || true
|
|
sudo rm -rf /opt/ghc /usr/local/.ghcup || true
|
|
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
|
|
sudo rm -rf /opt/hostedtoolcache/PyPy
|
|
sudo rm -rf /usr/local/julia* /usr/share/java /usr/share/kotlinc
|
|
sudo rm -rf /opt/hostedtoolcache/go /opt/az /opt/microsoft /opt/pipx
|
|
sudo rm -rf /usr/share/miniconda /home/runner/.rustup /home/packer/.rustup /home/runneradmin/.rustup
|
|
sudo rm -rf /etc/skel/.rustup /opt/hostedtoolcache/node /opt/google-cloud-sdk
|
|
sudo rm -rf /usr/share/az_* /opt/google /usr/lib/firefox /usr/local/aws-*
|
|
sudo rm -rf /usr/libexec/gcc /opt/actionarchivecache /opt/hostedtoolcache/Ruby
|
|
sudo rm -rf /var/lib/mysql /usr/local/n
|
|
sudo rm -rf /swapfile || true
|
|
sudo rm -rf /usr/share/dotnet /usr/share/swift
|
|
sudo rm -rf /usr/local/share/boost /usr/local/share/powershell
|
|
sudo rm -rf /usr/lib/google-cloud-sdk
|
|
sudo rm -rf /usr/local/graalvm /usr/local/share/chromium
|
|
sudo rm -rf /usr/local/lib/node_modules
|
|
sudo rm -rf /usr/lib/dotnet /usr/lib/php /usr/share/mysql
|
|
sudo rm -rf /usr/lib/llvm-*
|
|
sudo rm -rf /usr/lib/mono
|
|
sudo apt-get clean || true
|
|
sudo rm -rf /var/lib/apt/lists/*
|
|
|
|
- name: Generate screenshots
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
with:
|
|
api-level: 36
|
|
target: google_apis
|
|
arch: x86_64
|
|
profile: ${{ matrix.device.profile }}
|
|
emulator-options: -no-snapshot-save -no-window -no-metrics -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
|
disable-animations: true
|
|
pre-emulator-launch-script: .github/scripts/portrait-avd.sh
|
|
# The action runs every line of this as its own sh -c, so no loops here
|
|
script: .github/scripts/take-screenshots.sh ${{ matrix.device.device_type }}
|
|
|
|
- name: Upload screenshots
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: screenshots-android-${{ matrix.device.device_type }}
|
|
path: fastlane/metadata/android/**/images/${{ matrix.device.folder }}/*.png
|
|
|
|
commit_screenshots:
|
|
name: 'Commit and push'
|
|
if: ${{ inputs.commit_screenshots }}
|
|
needs:
|
|
- screenshots_apple
|
|
- screenshots_android
|
|
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Download all screenshot artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
path: screenshots
|
|
|
|
- name: Merge artifacts into fastlane/metadata
|
|
run: |
|
|
set -euo pipefail
|
|
for artifact in screenshots/screenshots-android-*/; do
|
|
rsync --archive --checksum --itemize-changes "$artifact" fastlane/metadata/android/
|
|
done
|
|
for artifact in screenshots/screenshots-ios-*/; do
|
|
rsync --archive --checksum --itemize-changes "$artifact" fastlane/metadata/ios/
|
|
done
|
|
|
|
- name: Commit screenshots to a dated branch
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add fastlane/metadata/android fastlane/metadata/ios || true
|
|
if git diff --staged --quiet; then
|
|
echo "No new or changed screenshots to commit."
|
|
else
|
|
BRANCH="screenshots-$(date -u +%Y-%m-%d)"
|
|
git commit -m "Update screenshots"
|
|
# Force-push so a same-day re-run replaces that day's branch
|
|
git push --force origin HEAD:"${BRANCH}"
|
|
echo "Pushed screenshots to branch ${BRANCH}"
|
|
fi |