Skip to content

Commit d6940b4

Browse files
Refine APK extraction and comparison in workflow
Updated APK extraction and comparison logic for builds.
1 parent 7ad0e64 commit d6940b4

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

.github/workflows/rep-build.yml

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,53 +20,75 @@ jobs:
2020
target: apk-builder
2121
tags: app:build-one
2222
outputs: type=docker,dest=/tmp/image1.tar
23-
cache-from: type=gha # Uses GitHub Actions native cache
23+
cache-from: type=gha
2424
cache-to: type=gha,mode=max
2525

2626
- name: Extract Build 1 APK
2727
run: |
2828
docker load -i /tmp/image1.tar
29+
# Create a container so we can copy from its filesystem
2930
docker create --name container1 app:build-one
30-
# Find the APK regardless of the exact flavor path and copy it out
31-
APK_PATH=$(docker run --rm app:build-one find /android -name "*-unsigned.apk" | head -n 1)
31+
32+
# Use a more robust way to find the APK path
33+
APK_PATH=$(docker run --rm app:build-one find /android -name "*.apk" | grep "release" | head -n 1)
34+
echo "Found APK at: $APK_PATH"
35+
36+
# Copy it to the current runner workspace
3237
docker cp container1:$APK_PATH ./build1.apk
3338
sha256sum build1.apk > hash1.txt
3439
35-
# --- Build 2 (Sequential to save RAM) ---
40+
# --- Build 2 ---
3641
- name: Build Second APK
3742
uses: docker/build-push-action@v5
3843
with:
3944
context: .
4045
target: apk-builder
4146
tags: app:build-two
4247
outputs: type=docker,dest=/tmp/image2.tar
43-
# We force a re-run of the build layer by passing a dummy arg or using no-cache
44-
# on the final stage if needed, but usually, a clean build is better.
48+
# We use no-cache specifically for the app source layer to force a rebuild
49+
no-cache-filter: apk-builder
4550
cache-from: type=gha
4651

4752
- name: Extract Build 2 APK
4853
run: |
4954
docker load -i /tmp/image2.tar
5055
docker create --name container2 app:build-two
51-
APK_PATH=$(docker run --rm app:build-two find /android -name "*-unsigned.apk" | head -n 1)
56+
57+
APK_PATH=$(docker run --rm app:build-two find /android -name "*.apk" | grep "release" | head -n 1)
58+
echo "Found APK at: $APK_PATH"
59+
5260
docker cp container2:$APK_PATH ./build2.apk
5361
sha256sum build2.apk > hash2.txt
5462
5563
# --- Comparison ---
5664
- name: Compare Results
5765
run: |
58-
echo "HASH 1: $(cat hash1.txt)"
59-
echo "HASH 2: $(cat hash2.txt)"
60-
if diff hash1.txt hash2.txt; then
61-
echo "Build is Reproducible!"
66+
echo "Build 1 SHA: $(cat hash1.txt)"
67+
echo "Build 2 SHA: $(cat hash2.txt)"
68+
69+
if cmp -s build1.apk build2.apk; then
70+
echo "Binaries are bit-for-bit identical."
6271
else
63-
echo "Build is NOT Reproducible!"
72+
echo "Binaries differ."
6473
exit 1
6574
fi
6675
67-
# Diagnostic tool in case of failure
76+
# --- Diagnostic (Only runs if Comparison fails) ---
6877
- name: Run Diffoscope on Mismatch
6978
if: failure()
7079
run: |
71-
sudo apt-get update && sudo apt-get install -y diffoscope
72-
diffoscope build1.apk build2.apk
80+
# Check if files exist before running to avoid the error you saw
81+
if [ -f "build1.apk" ] && [ -f "build2.apk" ]; then
82+
sudo apt-get update && sudo apt-get install -y diffoscope
83+
# We output to a file because the log might be too long for the UI
84+
diffoscope build1.apk build2.apk --html diff.html || true
85+
else
86+
echo "Extraction failed; build1.apk or build2.apk not found."
87+
fi
88+
89+
- name: Upload Diff Report
90+
if: failure()
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: reproduction-diff
94+
path: diff.html

0 commit comments

Comments
 (0)