-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (107 loc) · 3.97 KB
/
deploy_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
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
name: CI_DEPLOY_ANDROID
on:
push:
branches: [stable]
# eventually possible to add pull_request in the same way
jobs:
build:
# Only run this job if the branch name starts with 'release/'
name: android release
runs-on: ubuntu-latest
env:
# Setup env variables that will be used throughout the workflow
JAVA_VERSION: 12.0
FLUTTER_VERSION: 3.13.1
AAB_PATH: build/app/outputs/bundle/release/app-release.aab
KEYSTORE_PATH: android/upload-keystore.jks
KEY_PROPS_PATH: android/key.properties
SERVICE_ACCOUNT_PATH: store_credentials.json
steps:
# Checkout repository codebase
- name: Checkout Repository
uses: actions/checkout@v3
# Setup Java in the VM
- name: Setup Java
uses: actions/setup-java@v3.12.0
with:
distribution: 'oracle'
java-version: '17'
# Setup Flutter in the VM
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.2'
channel: 'stable'
# Decode Android env variables
# - name: Decode Android keystore
# run: echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 --decode > ${{ env.KEYSTORE_PATH }}
# - name: Decode Android key properties
# run: echo "${{ secrets.ANDROID_KEY_PROPERTIES }}" | base64 --decode > ${{ env.KEY_PROPS_PATH }}
# Decode Android release Service Account
# - name: Decode Android Service Account
# run: echo "${{ secrets.PRODUCTION_CREDENTIAL_FILE }}" | base64 --decode > ${{ env.SERVICE_ACCOUNT_PATH }}
# Run flutter commands
- name: Install Flutter
run: flutter pub get
- name: Build APK
run: flutter build apk --release
- name: Build appBundle
run: flutter build appbundle
- name: Build IPA for iOS
run: flutter build ipa --no-codesign
- name: Compress archives and IPAs
run: |
cd build
tar -czf ios_build.tar.gz ios
# Build Android Bundle release file
# - name: Build aab
# run: |
# flutter build appbundle
# --release
# Upload generated aab to project artifacts
# - name: Upload generated aab to the artifacts
# uses: actions/upload-artifact@master
# with:
# name: aab-stores
# path: {{ env.AAB_PATH }}
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: Release
path: |
build/app/outputs/flutter-apk/app-release.apk
build/app/outputs/bundle/release/app-release.aab
build/ios_build.tar/g
- name: Extract version from pubspec.yaml
id: extract_version
run: |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
echo "VERSION=$version" >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Modify Tag
if: env.TAG_EXISTS == 'true'
id: modify_tag
run: |
new_version="${{ env.VERSION }}-build-${{ github.run_number }}"
echo "VERSION=$new_version" >> $GITHUB_ENV
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/flutter-apk.app-release.apk, build/app/outputs/bundle/release/app-release.aab, build/ios_build.tar.gz"
tag: v${{ github.run_number }}
token: ${{ secrets.TOKEN }}
# Deploy bundle to Google Play internal testing
#- name: Deploy to Play Store (Internal testing)
# uses: r0adkll/upload-google-play@v1
# with:
# serviceAccountJson: {{ env.SERVICE_ACCOUNT_PATH }}
# packageName: com.yourapp.package
# releaseFiles: {{ env.AAB_PATH }}
# track: internal