-
Notifications
You must be signed in to change notification settings - Fork 10
70 lines (67 loc) · 2.46 KB
/
build-flutter.yml
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
name: Build Flutter app for an environment
on: [push]
permissions:
contents: read
jobs:
deployAndroid:
permissions: write-all
name: Build Android apk
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v4
- name: ⚙️ Setup Java
uses: actions/setup-java@v4
with:
java-version: "17.x"
cache: 'gradle'
distribution: 'adopt'
id: java
- name: Set Flutter version
run: |
cd app
export FLUTTER_VERSION="$(sed -E -n -e 's/^.*flutter:\ ">=([0-9.]+)"/\1/p' pubspec.yaml)"
echo "FLUTTER_VERSION=$FLUTTER_VERSION" >> $GITHUB_ENV
- name: ⚙️ Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "${{ env.FLUTTER_VERSION }}"
channel: 'stable'
cache: true
id: flutter
- name: 🔐 Retrieve base64 keystore and decode it to a file
id: write_file
uses: timheuer/base64-to-file@v1.2
with:
fileName: "android-keystore.jks"
fileDir: "${{ github.workspace }}/"
encodedString: ${{ secrets.KEYSTORE_FILE_BASE64 }}
- name: 📝🔐 Create keystore.properties file
env:
KEYSTORE_PROPERTIES_PATH: ${{ github.workspace }}/app/android/key.properties
run: |
echo "storeFile=${{ github.workspace }}/android-keystore.jks" > $KEYSTORE_PROPERTIES_PATH
echo "keyAlias=${{ secrets.KEYSTORE_KEY_ALIAS }}" >> $KEYSTORE_PROPERTIES_PATH
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" >> $KEYSTORE_PROPERTIES_PATH
echo "keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD }}" >> $KEYSTORE_PROPERTIES_PATH
- name: Pub Get Packages
run: |
cd app
flutter --disable-analytics
flutter pub get --enforce-lockfile
- name: 🤖📦 Create Android release
run: |
cd app
flutter build apk --split-per-abi --release
- name: Create Artifact Name
run: |
BRANCH_NAME="apks_${{ github.head_ref || github.ref_name }}"
export ARTIFACT_NAME="${BRANCH_NAME////\_}"
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV
- name: ⬆️ 📦 Upload apks
uses: actions/upload-artifact@v4
with:
name: "${{ env.ARTIFACT_NAME }}"
path: "app/build/app/outputs/flutter-apk/*.apk"
retention-days: 30
overwrite: true