42
42
echo "Starting EAS build..."
43
43
sudo apt-get install -y jq
44
44
45
- # Run build and capture JSON output
46
45
BUILD_JSON=$(npx eas build -p android --profile production --non-interactive --json)
47
46
echo "Raw build output: $BUILD_JSON"
48
47
49
- # Extract BUILD_ID
50
48
BUILD_ID=$(echo "$BUILD_JSON" | jq -r '.[0].id')
51
49
if [[ -z "$BUILD_ID" || "$BUILD_ID" == "null" ]]; then
52
50
echo "Error: Failed to retrieve BUILD_ID!"
66
64
outputs :
67
65
apk_path : ${{ steps.download.outputs.APK_PATH }}
68
66
steps :
69
- - name : Setup Node.js
70
- uses : actions/setup-node@v4
71
- with :
72
- node-version : 20.x
67
+ - name : Checkout repository
68
+ uses : actions/checkout@v4
73
69
74
70
- name : Install Required Tools
75
71
run : |
@@ -79,30 +75,27 @@ jobs:
79
75
80
76
- name : Wait for EAS Build to Complete
81
77
run : |
78
+ cd $GITHUB_WORKSPACE
82
79
BUILD_ID=${{ needs.build-android.outputs.build_id }}
83
80
echo "Starting build monitoring for BUILD_ID: $BUILD_ID"
84
- npx eas build:view --json $BUILD_ID
85
81
86
82
RETRY_COUNT=0
87
- MAX_RETRIES=120 # 120 attempts * 30 seconds = 60 minutes
83
+ MAX_RETRIES=120
88
84
SLEEP_TIME=30
89
85
90
86
while [[ $RETRY_COUNT -lt $MAX_RETRIES ]]; do
91
87
echo -e "\n=== Attempt $((RETRY_COUNT+1))/$MAX_RETRIES ==="
92
88
93
- # Get build status with full error visibility
94
- echo "Fetching build status..."
95
- npx eas build:view --json $BUILD_ID
96
- BUILD_STATUS_JSON=$(npx eas build:view --json $BUILD_ID)
89
+ BUILD_STATUS_JSON=$(npx eas build:view --json $BUILD_ID 2>/dev/null)
97
90
echo "Raw API response: $BUILD_STATUS_JSON"
98
91
99
- # Validate JSON structure
100
- if ! echo "$BUILD_STATUS_JSON" | jq empty >/dev/null 2>&1; then
101
- echo "Error: Invalid JSON response from EAS API!"
102
- exit 1
92
+ if [[ -z "$BUILD_STATUS_JSON" || "$BUILD_STATUS_JSON" == "null" ]]; then
93
+ echo "Error: Invalid response from EAS API! Retrying..."
94
+ RETRY_COUNT=$((RETRY_COUNT+1))
95
+ sleep $SLEEP_TIME
96
+ continue
103
97
fi
104
98
105
- # Parse status fields
106
99
BUILD_STATUS=$(echo "$BUILD_STATUS_JSON" | jq -r '.status')
107
100
ERROR_MESSAGE=$(echo "$BUILD_STATUS_JSON" | jq -r '.error.message // empty')
108
101
@@ -113,33 +106,25 @@ jobs:
113
106
"finished")
114
107
APK_URL=$(echo "$BUILD_STATUS_JSON" | jq -r '.artifacts.buildUrl')
115
108
if [[ -z "$APK_URL" || "$APK_URL" == "null" ]]; then
116
- echo "Error: Successful build but no APK URL found!"
117
- echo "Full response: $BUILD_STATUS_JSON"
109
+ echo "Error: Build finished but APK URL is missing!"
118
110
exit 1
119
111
fi
120
112
echo "APK_URL=$APK_URL" >> $GITHUB_ENV
121
- echo "Build completed successfully!"
122
113
exit 0
123
114
;;
124
115
125
- "errored")
116
+ "errored"|"canceled" )
126
117
echo "Build failed! Error details:"
127
118
echo "$BUILD_STATUS_JSON" | jq .
128
119
exit 1
129
120
;;
130
121
131
- "canceled")
132
- echo "Build was canceled!"
133
- exit 1
134
- ;;
135
-
136
122
"new"|"in_queue"|"in_progress"|"pending")
137
- echo "Build still in progress..."
123
+ echo "Build is still in progress..."
138
124
;;
139
125
140
126
*)
141
127
echo "Unknown build status: $BUILD_STATUS"
142
- echo "Full response: $BUILD_STATUS_JSON"
143
128
exit 1
144
129
;;
145
130
esac
@@ -149,7 +134,7 @@ jobs:
149
134
sleep $SLEEP_TIME
150
135
done
151
136
152
- echo "Error: Build did not complete within $((MAX_RETRIES * SLEEP_TIME / 60)) minutes !"
137
+ echo "Error: Build did not complete within the expected time !"
153
138
exit 1
154
139
env :
155
140
EXPO_TOKEN : ${{ secrets.EXPO_TOKEN }}
@@ -158,7 +143,7 @@ jobs:
158
143
id : download
159
144
run : |
160
145
echo "Downloading APK from: $APK_URL"
161
- curl -L -o app-release.apk "$APK_URL"
146
+ curl -L "$APK_URL" -o app-release.apk
162
147
ls -lh app-release.apk
163
148
echo "APK_PATH=app-release.apk" >> $GITHUB_OUTPUT
164
149
@@ -218,4 +203,4 @@ jobs:
218
203
body_path : changelog.txt
219
204
draft : false
220
205
prerelease : false
221
- files : app-release.apk
206
+ files : app-release.apk
0 commit comments