forked from tauri-apps/cef-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
279 lines (240 loc) · 8.09 KB
/
Copy pathupdate-bindings.yml
File metadata and controls
279 lines (240 loc) · 8.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
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: Update bindings
on:
workflow_dispatch:
inputs:
branch:
description: "Target branch"
default: "dev"
required: true
type: string
workflow_call:
inputs:
branch:
description: "Target branch"
default: "dev"
required: true
type: string
outputs:
published:
description: "Whether a PR was created for the target branch"
value: ${{ (jobs.publish-pr.outputs.published == 'true')
&& 'true' || 'false' }}
jobs:
update-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
outputs:
changed:
${{ (steps.pack-changes.outputs.changed-x86_64-unknown-linux-gnu == 'true')
&& 'true' || 'false' }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.branch }}
- name: Update Bindings
run: |
cargo run -p update-bindings -- -b -d -t ${{ matrix.target }}
- name: Pack Changes
id: pack-changes
run: |
git add .
CHANGED=($(git diff --name-only --staged | xargs))
if [ ${#CHANGED[@]} -gt 0 ]; then
tar -czf update-${{ matrix.target }}.tar.gz ${CHANGED[@]}
echo "changed-${{ matrix.target }}=true" >> "$GITHUB_OUTPUT"
else
echo "changed-${{ matrix.target }}=false" >> "$GITHUB_OUTPUT"
fi
- name: Upload Artifact
uses: actions/upload-artifact@v7.0.1
with:
name: update-${{ matrix.target }}
path: update-${{ matrix.target }}.tar.gz
if-no-files-found: ignore
update-macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
target:
- aarch64-apple-darwin
- x86_64-apple-darwin
outputs:
changed:
${{ (steps.pack-changes.outputs.changed-aarch64-apple-darwin == 'true'
|| steps.pack-changes.outputs.changed-x86_64-apple-darwin == 'true')
&& 'true' || 'false' }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.branch }}
- name: Update Bindings
run: |
cargo run -p update-bindings -- -b -d -t ${{ matrix.target }}
- name: Pack Changes
id: pack-changes
run: |
git add .
CHANGED=($(git diff --name-only --staged | xargs))
if [ ${#CHANGED[@]} -gt 0 ]; then
tar -czf update-${{ matrix.target }}.tar.gz ${CHANGED[@]}
echo "changed-${{ matrix.target }}=true" >> "$GITHUB_OUTPUT"
else
echo "changed-${{ matrix.target }}=false" >> "$GITHUB_OUTPUT"
fi
- name: Upload Artifact
uses: actions/upload-artifact@v7.0.1
with:
name: update-${{ matrix.target }}
path: update-${{ matrix.target }}.tar.gz
if-no-files-found: ignore
update-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-pc-windows-msvc
outputs:
changed:
${{ (steps.pack-changes.outputs.changed-x86_64-pc-windows-msvc == 'true')
&& 'true' || 'false' }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.branch }}
- name: Update Bindings
run: |
cargo run -p update-bindings -- -b -d -t ${{ matrix.target }}
- name: Pack Changes
id: pack-changes
run: |
git add .
$changed = @(git diff --name-only --staged)
if ($changed.Length -gt 0) {
tar -czf update-${{ matrix.target }}.tar.gz $changed
echo "changed-${{ matrix.target }}=true" >> "$env:GITHUB_OUTPUT"
} else {
echo "changed-${{ matrix.target }}=false" >> "$env:GITHUB_OUTPUT"
}
- name: Upload Artifact
uses: actions/upload-artifact@v7.0.1
with:
name: update-${{ matrix.target }}
path: update-${{ matrix.target }}.tar.gz
if-no-files-found: ignore
merge-changes:
runs-on: ubuntu-latest
needs:
- update-linux
- update-macos
- update-windows
if: needs.update-linux.outputs.changed == 'true'
|| needs.update-macos.outputs.changed == 'true'
|| needs.update-windows.outputs.changed == 'true'
outputs:
merged: ${{ steps.merge-artifacts.outputs.merged == 'true'
&& 'true' || 'false' }}
steps:
- name: Download Artifacts
uses: actions/download-artifact@v8.0.1
with:
pattern: update-*
merge-multiple: true
- name: Merge Artifacts
id: merge-artifacts
run: |
FILES=(update-*.tar.gz)
if [ ${#FILES[@]} -gt 0 ]; then
mkdir merged
cd merged
for FILE in ${FILES[@]}; do
echo "Extracting $FILE"
tar -xzf ../$FILE
rm ../$FILE
done
echo "Archiving merged changes"
tar -czvf ../merge-changes.tar.gz .
echo "merged=true" >> "$GITHUB_OUTPUT"
else
echo "No changes to merge"
echo "merged=false" >> "$GITHUB_OUTPUT"
fi
- name: Upload Merged Artifacts
if: steps.merge-artifacts.outputs.merged == 'true'
uses: actions/upload-artifact@v7.0.1
with:
name: merge-changes
path: merge-changes.tar.gz
publish-pr:
runs-on: ubuntu-latest
needs: merge-changes
if: needs.merge-changes.outputs.merged == 'true'
outputs:
published: ${{ steps.publish-pr.outputs.published == 'true'
&& 'true' || 'false' }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.branch }}
- name: Download Artifacts
uses: actions/download-artifact@v8.0.1
with:
name: merge-changes
- name: Update branch name
run: |
echo "Target branch name: ${{ inputs.branch }}"
SOURCE_BRANCH=${{ inputs.branch == 'dev' && 'update-bindings' || inputs.branch }}
echo "Source branch name: ${SOURCE_BRANCH}"
echo "SOURCE_BRANCH=${SOURCE_BRANCH}" >> $GITHUB_ENV
- name: Publish PR
id: publish-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
${{ inputs.branch == 'dev' && 'git switch -c ${SOURCE_BRANCH}' || 'echo "Re-using ${SOURCE_BRANCH}"' }}
RESET_REV=$(git rev-parse HEAD)
echo "Extracting merge-changes.tar.gz"
tar -xzf merge-changes.tar.gz
rm merge-changes.tar.gz
git reset ${RESET_REV}
git add .
CHANGED=($(git diff --name-only --staged | xargs))
if [ ${#CHANGED[@]} -gt 0 ]; then
git push --force -u origin ${SOURCE_BRANCH}
for VALUE in ${CHANGED[@]}; do
COMMIT_MESSAGE="chore: update ${VALUE}"
echo "${COMMIT_MESSAGE}"
base64 -w0 "${VALUE}" > "${VALUE}.base64"
RESET_REV=$(gh api graphql \
-F githubRepository=${GITHUB_REPOSITORY} \
-F branchName=${SOURCE_BRANCH} \
-F expectedHeadOid=${RESET_REV} \
-F "commitMessage=${COMMIT_MESSAGE}" \
-F query=@.github/api/createCommitOnBranch.graphql \
-F "files[][path]=${VALUE}" \
-F "files[][contents]=@${VALUE}.base64" \
| jq -r '.data.createCommitOnBranch.commit.oid')
done
git pull
echo "Publishing PR for ${SOURCE_BRANCH} branch"
for attempt in 1 2 3; do
if gh pr create -t "chore: update bindings" -b ""; then
break
fi
if [ "${attempt}" -eq 3 ]; then
echo "Failed to publish PR after ${attempt} attempts"
exit 1
fi
echo "gh pr create failed, retrying..."
sleep $((attempt * 5))
done
echo "published=true" >> "$GITHUB_OUTPUT"
else
echo "No changes detected"
echo "published=false" >> "$GITHUB_OUTPUT"
fi