-
Notifications
You must be signed in to change notification settings - Fork 3
215 lines (190 loc) · 6.83 KB
/
build-mobile.yml
File metadata and controls
215 lines (190 loc) · 6.83 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Build & Release Mobile Apps
on:
push:
tags:
- 'eride-v*'
- 'esocial-v*'
- 'etrack-v*'
- 'etravel-v*'
- 'ewallet-v*'
workflow_dispatch:
inputs:
app:
description: 'App to build'
required: true
type: choice
options: [eride, esocial, etrack, etravel, ewallet]
workflow_call:
inputs:
app:
description: 'App to build'
required: false
type: string
permissions:
contents: write
env:
FLUTTER_VERSION: '3.24.0'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
parse:
runs-on: ubuntu-latest
outputs:
app_id: ${{ steps.parse.outputs.app_id }}
version: ${{ steps.parse.outputs.version }}
steps:
- name: Parse tag or input
id: parse
run: |
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
echo "app_id=${{ inputs.app }}" >> "$GITHUB_OUTPUT"
echo "version=dev-$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
else
TAG="${GITHUB_REF_NAME}"
APP_ID="${TAG%-v*}"
VERSION="${TAG#*-v}"
echo "app_id=${APP_ID}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
fi
build-android:
needs: parse
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
- name: Install dependencies
working-directory: service-apps
run: flutter pub get
- name: Run tests
working-directory: service-apps
run: flutter test --coverage || true
- name: Build APK (release)
working-directory: service-apps
run: |
flutter build apk --release \
--build-name=${{ needs.parse.outputs.version }} \
--build-number=$(date +%Y%m%d%H)
- name: Build App Bundle (AAB)
working-directory: service-apps
run: |
flutter build appbundle --release \
--build-name=${{ needs.parse.outputs.version }} \
--build-number=$(date +%Y%m%d%H)
- name: Sign APK
if: env.ANDROID_KEYSTORE != ''
env:
ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
run: |
echo "$ANDROID_KEYSTORE" | base64 -d > keystore.jks
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 \
-keystore keystore.jks \
-storepass "$ANDROID_STORE_PASSWORD" \
-keypass "$ANDROID_KEY_PASSWORD" \
service-apps/build/app/outputs/flutter-apk/app-release.apk \
"$ANDROID_KEY_ALIAS"
- name: Rename artifacts
run: |
APP_ID="${{ needs.parse.outputs.app_id }}"
VERSION="${{ needs.parse.outputs.version }}"
mkdir -p dist
cp service-apps/build/app/outputs/flutter-apk/app-release.apk \
dist/${APP_ID}-${VERSION}.apk
cp service-apps/build/app/outputs/bundle/release/app-release.aab \
dist/${APP_ID}-${VERSION}.aab
- name: Upload Android artifacts
uses: actions/upload-artifact@v4
with:
name: android-${{ needs.parse.outputs.app_id }}
path: dist/*
build-ios:
needs: parse
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
- name: Install dependencies
working-directory: service-apps
run: flutter pub get
- name: Build iOS (no codesign for CI)
working-directory: service-apps
run: |
flutter build ios --release --no-codesign \
--build-name=${{ needs.parse.outputs.version }} \
--build-number=$(date +%Y%m%d%H)
- name: Archive IPA
if: env.IOS_CERTIFICATE != ''
env:
IOS_CERTIFICATE: ${{ secrets.IOS_CERTIFICATE }}
IOS_PROVISIONING_PROFILE: ${{ secrets.IOS_PROVISIONING_PROFILE }}
run: |
APP_ID="${{ needs.parse.outputs.app_id }}"
VERSION="${{ needs.parse.outputs.version }}"
mkdir -p dist
cd service-apps/build/ios/iphoneos
mkdir Payload
cp -r Runner.app Payload/
zip -r ../../../../dist/${APP_ID}-${VERSION}.ipa Payload
- name: Upload to TestFlight
if: env.APP_STORE_CONNECT_KEY != ''
env:
APP_STORE_CONNECT_KEY: ${{ secrets.APP_STORE_CONNECT_KEY }}
run: |
echo "Upload to TestFlight via App Store Connect API"
# xcrun altool --upload-app -f dist/*.ipa --type ios \
# --apiKey "$APP_STORE_KEY_ID" --apiIssuer "$APP_STORE_ISSUER"
release:
needs: [parse, build-android, build-ios]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: "${{ needs.parse.outputs.app_id }} v${{ needs.parse.outputs.version }}"
body: |
## ${{ needs.parse.outputs.app_id }} v${{ needs.parse.outputs.version }}
### Android Installation
1. Download the `.apk` file below
2. Enable "Install from Unknown Sources" in Settings
3. Open the APK to install
### iOS
- Available via TestFlight (invite link in app description)
- Or build from source: `cd service-apps && flutter run`
files: dist/*
- name: Update apps.json
run: |
APP_ID="${{ needs.parse.outputs.app_id }}"
VERSION="${{ needs.parse.outputs.version }}"
python3 -c "
import json
with open('data/apps.json', 'r', encoding='utf-8') as f:
data = json.load(f)
for app in data['apps']:
if app['id'] == '${APP_ID}':
app['version'] = '${VERSION}'
data['meta']['lastUpdated'] = '$(date +%Y-%m-%d)'
with open('data/apps.json', 'w', encoding='utf-8') as f:
json.dump(data, f, indent=2, ensure_ascii=False)
"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add data/apps.json
git diff --cached --quiet || git commit -m "chore: update $APP_ID to v$VERSION"
git push