-
Notifications
You must be signed in to change notification settings - Fork 7
103 lines (89 loc) · 3.2 KB
/
main.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: "Build & Release" # You can name it as you want
on:
pull_request:
branches:
- dev
- test
- master
push:
branches:
- dev
- test
- master
jobs: # Telling what jobs we need to happen
build: # Specify the building name and machine
name: Build & Release # you can name the build whatever you want
runs-on: macos-latest # here we selected macos-latest to be able to get ios build
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
# flutter-version-file: pubspec.yaml # path to pubspec.yaml
- run: flutter --version
#4 Install Dependencies
- name: Install Dependencies
run: flutter pub get
#5 Setup Keystore
- name: Decode Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks
- name: Create key.properties
run: |
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
echo "storeFile=keystore.jks" >> android/key.properties
#6 Building APK
- name: Build APK
run: flutter build apk --release
#7 Building App Bundle (aab)
- name: Build appBundle
run: flutter build appbundle
#8 Build IPA ( IOS Build )
- name: Build IPA
run: flutter build ipa --no-codesign
- name: Compress Archives and IPAs
run: |
cd build
tar -czf ios_build.tar.gz ios
#9 Upload Artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: Releases
path: |
build/app/outputs/flutter-apk/app-release.apk
build/app/outputs/bundle/release/app-release.aab
build/ios_build.tar.gz
#10 Extract Version
- 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
#11 Check if Tag Exists
- 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
#12 Modify Tag if it Exists
- 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
#13 Create Release
- 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${{ env.VERSION }}
token: ${{ secrets.TOKEN }}