-
Notifications
You must be signed in to change notification settings - Fork 54
213 lines (180 loc) · 6.09 KB
/
pr_build_all_platforms.yml
File metadata and controls
213 lines (180 loc) · 6.09 KB
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
name: Build PR Artifacts
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
permissions:
contents: read
pull-requests: write
concurrency:
group: pr-build-artifacts-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
APP_DIR: open_wearable
jobs:
build_android:
name: Build Android
runs-on: ubuntu-latest
outputs:
artifact_id: ${{ steps.upload_android.outputs.artifact-id }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: "17"
cache: gradle
- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}
- name: Build Android APK
working-directory: ${{ env.APP_DIR }}
run: flutter build apk --release
- name: Upload Android APK
id: upload_android
uses: actions/upload-artifact@v6
with:
name: android-apk
path: open_wearable/build/app/outputs/flutter-apk/app-release.apk
if-no-files-found: error
build_linux:
name: Build Linux
runs-on: ubuntu-latest
outputs:
artifact_id: ${{ steps.upload_linux.outputs.artifact-id }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
clang \
cmake \
libgtk-3-dev \
ninja-build \
pkg-config
- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}
- name: Build Linux bundle
working-directory: ${{ env.APP_DIR }}
run: flutter build linux --release
- name: Upload Linux bundle
id: upload_linux
uses: actions/upload-artifact@v6
with:
name: linux-bundle
path: open_wearable/build/linux/x64/release/bundle
if-no-files-found: error
build_windows:
name: Build Windows
runs-on: windows-latest
outputs:
artifact_id: ${{ steps.upload_windows.outputs.artifact-id }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}
- name: Build Windows runner
working-directory: ${{ env.APP_DIR }}
run: flutter build windows --release
- name: Upload Windows runner
id: upload_windows
uses: actions/upload-artifact@v6
with:
name: windows-runner
path: open_wearable/build/windows/x64/runner/Release
if-no-files-found: error
build_web:
name: Build Web
runs-on: ubuntu-latest
outputs:
artifact_id: ${{ steps.upload_web.outputs.artifact-id }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Flutter project
uses: ./.github/actions/flutter-prepare
with:
app-dir: ${{ env.APP_DIR }}
- name: Build Web bundle
working-directory: ${{ env.APP_DIR }}
run: flutter build web --release
- name: Upload Web bundle
id: upload_web
uses: actions/upload-artifact@v6
with:
name: web-bundle
path: open_wearable/build/web
if-no-files-found: error
comment_artifact_links:
name: Comment Artifact Links
runs-on: ubuntu-latest
needs:
- build_android
- build_linux
- build_windows
- build_web
if: always()
steps:
- name: Post or update PR comment with artifact links
uses: actions/github-script@v8
env:
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
ANDROID_ARTIFACT_ID: ${{ needs.build_android.outputs.artifact_id }}
LINUX_ARTIFACT_ID: ${{ needs.build_linux.outputs.artifact_id }}
WINDOWS_ARTIFACT_ID: ${{ needs.build_windows.outputs.artifact_id }}
WEB_ARTIFACT_ID: ${{ needs.build_web.outputs.artifact_id }}
with:
script: |
const marker = '<!-- pr-build-artifacts -->';
const prNumber = context.payload.pull_request.number;
const runUrl = process.env.RUN_URL;
const repoUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}`;
const linkFor = (id) => id
? `${repoUrl}/actions/runs/${context.runId}/artifacts/${id}`
: runUrl;
const body = `${marker}
### PR Build Artifacts
- Android APK: [Download Android build](${linkFor(process.env.ANDROID_ARTIFACT_ID)})
- Linux Bundle: [Download Linux build](${linkFor(process.env.LINUX_ARTIFACT_ID)})
- Windows Runner: [Download Windows build](${linkFor(process.env.WINDOWS_ARTIFACT_ID)})
- Web Bundle: [Download Web build](${linkFor(process.env.WEB_ARTIFACT_ID)})
Full workflow run: ${runUrl}`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const previous = comments.find(
(comment) =>
comment.user.type === 'Bot' &&
comment.body &&
comment.body.includes(marker)
);
if (previous) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: previous.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
}