Skip to content

Commit cff21f2

Browse files
committed
WIP Configure flutter Android releases on the CI
1 parent 070fd07 commit cff21f2

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

.github/workflows/release.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: "Build"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build:
14+
name: Build & Release
15+
runs-on: macos-latest
16+
17+
steps:
18+
#1 Checkout Repository
19+
- name: Checkout Repository
20+
uses: actions/checkout@v3
21+
22+
#2 Setup Java
23+
- name: Set Up Java
24+
uses: actions/[email protected]
25+
with:
26+
distribution: 'oracle'
27+
java-version: '17'
28+
29+
#3 Setup Flutter
30+
- name: Setup Flutter
31+
uses: subosito/flutter-action@v2
32+
with:
33+
channel: stable
34+
35+
#4 Install Dependencies
36+
- name: Install Dependencies
37+
run: flutter pub get
38+
39+
#5 Setup Keystore
40+
- name: Decode Keystore
41+
run: |
42+
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks
43+
44+
- name: Create key.properties
45+
run: |
46+
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > android/key.properties
47+
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
48+
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
49+
echo "storeFile=keystore.jks" >> android/key.properties
50+
51+
#6 Building APK
52+
- name: Build APK
53+
run: flutter build apk --flavor dev --release -t lib/main_prod.dart
54+
55+
#7 Building App Bundle (aab)
56+
- name: Build appBundle
57+
run: flutter build appbundle --flavor dev --release -t lib/main_prod.dart
58+
59+
#9 Upload Artifacts
60+
- name: Upload Artifacts
61+
uses: actions/upload-artifact@v2
62+
with:
63+
name: Releases
64+
path: |
65+
build/app/outputs/flutter-apk/app-dev-release.apk
66+
build/app/outputs/bundle/devRelease/app-dev-release.aab
67+
68+
#10 Extract Version
69+
- name: Extract version from pubspec.yaml
70+
id: extract_version
71+
run: |
72+
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
73+
echo "VERSION=$version" >> $GITHUB_ENV
74+
75+
#11 Check if Tag Exists
76+
- name: Check if Tag Exists
77+
id: check_tag
78+
run: |
79+
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
80+
echo "TAG_EXISTS=true" >> $GITHUB_ENV
81+
else
82+
echo "TAG_EXISTS=false" >> $GITHUB_ENV
83+
fi
84+
85+
#12 Modify Tag if it Exists
86+
- name: Modify Tag
87+
if: env.TAG_EXISTS == 'true'
88+
id: modify_tag
89+
run: |
90+
new_version="${{ env.VERSION }}-build-${{ github.run_number }}"
91+
echo "VERSION=$new_version" >> $GITHUB_ENV
92+
93+
#13 Create Release
94+
- name: Create Release
95+
uses: ncipollo/release-action@v1
96+
with:
97+
artifacts: "build/app/outputs/flutter-apk/app-dev-release.apk,build/app/outputs/bundle/devRelease/app-dev-release.aab"
98+
tag: v${{ env.VERSION }}
99+
token: ${{ secrets.TOKEN }}

0 commit comments

Comments
 (0)