Skip to content

Commit 26be166

Browse files
committed
feat: improve UX with auto-hide tabbar, keyboard shortcuts and CI fixes
1 parent 82499fa commit 26be166

File tree

12 files changed

+437
-299
lines changed

12 files changed

+437
-299
lines changed

.github/workflows/build-apk.yml

Lines changed: 112 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ on:
44
release:
55
types: [published]
66
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version tag for APK filename (optional)'
10+
required: false
11+
default: ''
712

813
permissions:
914
contents: write
1015

16+
concurrency:
17+
group: build-apk-${{ github.ref }}
18+
cancel-in-progress: true
19+
1120
jobs:
1221
build:
1322
runs-on: ubuntu-latest
@@ -33,50 +42,126 @@ jobs:
3342
- name: Build APK
3443
id: build
3544
run: |
36-
BUILD_JSON=$(eas build --platform android --profile preview --non-interactive --json)
37-
BUILD_ID=$(echo "$BUILD_JSON" | jq -r '.[0].id')
38-
if [ -z "$BUILD_ID" ] || [ "$BUILD_ID" = "null" ]; then
39-
echo "Failed to get build id"
45+
echo "::group::Starting EAS Build"
46+
BUILD_JSON=$(eas build --platform android --profile preview --non-interactive --json 2>&1) || {
47+
echo "::error::EAS build command failed"
48+
echo "$BUILD_JSON"
49+
exit 1
50+
}
51+
echo "$BUILD_JSON"
52+
BUILD_ID=$(echo "$BUILD_JSON" | jq -r '.[0].id // empty')
53+
if [ -z "$BUILD_ID" ]; then
54+
echo "::error::Failed to extract build ID from response"
4055
exit 1
4156
fi
4257
echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT
58+
echo "Build started with ID: $BUILD_ID"
59+
echo "::endgroup::"
4360
44-
- name: Wait for build and get APK URL
61+
- name: Wait for build completion
4562
id: artifact
4663
run: |
4764
BUILD_ID="${{ steps.build.outputs.build_id }}"
48-
if [ -z "$BUILD_ID" ] || [ "$BUILD_ID" = "null" ]; then
49-
echo "Missing build id"
50-
exit 1
51-
fi
52-
for i in {1..60}; do
53-
BUILD_INFO=$(eas build:view "$BUILD_ID" --json --non-interactive)
54-
STATUS=$(echo "$BUILD_INFO" | jq -r '.status')
55-
if [ "$STATUS" = "finished" ]; then
56-
BUILD_URL=$(echo "$BUILD_INFO" | jq -r '.artifacts.buildUrl')
57-
if [ -n "$BUILD_URL" ] && [ "$BUILD_URL" != "null" ]; then
58-
echo "apk_url=$BUILD_URL" >> $GITHUB_OUTPUT
59-
exit 0
60-
fi
65+
echo "Waiting for build $BUILD_ID to complete..."
66+
67+
MAX_ATTEMPTS=90
68+
SLEEP_INTERVAL=20
69+
70+
for i in $(seq 1 $MAX_ATTEMPTS); do
71+
echo "::group::Attempt $i/$MAX_ATTEMPTS"
72+
73+
# Fetch build info, capture both success and failure
74+
if ! BUILD_INFO=$(eas build:view "$BUILD_ID" --json --non-interactive 2>/dev/null); then
75+
echo "eas build:view command failed, retrying..."
76+
echo "::endgroup::"
77+
sleep $SLEEP_INTERVAL
78+
continue
6179
fi
62-
if [ "$STATUS" = "errored" ] || [ "$STATUS" = "canceled" ]; then
63-
echo "Build failed with status: $STATUS"
64-
exit 1
80+
81+
# Validate JSON response
82+
if ! echo "$BUILD_INFO" | jq -e . >/dev/null 2>&1; then
83+
echo "Invalid JSON response, retrying..."
84+
echo "::endgroup::"
85+
sleep $SLEEP_INTERVAL
86+
continue
6587
fi
66-
sleep 20
88+
89+
STATUS=$(echo "$BUILD_INFO" | jq -r '.status // "unknown"')
90+
echo "Current status: $STATUS"
91+
92+
case "$STATUS" in
93+
"finished")
94+
BUILD_URL=$(echo "$BUILD_INFO" | jq -r '.artifacts.applicationArchiveUrl // .artifacts.buildUrl // empty')
95+
if [ -n "$BUILD_URL" ]; then
96+
echo "apk_url=$BUILD_URL" >> $GITHUB_OUTPUT
97+
echo "✅ Build completed successfully!"
98+
echo "::endgroup::"
99+
exit 0
100+
else
101+
echo "::error::Build finished but no artifact URL found"
102+
exit 1
103+
fi
104+
;;
105+
"errored"|"canceled")
106+
echo "::error::Build failed with status: $STATUS"
107+
echo "::endgroup::"
108+
exit 1
109+
;;
110+
*)
111+
echo "Build in progress..."
112+
;;
113+
esac
114+
echo "::endgroup::"
115+
sleep $SLEEP_INTERVAL
67116
done
68-
echo "Timed out waiting for build artifact"
117+
118+
echo "::error::Timed out after $((MAX_ATTEMPTS * SLEEP_INTERVAL)) seconds"
69119
exit 1
70120
121+
- name: Determine APK filename
122+
id: filename
123+
run: |
124+
if [ "${{ github.event_name }}" = "release" ]; then
125+
VERSION="${{ github.event.release.tag_name }}"
126+
elif [ -n "${{ github.event.inputs.version }}" ]; then
127+
VERSION="${{ github.event.inputs.version }}"
128+
else
129+
VERSION="dev-$(date +%Y%m%d-%H%M%S)"
130+
fi
131+
FILENAME="gojuon-${VERSION}.apk"
132+
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
133+
echo "APK will be saved as: $FILENAME"
134+
71135
- name: Download APK
72-
if: github.event_name == 'release'
73136
run: |
74-
curl -L -o gojuon.apk "${{ steps.artifact.outputs.apk_url }}"
137+
echo "Downloading APK from EAS..."
138+
curl -L --fail --retry 3 -o "${{ steps.filename.outputs.filename }}" "${{ steps.artifact.outputs.apk_url }}"
139+
ls -lh "${{ steps.filename.outputs.filename }}"
140+
141+
- name: Upload APK as artifact
142+
uses: actions/upload-artifact@v4
143+
with:
144+
name: ${{ steps.filename.outputs.filename }}
145+
path: ${{ steps.filename.outputs.filename }}
146+
retention-days: 30
75147

76148
- name: Upload APK to Release
77149
if: github.event_name == 'release'
78-
uses: softprops/action-gh-release@v1
150+
uses: softprops/action-gh-release@v2
79151
with:
80-
files: gojuon.apk
152+
files: ${{ steps.filename.outputs.filename }}
81153
env:
82154
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
156+
- name: Build Summary
157+
run: |
158+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
159+
echo "" >> $GITHUB_STEP_SUMMARY
160+
echo "| Item | Value |" >> $GITHUB_STEP_SUMMARY
161+
echo "|------|-------|" >> $GITHUB_STEP_SUMMARY
162+
echo "| APK Filename | \`${{ steps.filename.outputs.filename }}\` |" >> $GITHUB_STEP_SUMMARY
163+
echo "| Build ID | \`${{ steps.build.outputs.build_id }}\` |" >> $GITHUB_STEP_SUMMARY
164+
echo "| Trigger | ${{ github.event_name }} |" >> $GITHUB_STEP_SUMMARY
165+
if [ "${{ github.event_name }}" = "release" ]; then
166+
echo "| Release | ${{ github.event.release.tag_name }} |" >> $GITHUB_STEP_SUMMARY
167+
fi

0 commit comments

Comments
 (0)