Repository navigation
187 lines (160 loc) · 5.83 KB
/
Copy pathandroid.yml
File metadata and controls
187 lines (160 loc) · 5.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
name: Build for Android
on:
# Enable manual run
workflow_dispatch:
push:
tags:
- "**"
branches:
- "**"
paths:
- .github/workflows/android.yml
jobs:
build-android:
name: Build APK (${{ matrix.foss && 'FOSS' || 'Regular' }})
strategy:
fail-fast: false
matrix:
foss: [false, true]
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false
- uses: "./.github/shared_workflows/install_apt_dependencies"
- name: Setup Flutter
uses: adil192/setup-flutter-submodule@v3
with:
flutter-path: submodules/flutter
no-save-caches: true
- name: Restore cache
uses: actions/cache/restore@v6.1.0
with:
path: |
.dart_tool/
.flutter-plugins-dependencies
build/
linux/flutter/ephemeral/
macos/Flutter/ephemeral/
packages/**/.dart_tool/
packages/**/.flutter-plugins-dependencies
packages/**/pubspec.lock
windows/flutter/ephemeral/
~/.dartServer/
~/.dart-tool/
key: ${{ runner.OS }}-saber-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
${{ runner.OS }}-saber-
- name: Setup keystore
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
if: ${{ env.SIGNING_KEY != '' }}
run: |
echo "${{ secrets.SIGNING_KEY }}" | base64 -d > android/android.keystore
echo "storePassword=${{ secrets.KEY_STORE_PASSWORD }}" > android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.ALIAS }}" >> android/key.properties
echo "storeFile=../android.keystore" >> android/key.properties
- name: Setup Android build tools
run: |
ANDROID_NDK=/usr/local/lib/android/sdk/ndk/29.0.14206865
echo "ANDROID_NDK=$ANDROID_NDK" >> $GITHUB_ENV
echo "ANDROID_NDK_HOME=$ANDROID_NDK" >> $GITHUB_ENV
echo "ANDROID_NDK_ROOT=$ANDROID_NDK" >> $GITHUB_ENV
echo "JAVA_HOME=$JAVA_HOME_25_X64" >> $GITHUB_ENV
- name: Disable Flutter CLI animations
run: flutter config --no-cli-animations
- run: ./patches/pre/remove_proprietary_dependencies.sh
if: matrix.foss
- run: patch pubspec.lock < patches/pre/pubspec-fdroid.lock.patch
if: matrix.foss
- name: Build apk
run: flutter build apk
- name: Rename apk
id: rename_apk
run: |
buildName=$(grep -oP "(?<=buildName = ').*(?=')" lib/data/version.dart)
if [ "${{ matrix.foss }}" = "true" ]; then
apkName="Saber_FOSS_v${buildName}.apk"
else
apkName="Saber_v${buildName}.apk"
fi
echo "apkName=$apkName" >> $GITHUB_OUTPUT
mkdir -p output
mv build/app/outputs/flutter-apk/app-release.apk output/$apkName
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.foss && 'Saber-Android-FOSS' || 'Saber-Android' }}
path: output/${{ steps.rename_apk.outputs.apkName }}
- name: Upload to GitHub release
uses: svenstaro/upload-release-action@v2
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: output/${{ steps.rename_apk.outputs.apkName }}
- name: Build aab
if: ${{ matrix.foss == false }}
run: |
flutter build appbundle \
--dart-define=FLAVOR="Google Play" \
--dart-define=APP_STORE="Google Play" \
--dart-define=UPDATE_CHECK="false"
mkdir -p output
mv build/app/outputs/bundle/release/app-release.aab output/Saber.aab
- name: Upload artifact
if: ${{ matrix.foss == false }}
uses: actions/upload-artifact@v7
with:
name: Saber-Android-PlayStore
path: output/Saber.aab
upload-to-play-store:
name: Upload to Play Store
runs-on: ubuntu-latest
needs: build-android
if: ${{ startsWith(github.ref, 'refs/tags/') }}
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download artifact
uses: actions/download-artifact@v8
with:
name: Saber-Android-PlayStore
path: output
- name: Prepare whatsnew directory from metadata/*/changelogs
working-directory: ${{ github.workspace }}
run: |
# display changelogs for debugging
find metadata -name '*.txt'
mkdir -p whatsnew
# get current version code from lib/data/version.dart
VERSION_CODE=$(grep -oP '(?<=buildNumber = )\d+' lib/data/version.dart)
# copy changelogs of each language to whatsnew
for dir in metadata/*/changelogs; do
# get language code from directory name
# e.g. metadata/en-US/changelogs -> en-US
lang=${dir#metadata/}
lang=${lang%/changelogs}
# get original changelog file
original="$dir/$VERSION_CODE.txt"
if [ -f "$original" ]; then
# copy changelog file to whatsnew
cp "$original" "whatsnew/whatsnew-${lang}"
fi
done
- name: Upload to Play Store
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAY_STORE_JSON }}
packageName: com.adilhanney.saber
releaseFiles: output/Saber.aab
track: production
status: completed
whatsNewDirectory: whatsnew