Skip to content

Commit f7f8005

Browse files
author
Suyunjing
authored
feat(ci): enhance build workflow for Android and iOS with debug/release output handling (#26)
1 parent 3075e1c commit f7f8005

1 file changed

Lines changed: 101 additions & 14 deletions

File tree

.github/workflows/build.yaml

Lines changed: 101 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
android:
1919
runs-on: ubuntu-latest
2020
env:
21-
output: "${{ github.workspace }}/build/app/outputs/apk/release"
21+
release_output: "${{ github.workspace }}/build/app/outputs/apk/release"
22+
debug_output: "${{ github.workspace }}/build/app/outputs/flutter-apk"
2223
steps:
2324
- uses: actions/checkout@v3
2425
with:
@@ -63,7 +64,21 @@ jobs:
6364
name: "OpenList"
6465
path: "${{ github.workspace }}/android/app/libs/*.aar"
6566

66-
- name: Init Signature
67+
- name: Manual Disk Cleanup
68+
run: |
69+
echo "Before cleanup:"
70+
df -h
71+
# 清理一些安全的大文件夹
72+
sudo rm -rf /opt/hostedtoolcache/CodeQL 2>/dev/null || true
73+
sudo rm -rf /imagegeneration 2>/dev/null || true
74+
sudo rm -rf /opt/az 2>/dev/null || true
75+
# 清理Docker相关(但保留基础)
76+
docker system prune -af 2>/dev/null || true
77+
echo "After cleanup:"
78+
df -h
79+
80+
- name: Init Signature (Release only)
81+
if: github.event_name != 'pull_request'
6782
run: |
6883
touch local.properties
6984
cd android
@@ -77,39 +92,107 @@ jobs:
7792
- uses: subosito/flutter-action@v2
7893
with:
7994
flutter-version: '3.32.7'
80-
- run: flutter build apk --split-per-abi --release
95+
96+
- name: Verify Flutter and Android environment
97+
run: |
98+
echo "=== Flutter Environment ==="
99+
flutter --version
100+
flutter doctor -v
101+
echo "=== Android Environment ==="
102+
echo "ANDROID_HOME: $ANDROID_HOME"
103+
echo "ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT"
104+
echo "JAVA_HOME: $JAVA_HOME"
105+
ls -la $ANDROID_HOME/build-tools/ || echo "build-tools not found"
106+
echo "=== Disk Space ==="
107+
df -h
108+
109+
- name: Debug - Check build directory
110+
run: |
111+
echo "Checking build directory structure..."
112+
ls -la build/ || echo "build directory not found"
113+
ls -la build/app/ || echo "build/app directory not found"
114+
ls -la build/app/outputs/ || echo "build/app/outputs directory not found"
115+
116+
- name: Build Release APK
117+
if: github.event_name != 'pull_request'
118+
run: flutter build apk --split-per-abi --release --target-platform android-arm,android-arm64,android-x64
119+
120+
- name: Build Debug APK
121+
if: github.event_name == 'pull_request'
122+
run: flutter build apk --split-per-abi --debug --target-platform android-arm,android-arm64,android-x64
123+
124+
- name: Debug - Check APK files
125+
run: |
126+
echo "Checking for APK files..."
127+
find build/ -name "*.apk" -type f || echo "No APK files found"
128+
ls -la build/app/outputs/flutter-apk/ || echo "Flutter APK directory not found"
129+
ls -la build/app/outputs/apk/release/ || echo "Release directory not found"
130+
ls -la build/app/outputs/apk/debug/ || echo "Debug directory not found"
131+
echo "Expected architectures: ARM64 (arm64-v8a), ARM (armeabi-v7a), and x86_64"
132+
ls -la build/app/outputs/apk/debug/ || echo "Debug directory not found"
81133
82134
- name: Upload missing_rules.txt
83-
if: failure() && steps.gradle.outcome != 'success'
135+
if: failure()
84136
uses: actions/upload-artifact@v4
85137
with:
86138
name: "missing_rules"
87139
path: "${{ github.workspace }}/build/app/outputs/mapping/release/missing_rules.txt"
88140

89141
- name: Init APP Version Name
90142
run: |
91-
echo "ver_name=$(grep -m 1 'versionName' ${{ env.output }}/output-metadata.json | cut -d'"' -f4)" >> $GITHUB_ENV
143+
if [ "${{ github.event_name }}" == "pull_request" ]; then
144+
OUTPUT_DIR="${{ env.debug_output }}"
145+
BUILD_TYPE="debug"
146+
else
147+
OUTPUT_DIR="${{ env.release_output }}"
148+
BUILD_TYPE="release"
149+
fi
150+
151+
echo "Looking for version in: $OUTPUT_DIR"
152+
153+
if [ -f "$OUTPUT_DIR/output-metadata.json" ]; then
154+
VER_NAME=$(grep -m 1 'versionName' "$OUTPUT_DIR/output-metadata.json" | cut -d'"' -f4)
155+
echo "Found version: $VER_NAME"
156+
else
157+
echo "output-metadata.json not found, using fallback version"
158+
VER_NAME=$(cat openlist_version || echo "unknown")
159+
fi
160+
161+
if [ "$BUILD_TYPE" == "debug" ]; then
162+
echo "ver_name=${VER_NAME}-debug" >> $GITHUB_ENV
163+
else
164+
echo "ver_name=${VER_NAME}" >> $GITHUB_ENV
165+
fi
166+
167+
echo "output_path=$OUTPUT_DIR" >> $GITHUB_ENV
168+
echo "build_type=$BUILD_TYPE" >> $GITHUB_ENV
92169
93170
- name: Upload App To Artifact arm64-v8a
94171
if: success () || failure ()
95172
uses: actions/upload-artifact@v4
96173
with:
97-
name: "OpenList-Mobile-v${{ env.ver_name }}_arm64-v8a"
98-
path: "${{ env.output }}/*-v8a.apk"
174+
name: "OpenList-Mobile-${{ env.ver_name }}_arm64-v8a"
175+
path: |
176+
${{ env.output_path }}/*arm64-v8a*.apk
177+
${{ env.output_path }}/*v8a.apk
99178
100179
- name: Upload App To Artifact arm-v7a
101180
if: success () || failure ()
102181
uses: actions/upload-artifact@v4
103182
with:
104-
name: "OpenList-Mobile-v${{ env.ver_name }}_arm-v7a"
105-
path: "${{ env.output }}/*-v7a.apk"
183+
name: "OpenList-Mobile-${{ env.ver_name }}_arm-v7a"
184+
path: |
185+
${{ env.output_path }}/*armeabi-v7a*.apk
186+
${{ env.output_path }}/*v7a.apk
106187
107-
- name: Upload App To Artifact x86
188+
- name: Upload App To Artifact x86_64
108189
if: success () || failure ()
109190
uses: actions/upload-artifact@v4
110191
with:
111-
name: "OpenList-Mobile-v${{ env.ver_name }}_x86_64"
112-
path: "${{ env.output }}/*64.apk"
192+
name: "OpenList-Mobile-${{ env.ver_name }}_x86_64"
193+
path: |
194+
${{ env.output_path }}/*x86_64*.apk
195+
${{ env.output_path }}/*x64*.apk
113196
114197
ios:
115198
runs-on: macos-latest
@@ -191,11 +274,15 @@ jobs:
191274
# Generate timestamp in format YYMMDDHH (精确到小时)
192275
TIMESTAMP=$(date +%y%m%d%H)
193276
# Combine version with timestamp for artifact naming
194-
echo "ver_name=${BASE_VERSION}.${TIMESTAMP}" >> $GITHUB_ENV
277+
if [ "${{ github.event_name }}" == "pull_request" ]; then
278+
echo "ver_name=${BASE_VERSION}.${TIMESTAMP}-debug" >> $GITHUB_ENV
279+
else
280+
echo "ver_name=${BASE_VERSION}.${TIMESTAMP}" >> $GITHUB_ENV
281+
fi
195282
196283
- name: Upload iOS App To Artifact
197284
if: success() || failure()
198285
uses: actions/upload-artifact@v4
199286
with:
200287
name: "OpenList-Mobile-iOS-${{ env.ver_name }}"
201-
path: "${{ env.output }}/OpenList-Mobile.ipa"
288+
path: "${{ env.output }}/OpenList-Mobile.ipa"

0 commit comments

Comments
 (0)