forked from flutter/gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
248 lines (217 loc) · 10.1 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
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
name: Build Flutter App
on:
push:
branches: [main, master, hotfix/*]
# Pattern matched against refs/tags
tags:
- "**" # Push events to every tag including hierarchical tags like v1.0/beta
pull_request:
branches: [main, master]
workflow_dispatch:
inputs:
DEBUG:
required: true
default: "false"
WAIT_ON_ERROR:
required: true
default: "true"
jobs:
filter:
name: Filter builds
if: |
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip') &&
!github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
outputs:
skip-ios: "${{ steps.check.outputs.skip-ios }}"
skip-android: "${{ steps.check.outputs.skip-android }}"
steps:
- name: Check out code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
with:
fetch-depth: 0
- name: gate-check
id: check
run: |
set -x
# Allow specialized builds on only tagged builds or master builds. For master, check associated tag to allow specific builds. This check happens in the filter job.
# Add: Test for tag existance to allow master-only tag-less ios/android builds
if [[ "$GITHUB_REF" == "refs/heads/master" || "$GITHUB_REF" == "refs/heads/main" || "$GITHUB_REF" == "refs/heads/hotfix/"* ]] && [[ "$(git describe --tags --exact-match HEAD)" != "mobile/"* ]] && [[ "$(git describe --tags --exact-match HEAD)" != "ios/"* ]]; then
echo "skip-ios=true" >> $GITHUB_OUTPUT
else
echo "skip-ios=false" >> $GITHUB_OUTPUT
fi
if [[ "$GITHUB_REF" == "refs/heads/master" || "$GITHUB_REF" == "refs/heads/main" || "$GITHUB_REF" == "refs/heads/hotfix/"* ]] && [[ "$(git describe --tags --exact-match HEAD)" != "mobile/"* ]] && [[ "$(git describe --tags --exact-match HEAD)" != "android/"* ]]; then
echo "skip-android=true" >> $GITHUB_OUTPUT
else
echo "skip-android=false" >> $GITHUB_OUTPUT
fi
build-web:
name: Build & package builds for Web
if: |
always() &&
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip') &&
!github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
env:
DEBUG: ${{ github.event.inputs.DEBUG }}
WAIT_ON_ERROR: ${{ github.event.inputs.WAIT_ON_ERROR }}
steps:
- name: Check out code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
- name: Expose GitHub Runtime for docker buildx to use gha cache
uses: crazy-max/ghaction-github-runtime@056b8ec6661ce03a987ab8643a0edc346ae63fe3 #v2.2.0
- name: docker
uses: docker://docker
with:
args: /bin/sh -c "apk update && apk add bash && /bin/bash _ops/ci.build.sh web"
env:
SECRETS_B64_DEV: ${{ secrets.SECRETS_B64_DEV }}
SECRETS_B64_PROD: ${{ secrets.SECRETS_B64_PROD }}
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha }}
build-android:
needs:
- filter
name: Build & package builds for Android
if: |
always() &&
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip') &&
!github.event.pull_request.head.repo.fork &&
(startsWith(github.ref, 'refs/tags/android') || startsWith(github.ref, 'refs/tags/mobile') || startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/hotfix/')) &&
needs.filter.outputs.skip-android == 'false'
runs-on: ubuntu-latest
env:
DEBUG: ${{ github.event.inputs.DEBUG }}
WAIT_ON_ERROR: ${{ github.event.inputs.WAIT_ON_ERROR }}
steps:
- name: Check out code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
- name: Expose GitHub Runtime for docker buildx to use gha cache
uses: crazy-max/ghaction-github-runtime@056b8ec6661ce03a987ab8643a0edc346ae63fe3 #v2.2.0
- name: docker
uses: docker://docker
with:
args: /bin/sh -c "apk update && apk add bash && /bin/bash _ops/ci.build.sh android"
env:
SECRETS_B64_DEV: ${{ secrets.SECRETS_B64_DEV }}
SECRETS_B64_PROD: ${{ secrets.SECRETS_B64_PROD }}
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha }}
build-ios:
needs:
- filter
name: Build ios archive
if: |
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip') &&
!github.event.pull_request.head.repo.fork &&
(startsWith(github.ref, 'refs/tags/ios') || startsWith(github.ref, 'refs/tags/mobile') || startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/hotfix/')) &&
needs.filter.outputs.skip-ios == 'false'
runs-on: macos-latest
env:
DEBUG: ${{ github.event.inputs.DEBUG }}
WAIT_ON_ERROR: ${{ github.event.inputs.WAIT_ON_ERROR }}
FLUTTER_VER: 3.13.1
steps:
- name: Check out code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
- name: Restore Flutter archive
id: flutter-cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1
with:
key: flutter-archive-${{ env.FLUTTER_VER }}
path: |
~/Flutter/flutter_macos_${{ env.FLUTTER_VER }}-stable.zip
- name: Restore Flutter dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1
with:
path: ~/Flutter/flutter
key: ${{ runner.OS }}-flutter-install-cache-${{ env.FLUTTER_VER }}
- name: build
run: /bin/bash runner ios-build release
env:
SECRETS_B64_DEV: ${{ secrets.SECRETS_B64_DEV }}
SECRETS_B64_PROD: ${{ secrets.SECRETS_B64_PROD }}
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha }}
- name: Cache Flutter archive
if: steps.flutter-cache.outputs.cache-hit != 'true'
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1
with:
key: flutter-archive-${{ env.FLUTTER_VER }}
path: |
~/Flutter/flutter_macos_${{ env.FLUTTER_VER }}-stable.zip
- name: Cache Flutter dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1
with:
path: ~/Flutter/flutter
key: ${{ runner.OS }}-flutter-install-cache-${{ env.FLUTTER_VER }}
- name: Cache ios archive
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1
with:
key: ios-archive-${{ github.event.pull_request.head.sha || github.sha }}-${{ github.head_ref || github.ref_name }}-${{ github.run_attempt }}
path: |
./build/ios/archive/Runner.xcarchive
package-ios:
needs:
- build-ios
name: Package ios archive
if: |
!contains(github.event.head_commit.message, 'ci skip') &&
!contains(github.event.pull_request.title, 'ci skip') &&
!github.event.pull_request.head.repo.fork &&
(startsWith(github.ref, 'refs/tags/ios') || startsWith(github.ref, 'refs/tags/mobile') || startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/hotfix/')) &&
needs.filter.outputs.skip-ios == 'false'
runs-on: ubuntu-latest
env:
DEBUG: ${{ github.event.inputs.DEBUG }}
WAIT_ON_ERROR: ${{ github.event.inputs.WAIT_ON_ERROR }}
steps:
- name: Check out code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
- name: Restore Cache ios archive
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 #v3.3.1
with:
key: ios-archive-${{ github.event.pull_request.head.sha || github.sha }}-${{ github.head_ref || github.ref_name }}-${{ github.run_attempt }}
restore-keys: |
ios-archive-${{ github.event.pull_request.head.sha || github.sha }}-${{ github.head_ref || github.ref_name }}-
path: |
./build/ios/archive/Runner.xcarchive
fail-on-cache-miss: true
- name: Expose GitHub Runtime for docker buildx to use gha cache
uses: crazy-max/ghaction-github-runtime@056b8ec6661ce03a987ab8643a0edc346ae63fe3 #v2.2.0
- name: docker
uses: docker://docker
with:
args: /bin/sh -c "apk update && apk add bash && /bin/bash _ops/ci.build.sh ios"
env:
SECRETS_B64_DEV: ${{ secrets.SECRETS_B64_DEV }}
SECRETS_B64_PROD: ${{ secrets.SECRETS_B64_PROD }}
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha }}
dispatch:
# using always() in this condition causes the job to not be skipped, sort of GA bug, always() check shldn't be needed
if: |
startsWith(github.ref, 'refs/tags/') &&
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
needs:
- build-web
- build-android
- build-ios
- package-ios
strategy:
matrix:
repo: ["slaystack/xops"]
name: Dispatch
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@26b39ed245ab8f31526069329e112ab2fb224588 #v2.1.1
with:
token: ${{ secrets.PA_TOKEN }}
repository: ${{ matrix.repo }}
event-type: ops_update
client-payload: '{ "app" : "gallery","dependency_type" : "core","github": ${{ tojson(github) }}}'
#curl -vs --request POST --url https://api.github.com/repos/slaystack/xops/dispatches --header "authorization: token ${PA_TOKEN}" --header 'Accept: application/vnd.github.everest-preview+json' --header 'content-type: application/json' --data '{"event_type": "ops_update","client_payload": {"app" : "gallery","dependency" : "core","github" : {"ref": "refs/heads/master","sha": "5e06ae0aa5caa5b4a18adaed27021f0a1cb86e8f","repository": "aweps/flumo"}}}'