Skip to content

Commit e257932

Browse files
More debugging to apk download / build status.
1 parent f154c1c commit e257932

File tree

1 file changed

+69
-55
lines changed

1 file changed

+69
-55
lines changed

.github/workflows/eas-android-build.yml

Lines changed: 69 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@ jobs:
3434
- name: Debug Expo Authentication
3535
run: |
3636
echo "Checking Expo authentication..."
37-
npx eas whoami --token $EXPO_TOKEN || echo "Expo token is invalid!"
37+
npx eas whoami --token $EXPO_TOKEN || echo "Expo authentication check failed!"
3838
39-
- name: Start EAS Build (With Logs)
39+
- name: Start EAS Build
4040
id: build
4141
run: |
4242
echo "Starting EAS build..."
43+
sudo apt-get install -y jq
4344
44-
if ! command -v jq &> /dev/null; then
45-
sudo apt-get install -y jq
46-
fi
45+
# Run build and capture JSON output
46+
BUILD_JSON=$(npx eas build -p android --profile production --non-interactive --json)
47+
echo "Raw build output: $BUILD_JSON"
4748
48-
BUILD_ID=$(npx eas build -p android --profile production --non-interactive --json | jq -r '.[0].id')
49+
# Extract BUILD_ID
50+
BUILD_ID=$(echo "$BUILD_JSON" | jq -r '.[0].id')
4951
if [[ -z "$BUILD_ID" || "$BUILD_ID" == "null" ]]; then
5052
echo "Error: Failed to retrieve BUILD_ID!"
5153
exit 1
@@ -69,78 +71,92 @@ jobs:
6971
with:
7072
node-version: 20.x
7173

72-
- name: Install EAS CLI
73-
run: npm install -g eas-cli@latest
74+
- name: Install Required Tools
75+
run: |
76+
npm install -g eas-cli@latest
77+
sudo apt-get update
78+
sudo apt-get install -y jq curl
7479
7580
- name: Wait for EAS Build to Complete
7681
run: |
7782
BUILD_ID=${{ needs.build-android.outputs.build_id }}
78-
79-
if [[ -z "$BUILD_ID" || "$BUILD_ID" == "null" ]]; then
80-
echo "Error: BUILD_ID is missing or invalid!"
81-
exit 1
82-
fi
83-
84-
echo "Waiting for EAS Build to complete..."
85-
echo "BUILD_ID: $BUILD_ID"
83+
echo "Starting build monitoring for BUILD_ID: $BUILD_ID"
8684
8785
RETRY_COUNT=0
88-
MAX_RETRIES=100
86+
MAX_RETRIES=120 # 120 attempts * 30 seconds = 60 minutes
8987
SLEEP_TIME=30
9088
9189
while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do
92-
echo "Starting retry #$RETRY_COUNT..."
93-
BUILD_STATUS_JSON=$(npx eas build:view --json $BUILD_ID 2>/dev/null)
90+
echo -e "\n=== Attempt $((RETRY_COUNT+1))/$MAX_RETRIES ==="
9491
95-
if [[ -z "$BUILD_STATUS_JSON" || "$BUILD_STATUS_JSON" == "null" ]]; then
96-
echo "Error: Failed to fetch build status! Retrying in $SLEEP_TIME seconds..."
97-
RETRY_COUNT=$((RETRY_COUNT+1))
98-
sleep $SLEEP_TIME
99-
continue
92+
# Get build status with full error visibility
93+
echo "Fetching build status..."
94+
BUILD_STATUS_JSON=$(npx eas build:view --json $BUILD_ID)
95+
echo "Raw API response: $BUILD_STATUS_JSON"
96+
97+
# Validate JSON structure
98+
if ! echo "$BUILD_STATUS_JSON" | jq empty >/dev/null 2>&1; then
99+
echo "Error: Invalid JSON response from EAS API!"
100+
exit 1
100101
fi
101102
102-
BUILD_STATUS=$(echo "$BUILD_STATUS_JSON" | jq -r '.status' 2>/dev/null)
103-
104-
if [[ -z "$BUILD_STATUS" || "$BUILD_STATUS" == "null" ]]; then
105-
echo "Error: Build status is empty! Retrying..."
106-
RETRY_COUNT=$((RETRY_COUNT+1))
107-
sleep $SLEEP_TIME
108-
continue
109-
fi
110-
111-
echo "Current Build Status: $BUILD_STATUS"
103+
# Parse status fields
104+
BUILD_STATUS=$(echo "$BUILD_STATUS_JSON" | jq -r '.status')
105+
ERROR_MESSAGE=$(echo "$BUILD_STATUS_JSON" | jq -r '.error.message // empty')
106+
107+
echo "Parsed status: $BUILD_STATUS"
108+
[[ -n "$ERROR_MESSAGE" ]] && echo "Error message: $ERROR_MESSAGE"
109+
110+
case $BUILD_STATUS in
111+
"finished")
112+
APK_URL=$(echo "$BUILD_STATUS_JSON" | jq -r '.artifacts.buildUrl')
113+
if [[ -z "$APK_URL" || "$APK_URL" == "null" ]]; then
114+
echo "Error: Successful build but no APK URL found!"
115+
echo "Full response: $BUILD_STATUS_JSON"
116+
exit 1
117+
fi
118+
echo "APK_URL=$APK_URL" >> $GITHUB_ENV
119+
echo "Build completed successfully!"
120+
exit 0
121+
;;
122+
123+
"errored")
124+
echo "Build failed! Error details:"
125+
echo "$BUILD_STATUS_JSON" | jq .
126+
exit 1
127+
;;
112128
113-
if [[ "$BUILD_STATUS" == "FINISHED" ]]; then
114-
APK_URL=$(echo "$BUILD_STATUS_JSON" | jq -r '.artifacts.buildUrl' 2>/dev/null)
115-
116-
if [[ -z "$APK_URL" || "$APK_URL" == "null" ]]; then
117-
echo "Error: APK URL not found!"
129+
"canceled")
130+
echo "Build was canceled!"
118131
exit 1
119-
fi
132+
;;
120133
121-
echo "APK_URL=$APK_URL" >> $GITHUB_ENV
122-
break
123-
elif [[ "$BUILD_STATUS" == "errored" ]]; then
124-
echo "EAS build failed."
125-
exit 1
126-
fi
134+
"new"|"in_queue"|"in_progress"|"pending")
135+
echo "Build still in progress..."
136+
;;
137+
138+
*)
139+
echo "Unknown build status: $BUILD_STATUS"
140+
echo "Full response: $BUILD_STATUS_JSON"
141+
exit 1
142+
;;
143+
esac
127144
128145
RETRY_COUNT=$((RETRY_COUNT+1))
146+
echo "Waiting $SLEEP_TIME seconds before next check..."
129147
sleep $SLEEP_TIME
130148
done
131149
132-
if [[ $RETRY_COUNT -eq $MAX_RETRIES ]]; then
133-
echo "Error: Build did not complete within the expected time!"
134-
exit 1
135-
fi
150+
echo "Error: Build did not complete within $((MAX_RETRIES * SLEEP_TIME / 60)) minutes!"
151+
exit 1
136152
env:
137153
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
138154

139155
- name: Download APK
140156
id: download
141157
run: |
142158
echo "Downloading APK from: $APK_URL"
143-
curl -L $APK_URL -o app-release.apk
159+
curl -L -o app-release.apk "$APK_URL"
144160
ls -lh app-release.apk
145161
echo "APK_PATH=app-release.apk" >> $GITHUB_OUTPUT
146162
@@ -164,14 +180,12 @@ jobs:
164180
id: changelog
165181
run: |
166182
echo "Generating changelog..."
183+
git fetch --prune --unshallow 2> /dev/null || true
167184
echo "## Changelog" > changelog.txt
168185
echo "" >> changelog.txt
169186
git log --pretty=format:"- %s (%h) by %an" $(git rev-parse HEAD^)..HEAD >> changelog.txt
170-
cat changelog.txt
171-
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
172-
cat changelog.txt >> $GITHUB_ENV
173-
echo "EOF" >> $GITHUB_ENV
174187
echo "CHANGELOG=$(cat changelog.txt)" >> $GITHUB_OUTPUT
188+
cat changelog.txt
175189
176190
- name: Upload Changelog as artifact
177191
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)