Repository navigation
221 lines (200 loc) · 8.6 KB
/
Copy pathscreenshots.yml
File metadata and controls
221 lines (200 loc) · 8.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
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