-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (112 loc) · 4.54 KB
/
ci.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
130
131
132
133
134
135
136
name: CI
on:
push:
branches:
- 'main'
- 'develop'
env:
FLUTTER_VERSION: '3.19.4'
JAVA_VERSION: '17'
JAVA_DISTRO: 'temurin'
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
- name: Set up Flutter
run: |
git clone https://github.com/flutter/flutter.git -b ${{ env.FLUTTER_VERSION }}
echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
- name: Fetch Flutter Dependencies
run: |
flutter pub get
- name: Execute Build Runner
run: |
dart run build_runner build
- name: Setup Bundler
run: |
sudo gem install bundler
- name: Install Bundles
run: |
cd android
sudo bundle install
- name: Decode Keystore
run: echo "${{ secrets.KEYSTORE }}" | base64 --decode > ./android/app/key.jks
- name: Set Keystore Path and Passwords
run: |
echo "KEYSTORE_PATH=./key.jks" >> $GITHUB_ENV
echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> $GITHUB_ENV
echo "KEY_ALIAS=${{ secrets.KEY_ALIAS }}" >> $GITHUB_ENV
echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> $GITHUB_ENV
- name: Create local.properties file
run: |
echo "sdk.dir=$ANDROID_HOME" > android/local.properties
echo "flutter.sdk=$GITHUB_WORKSPACE/flutter" >> android/local.properties
- name: Create Environment
env:
ENVIRONMENT: ${{ secrets.ENVIRONMENT }}
run: |
echo "env=$ENVIRONMENT" > .env
- name: Set execute permissions on gradlew
run: chmod +x android/gradlew
- name: Run Tests through Fastlane
run: |
cd android
bundle exec fastlane android test
- name: Extract Version
if: github.ref == 'refs/heads/main'
run: |
cd android
versionCode=$(grep 'flutter.versionCode' version.properties | cut -d'=' -f2)
versionName=$(grep 'flutter.versionName' version.properties | cut -d'=' -f2)
echo "VERSION_CODE=$versionCode" >> $GITHUB_ENV
echo "VERSION_NAME=$versionName" >> $GITHUB_ENV
- name: Update Version Code
if: github.ref == 'refs/heads/main'
run: |
cd android
VERSION_CODE=$(grep 'flutter.versionCode' version.properties | cut -d'=' -f2)
NEW_VERSION_CODE=$((VERSION_CODE+1))
echo "NEW_VERSION_CODE=$NEW_VERSION_CODE" >> $GITHUB_ENV
sed -i "s/flutter\.versionCode\s*=\s*[0-9]*/flutter\.versionCode=$NEW_VERSION_CODE/" version.properties
git config --global user.email "[email protected]"
git config --global user.name "Release Pipeline"
git remote set-url origin https://x-access-token:${{ secrets.ACCESS_TOKEN }}@github.com/Hollow-Ego/rabenkorb.git
git add version.properties
git commit -m "Increased version code to $NEW_VERSION_CODE"
git push
- name: Build Release APK through Fastlane
if: github.ref == 'refs/heads/main'
run: |
cd android
bundle exec fastlane android build_release
- name: Rename APK
if: github.ref == 'refs/heads/main'
run: mv ./build/app/outputs/flutter-apk/app-release.apk ./build/app/outputs/flutter-apk/app-release-${{ env.VERSION_NAME }}-${{ env.NEW_VERSION_CODE }}.apk
- name: Create GitHub Release
if: github.ref == 'refs/heads/main'
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.VERSION_NAME }}-${{ env.NEW_VERSION_CODE }}
release_name: Release ${{ env.VERSION_NAME }}-${{ env.NEW_VERSION_CODE }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Upload APK to GitHub Release
if: github.ref == 'refs/heads/main'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/app/outputs/flutter-apk/app-release-${{ env.VERSION_NAME }}-${{ env.NEW_VERSION_CODE }}.apk
asset_name: rabenkorb.${{ env.VERSION_NAME }}-${{ env.NEW_VERSION_CODE }}.apk
asset_content_type: application/vnd.android.package-archive
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}