-
Notifications
You must be signed in to change notification settings - Fork 5
103 lines (100 loc) · 3.66 KB
/
android.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
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
name: Android Release
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
upload:
description: 'Upload to release?'
type: boolean
required: true
default: false
env:
GOOGLE_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }}
jobs:
android:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: "11.x"
cache: 'gradle'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Flutter version
run: flutter --version
- name: Install dependencies
run: flutter pub get
# <-------- START: Utility scripts -------->
- name: Get Tag
id: GetTag
run: echo "tag=$(dart scripts/get_tag.dart ${{ github.event.inputs.tag }} ${{ github.ref }})" >> $GITHUB_OUTPUT
- name: Get Pubspec Version
id: GetPubspecVersion
run: echo "version=$(dart scripts/pubspec_version.dart)" >> $GITHUB_OUTPUT
# <-------- END: Utility scripts -------->
- name: Create keystore file
uses: timheuer/base64-to-file@v1
with:
fileName: 'release.jks'
fileDir: './android/keystore/'
encodedString: ${{ secrets.KEYSTORE_FILE }}
- name: Create keystore.properties file
run: echo "${{ secrets.KEYSTORE_PROPERTIES }}" > android/keystore.properties
- name: Build APK
run: flutter build apk --release --dart-define-from-file=configs/github.json
- name: Build AAB
run: flutter build appbundle --release --dart-define-from-file=configs/github.json
# - name: Upload
# if: ${{ inputs.upload_to_play_store || github.event_name == 'release' }}
# run: |
# gem install fastlane
# bundle install
# fastlane android upload
- name: Rename APK
run: mv build/app/outputs/flutter-apk/app-release.apk TargetMate-android-${{ steps.GetTag.outputs.tag }}.apk
- name: Rename AppBundle
run: mv build/app/outputs/bundle/release/app-release.aab TargetMate-android-${{ steps.GetTag.outputs.tag }}.aab
- name: Upload APK
uses: actions/upload-artifact@v3
with:
path: TargetMate-android-${{ steps.GetTag.outputs.tag }}.apk
if-no-files-found: error
retention-days: 5
- name: Upload AAB
uses: actions/upload-artifact@v3
with:
path: TargetMate-android-${{ steps.GetTag.outputs.tag }}.aab
if-no-files-found: error
retention-days: 5
- name: Upload APK to release
if: ${{ inputs.upload || github.event_name == 'release' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: TargetMate-android-${{ steps.GetTag.outputs.tag }}.apk
tag: refs/tags/${{ steps.GetTag.outputs.tag }}
overwrite: true
file_glob: true
- name: Upload AppBundle to release
if: ${{ inputs.upload || github.event_name == 'release' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: TargetMate-android-${{ steps.GetTag.outputs.tag }}.aab
tag: refs/tags/${{ steps.GetTag.outputs.tag }}
overwrite: true
file_glob: true
- name: Clean up keystore and keystore.properties
if: ${{ always() }}
run: |
rm android/keystore.properties
rm android/keystore/release.jks