-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (90 loc) · 2.81 KB
/
Copy pathbuild-android.yml
File metadata and controls
105 lines (90 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Build Android App
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
jobs:
build:
name: Build Android APK
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.3
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 20.x
cache: 'npm'
- name: Setup Expo and EAS
uses: expo/expo-github-action@v9
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies
run: npm ci
- name: Verify TypeScript
run: npx tsc --noEmit
- name: Setup EAS
if: ${{ secrets.EXPO_TOKEN != '' }}
run: |
# 配置 EAS
echo "EXPO_TOKEN=${{ secrets.EXPO_TOKEN }}" >> $GITHUB_ENV
- name: Build APK (Preview)
if: ${{ secrets.EXPO_TOKEN != '' }}
run: |
# 构建 Android 预览版 APK
eas build --platform android --profile preview --non-interactive --no-wait
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: build-artifacts
path: |
./
!node_modules
!.git
retention-days: 30
test-local:
name: Local Build Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.3
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 20.x
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Verify TypeScript
run: npx tsc --noEmit
- name: Validate project structure
run: |
# Sanity check that the build target files actually exist before
# we spend EAS credits spinning up a cloud build.
for f in App.tsx app.json eas.json package.json src/shared/store/index.ts; do
if [ ! -f "$f" ]; then
echo "::error::missing required file: $f"
exit 1
fi
done
echo "project structure OK"
- name: Create test build report
run: |
echo "✅ 项目验证成功!" > build-report.txt
echo "📱 Todo App - 项目结构验证报告" >> build-report.txt
echo "日期: $(date)" >> build-report.txt
echo "Node版本: $(node --version)" >> build-report.txt
echo "npm版本: $(npm --version)" >> build-report.txt
- name: Upload build report
uses: actions/upload-artifact@v7
with:
name: build-report
path: build-report.txt
retention-days: 30