@@ -34,18 +34,20 @@ jobs:
34
34
- name : Debug Expo Authentication
35
35
run : |
36
36
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 !"
38
38
39
- - name : Start EAS Build (With Logs)
39
+ - name : Start EAS Build
40
40
id : build
41
41
run : |
42
42
echo "Starting EAS build..."
43
+ sudo apt-get install -y jq
43
44
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"
47
48
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')
49
51
if [[ -z "$BUILD_ID" || "$BUILD_ID" == "null" ]]; then
50
52
echo "Error: Failed to retrieve BUILD_ID!"
51
53
exit 1
@@ -69,78 +71,92 @@ jobs:
69
71
with :
70
72
node-version : 20.x
71
73
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
74
79
75
80
- name : Wait for EAS Build to Complete
76
81
run : |
77
82
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"
86
84
87
85
RETRY_COUNT=0
88
- MAX_RETRIES=100
86
+ MAX_RETRIES=120 # 120 attempts * 30 seconds = 60 minutes
89
87
SLEEP_TIME=30
90
88
91
89
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 ==="
94
91
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
100
101
fi
101
102
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
+ ;;
112
128
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!"
118
131
exit 1
119
- fi
132
+ ;;
120
133
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
127
144
128
145
RETRY_COUNT=$((RETRY_COUNT+1))
146
+ echo "Waiting $SLEEP_TIME seconds before next check..."
129
147
sleep $SLEEP_TIME
130
148
done
131
149
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
136
152
env :
137
153
EXPO_TOKEN : ${{ secrets.EXPO_TOKEN }}
138
154
139
155
- name : Download APK
140
156
id : download
141
157
run : |
142
158
echo "Downloading APK from: $APK_URL"
143
- curl -L $APK_URL -o app-release.apk
159
+ curl -L -o app-release.apk "$APK_URL"
144
160
ls -lh app-release.apk
145
161
echo "APK_PATH=app-release.apk" >> $GITHUB_OUTPUT
146
162
@@ -164,14 +180,12 @@ jobs:
164
180
id : changelog
165
181
run : |
166
182
echo "Generating changelog..."
183
+ git fetch --prune --unshallow 2> /dev/null || true
167
184
echo "## Changelog" > changelog.txt
168
185
echo "" >> changelog.txt
169
186
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
174
187
echo "CHANGELOG=$(cat changelog.txt)" >> $GITHUB_OUTPUT
188
+ cat changelog.txt
175
189
176
190
- name : Upload Changelog as artifact
177
191
uses : actions/upload-artifact@v4
0 commit comments