-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (176 loc) · 6.37 KB
/
cd.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Continuous Delivery
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: false
jobs:
release:
name: 🚀 Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.rp.outputs.release_created }}
created_tag: ${{ steps.rp.outputs.tag_name }}
steps:
- name: 📚 Code Checkout
uses: actions/checkout@v4
- name: 🚀 Release
id: rp
uses: googleapis/release-please-action@v4
with:
manifest-file: release.manifest.json
config-file: release.config.json
include-component-in-tag: false
dependencies:
name: 📦 Setup Dependencies For Deployment
needs: release
if: ${{ needs.release.outputs.release_created }}
runs-on: macos-latest
env:
JDK_VERSION: 17
JDK_DISTRIBUTION: microsoft
outputs:
release-tag: ${{ needs.release.outputs.created_tag }}
fl-cache-key: ${{ steps.fl-setup.outputs.CACHE-KEY }}
fl-pub-cache-key: ${{ steps.fl-setup.outputs.PUB-CACHE-KEY }}
jdk-version: ${{ steps.jdk.outputs.version }}
jdk-distro: ${{ env.JDK_DISTRIBUTION }}
steps:
- name: 📚 Code Checkout
uses: actions/checkout@v4
- name: 🐦 Setup Flutter SDK
id: fl-setup
uses: subosito/flutter-action@v2
with:
flutter-version-file: ./pubspec.yaml
channel: stable
cache: true
cache-key: |
fl-:channel:-v:version:-:os:-:arch:-cd-${{ hashFiles('./pubspec.lock') }}
pub-cache-key: |
fl-pub-:channel:-v:version:-:os:-:arch:-cd-${{ hashFiles('./pubspec.lock') }}
- name: ☕ Setup JDK v${{ env.JDK_VERSION }}
id: jdk
uses: actions/setup-java@v4
with:
java-version: ${{ env.JDK_VERSION }}
distribution: ${{ env.JDK_DISTRIBUTION }}
cache: "gradle"
cache-dependency-path: |
android/*.gradle*
android/**/gradle-wrapper.properties
- name: 🔍 flutter doctor
run: flutter doctor -v
- name: 📦 Get dependencies
run: flutter pub get
web-github-pages:
name: 🚀 Web Deploy on Github Pages
needs: dependencies
runs-on: macos-latest
permissions:
contents: write
steps:
- name: 📚 Code Checkout
uses: actions/checkout@v4
- name: 📦 Restore Dependencies
uses: subosito/flutter-action@v2
with:
flutter-version-file: ./pubspec.yaml
channel: stable
cache: true
cache-key: ${{needs.dependencies.outputs.fl-cache-key}}
pub-cache-key: ${{needs.dependencies.outputs.fl-pub-cache-key}}
- name: 🏗️ Build code utils
run: |
dart run build_runner build -d
flutter gen-l10n
- name: 🏗️ Generate build number
id: build-number
uses: onyxmueller/build-tag-number@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
prefix: "web--github-pages--"
- name: 🏗️ Build web release
env:
BASE_HREF: "/dicoding_story_fl/"
BUILD_NUMBER: ${{ steps.build-number.outputs.build_number }}
WEB_RENDERER: canvaskit
run: |
flutter build web --release --base-href ${{ env.BASE_HREF }} --build-number ${{ env.BUILD_NUMBER }} --build-number ${{ env.BUILD_NUMBER }} --web-renderer ${{ env.WEB_RENDERER }}
- name: 🚀 Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3
env:
RELEASE_TAG: ${{ needs.dependencies.outputs.release-tag }}
BUILD_NUMBER: ${{ steps.build-number.outputs.build_number }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/web
publish_branch: web-release
commit_message:
"${{ env.RELEASE_TAG }}+${{ env.BUILD_NUMBER }} web release"
apk-github-release:
name: 🚀 Apk Release on Github Release
needs: dependencies
runs-on: macos-latest
permissions:
contents: write
steps:
- name: 📚 Code Checkout
uses: actions/checkout@v4
- name: 📦 Restore Dependencies
uses: subosito/flutter-action@v2
with:
flutter-version-file: ./pubspec.yaml
channel: stable
cache: true
cache-key: ${{needs.dependencies.outputs.fl-cache-key}}
pub-cache-key: ${{needs.dependencies.outputs.fl-pub-cache-key}}
- name: ☕ Setup JDK v${{ needs.dependencies.outputs.jdk-version }}
id: jdk
uses: actions/setup-java@v4
with:
java-version: ${{ needs.dependencies.outputs.jdk-version }}
distribution: ${{ needs.dependencies.outputs.jdk-distro }}
cache: "gradle"
cache-dependency-path: |
android/*.gradle*
android/**/gradle-wrapper.properties
- name: 📝 Accept Android licenses
run: "yes | flutter doctor --android-licenses"
- name: 🏗️ Build code utils
run: |
dart run build_runner build -d
flutter gen-l10n
mkdir secrets
echo "${{ secrets.ANDROID_RELEASE_KEY_BASE64 }}" | base64 --decode > secrets/android-release-key.jks
echo "${{ secrets.ANDROID_KEY_PROPS_BASE64 }}" | base64 --decode > android/key.properties
- name: 🏗️ Generate build number
id: build-number
uses: onyxmueller/build-tag-number@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
prefix: "apk--github-release--"
- name: 🏗️ Build APK release
env:
BUILD_NUMBER: ${{ steps.build-number.outputs.build_number }}
run: |
flutter build apk --release --build-number ${{ env.BUILD_NUMBER }}
- name: 🚀 Publish to Github Release
uses: softprops/action-gh-release@v2
env:
RELEASE_TAG: ${{ needs.dependencies.outputs.release-tag }}
BUILD_NUMBER: ${{ steps.build-number.outputs.build_number }}
with:
name: "${{ env.RELEASE_TAG }}+${{ env.BUILD_NUMBER }} APK Release"
tag_name: "${{ env.RELEASE_TAG }}+${{ env.BUILD_NUMBER }}--apk-build"
generate_release_notes: true
files: |
build/app/outputs/flutter-apk/app-release.apk
CHANGELOG.md
LICENSE