-
Notifications
You must be signed in to change notification settings - Fork 0
260 lines (222 loc) · 8.46 KB
/
vtd-trigger.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: VTD Banana
on:
repository_dispatch:
types:
- vtd-trigger
- v*
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
TELEGRAM_GROUP_ID: ${{ vars.TELEGRAM_GROUP_ID}}
TELEGRAM_TOPIC_ID: ${{ vars.TELEGRAM_TOPIC_ID}}
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
REF_NAME: ${{ github.event.client_payload.ref_name}}
TRIGGERING_ACTOR: ${{ github.event.client_payload.triggering_actor}}
jobs:
pre-deployment:
name: Pre Deployment
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.value }}
message-information: ${{ steps.get-message-information.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ secrets.VTD_REPOSITORY }}
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event.client_payload.ref_name}}
- name: Set matrix
id: set-matrix
run: |
MATRIX="[{\"format\":\"IPA\",\"name\":\"macos-14\"},{\"format\":\"APK\",\"name\":\"ubuntu-22.04\"}]"
if [[ "$REF_NAME" =~ "prd" ]]; then
MATRIX="[{\"format\":\"IPA\",\"name\":\"macos-14\"},{\"format\":\"APK\",\"name\":\"ubuntu-22.04\"},{\"format\":\"AAB\",\"name\":\"ubuntu-22.04\"}]"
fi
echo "value=$MATRIX" >> $GITHUB_OUTPUT
- name: Generate message
id: get-message-information
run: |
source .github/scripts/utils.sh
echo "value=$(get_message_information)" >> "$GITHUB_OUTPUT"
timeout-minutes: 1
- name: Log value
run: |
echo "tag-source: $REF_NAME"
echo "matrix: ${{ steps.set-matrix.outputs.value }}"
echo "message-information: ${{ steps.get-message-information.outputs.value }}"
- name: Send telegram message
uses: tuanngocptn/macos-telegram-action@v1
with:
type: topic
message: "🎬 - Start: ${{ steps.get-message-information.outputs.value }}"
- name: Send message failure
if: failure()
uses: tuanngocptn/macos-telegram-action@v1
with:
type: topic
message: "💥 - Failure ${{ steps.get-message-information.outputs.value }}"
deploy:
continue-on-error: true
strategy:
fail-fast: true
matrix:
include: ${{ fromJson(needs.pre-deployment.outputs.matrix) }}
runs-on: ${{ matrix.name }}
needs: [pre-deployment]
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ secrets.VTD_REPOSITORY }}
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event.client_payload.ref_name}}
# Setup environment
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2.2"
bundler-cache: true
- name: Setup flutter 3.13.2
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.2"
channel: "stable"
- run: flutter --version
- name: Set up JDK 17
uses: actions/setup-java@v4
if: matrix.format != 'IPA'
with:
java-version: "17"
distribution: "temurin"
- name: Setup Android SDK
if: matrix.format != 'IPA'
uses: android-actions/setup-android@v3
- name: setup-cocoapods
if: matrix.format == 'IPA'
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: 1.14.3
- name: Setup gem
run: bundle install
# Running
- name: Change version, build number and config environment
run: bash .github/scripts/change_version_and_build_number.sh && bash .github/scripts/config_environment.sh
- name: Clean and install libs
run: flutter clean && flutter pub get
- name: Generate launcher icon
run: flutter pub run flutter_launcher_icons:main
- name: Build APK
if: matrix.format == 'APK'
run: flutter build apk
- name: Build AAB
if: matrix.format == 'AAB'
run: flutter build appbundle
- name: Cache Primes
if: matrix.format == 'IPA'
id: cache-primes
uses: actions/cache@v4
with:
path: |
ios/Pods
ios/Podfile.lock
key: vtd-cache-pods-${{ hashFiles('pubspec.lock') }}
- name: Pod install
if: ${{ (matrix.format == 'IPA') && (steps.cache-primes.outputs.cache-hit != 'true') }}
working-directory: ios
run: pod install
- name: Install certificate and provision
if: matrix.format == 'IPA'
run: |
# create variables
CERTIFICATE_PATH=$GITHUB_WORKSPACE/.github/scripts/data/certificates/distribution.p12
PP_PATH=$GITHUB_WORKSPACE/.github/scripts/data/provisions
KEYCHAIN_PATH=$GITHUB_WORKSPACE/.github/scripts/data/certificates/app-signing.keychain-db
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH/* ~/Library/MobileDevice/Provisioning\ Profiles
# - name: Build ipa
# if: matrix.format == 'IPA'
# run: flutter build ipa --release --export-options-plist ios/export.plist
- name: Build ipa
if: matrix.format == 'IPA'
uses: maierj/[email protected]
with:
lane: "ios build_ipa"
# Deployment
- name: Upload APK to Firebase
if: matrix.format == 'APK'
uses: maierj/[email protected]
with:
lane: "android beta"
- name: Upload APK open testing Playstore
if: ${{ (matrix.format == 'APK') && contains(env.REF_NAME, 'prd') }}
uses: maierj/[email protected]
with:
lane: "android upload_to_open_testing_play_store"
- name: Deploy ipa
if: matrix.format == 'IPA'
uses: maierj/[email protected]
with:
lane: "ios beta"
- name: Send telegram message
uses: tuanngocptn/macos-telegram-action@v1
with:
type: topic
message: "✅ - Buid Success ${{ matrix.format }}: ${{ needs.pre-deployment.outputs.message-information }}"
- name: Send message failure
if: failure()
uses: tuanngocptn/macos-telegram-action@v1
with:
type: topic
message: "💥 - Failure ${{ matrix.format }}: ${{ needs.pre-deployment.outputs.message-information }}"
after-deployment:
needs: [deploy]
name: After Deployment
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ secrets.VTD_REPOSITORY }}
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event.client_payload.ref_name}}
- name: Get environment full
uses: dkershner6/switch-case-action@v1
id: get-environment
with:
default: "debug"
conditionals-with-values: |
${{ contains(env.REF_NAME, 'prd') }} => production
${{ contains(env.REF_NAME, 'stg') }} => staging
${{ contains(env.REF_NAME, 'dev') }} => development
- name: Get version and build number
id: get-version-sentry
run: |
source .github/scripts/utils.sh
echo "value=$(get_sentry_version)" >> "$GITHUB_OUTPUT"
timeout-minutes: 1
- name: Log value
run: |
echo "Bundle identifier: ${{ steps.get-environment.outputs.value }}"
echo "Version: ${{ steps.get-version-sentry.outputs.value }}"
- name: Create Sentry release
uses: getsentry/action-release@v1
if: ${{ steps.get-environment.outputs.value != 'debug' }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
set_commits: skip
environment: ${{ steps.get-environment.outputs.value }}
version: ${{ steps.get-version-sentry.outputs.value }}