forked from git/git
418 lines (395 loc) · 17.4 KB
/
git-artifacts.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
name: git-artifacts
on:
# This workflow can be triggered manually in the Actions tab, see
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
workflow_dispatch:
inputs:
build_only:
description: 'Optionally restrict what artifacts to build'
ref:
description: 'Optionally override which branch to build'
repository:
description: 'Optionally override from where to fetch the specified ref'
env:
GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
HOME: "${{github.workspace}}\\home"
MSYSTEM: MINGW64
USERPROFILE: "${{github.workspace}}\\home"
BUILD_ONLY: "${{github.event.inputs.build_only}}"
REPOSITORY: "${{github.event.inputs.repository}}"
REF: "${{github.event.inputs.ref}}"
jobs:
bundle-artifacts:
runs-on: windows-latest
steps:
- name: Configure user
shell: bash
run:
USER_NAME="${{github.actor}}" &&
USER_EMAIL="${{github.actor}}@users.noreply.github.com" &&
mkdir "$HOME" &&
git config --global user.name "$USER_NAME" &&
git config --global user.email "$USER_EMAIL" &&
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >>$GITHUB_ENV
- name: Download git-sdk-64-build-installers
shell: bash
run: |
# Use Git Bash to download and unpack the artifact
## Get artifact
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
id=$(curl "$urlbase?definitions=29&statusFilter=completed&resultFilter=succeeded&\$top=1" |
jq -r '.value[0].id')
download_url=$(curl "$urlbase/$id/artifacts" |
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')
curl -o artifacts.zip "$download_url"
## Unpack artifact
unzip artifacts.zip
- name: Clone build-extra
shell: bash
run: |
d=git-sdk-64-build-installers/usr/src/build-extra &&
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
- name: Prepare home directory for GPG signing
if: env.GPGKEY != ''
shell: bash
run: |
echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import &&
mkdir -p home &&
git config --global gpg.program "$PWD/git-sdk-64-build-installers/usr/src/build-extra/gnupg-with-gpgkey.sh" &&
info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" &&
git config --global user.name "${info% <*}" &&
git config --global user.email "<${info#*<}"
env:
GPGKEY: ${{secrets.GPGKEY}}
- name: Generate bundle artifacts
env:
GPGKEY: ${{secrets.GPGKEY}}
shell: powershell
run: |
& .\git-sdk-64-build-installers\git-cmd.exe --command=usr\bin\bash.exe -lc @"
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "`$@"\n' >/usr/bin/git &&
mkdir -p bundle-artifacts &&
{ test -n \"`$REPOSITORY\" || REPOSITORY='${{github.repository}}'; } &&
{ test -n \"`$REF\" || REF='${{github.ref}}'; } &&
git -c init.defaultBranch=main init --bare &&
git remote add -f origin https://github.com/git-for-windows/git &&
git fetch \"https://github.com/`$REPOSITORY\" \"`$REF:`$REF\" &&
tag_name=\"`$(git describe --match 'v[0-9]*' FETCH_HEAD)-`$(date +%Y%m%d%H%M%S)\" &&
echo \"prerelease-`${tag_name#v}\" >bundle-artifacts/ver &&
echo \"`${tag_name#v}\" >bundle-artifacts/display_version &&
echo \"`$tag_name\" >bundle-artifacts/next_version &&
git tag `$(test -z \"`$GPGKEY\" || echo \" -s\") -m \"Snapshot build\" \"`$tag_name\" FETCH_HEAD &&
git bundle create bundle-artifacts/git.bundle origin/main..\"`$tag_name\" &&
sh -x /usr/src/build-extra/please.sh mention feature \"Snapshot of `$(git show -s --pretty='tformat:%h (%s, %ad)' --date=short FETCH_HEAD)\" &&
git -C /usr/src/build-extra bundle create \"`$PWD/bundle-artifacts/build-extra.bundle\" origin/main..main
"@
- name: Clean up temporary files
if: always()
shell: bash
run: rm -rf home
- name: 'Publish Pipeline Artifact: bundle-artifacts'
uses: actions/upload-artifact@v1
with:
name: bundle-artifacts
path: bundle-artifacts
pkg:
runs-on: windows-latest
needs: bundle-artifacts
strategy:
matrix:
arch:
- name: x86_64
bitness: 64
bin: /amd64
- name: i686
bitness: 32
bin: ''
steps:
- name: Configure user
shell: bash
run:
USER_NAME="${{github.actor}}" &&
USER_EMAIL="${{github.actor}}@users.noreply.github.com" &&
mkdir "$HOME" &&
git config --global user.name "$USER_NAME" &&
git config --global user.email "$USER_EMAIL" &&
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >>$GITHUB_ENV
- name: Download git-sdk-64-makepkg-git
shell: bash
run: |
# Use Git Bash to download and unpack the artifact
## Get artifact
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
id=${{ needs.bundle-artifacts.outputs.latest-sdk64-extra-build-id }}
download_url="$(curl "$urlbase/$id/artifacts" |
jq -r '.value[] | select(.name == "git-sdk-64-makepkg-git").resource.downloadUrl')"
curl -o artifacts.zip "$download_url"
## Unpack artifact
unzip artifacts.zip
- name: Download bundle-artifacts
uses: actions/download-artifact@v1
with:
name: bundle-artifacts
path: bundle-artifacts
- name: Clone and update build-extra
shell: bash
run: |
d=git-sdk-64-makepkg-git/usr/src/build-extra &&
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
- name: Check out git/git
shell: bash
run: |
git -c init.defaultBranch=main init &&
git remote add -f origin https://github.com/git-for-windows/git &&
git fetch --tags bundle-artifacts/git.bundle $(cat bundle-artifacts/next_version) &&
git reset --hard $(cat bundle-artifacts/next_version)
- name: Prepare home directory for code-signing
env:
CODESIGN_P12: ${{secrets.CODESIGN_P12}}
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
shell: bash
run: |
cd home &&
mkdir -p .sig &&
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >.sig/codesign.p12 &&
echo -n "$CODESIGN_PASS" >.sig/codesign.pass
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
- name: Prepare home directory for GPG signing
if: env.GPGKEY != ''
shell: bash
run: |
echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import &&
info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" &&
git config --global user.name "${info% <*}" &&
git config --global user.email "<${info#*<}"
env:
GPGKEY: ${{secrets.GPGKEY}}
- name: Build mingw-w64-${{matrix.arch.name}}-git
env:
GPGKEY: "${{secrets.GPGKEY}}"
shell: powershell
run: |
& git-sdk-64-makepkg-git\usr\bin\sh.exe -lc @"
set -x
# Let `cv2pdb` find the DLLs
PATH=\"`$PATH:/c/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/:/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin${{matrix.arch.bin}}\"
type -p mspdb140.dll || exit 1
sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.bitness}}-bit --build-src-pkg -o artifacts HEAD &&
cp bundle-artifacts/ver artifacts/ &&
if test -n \"`$GPGKEY\"
then
for tar in artifacts/*.tar*
do
/usr/src/build-extra/gnupg-with-gpgkey.sh --detach-sign --no-armor `$tar
done
fi &&
b=`$PWD/artifacts &&
version=`$(cat bundle-artifacts/next_version) &&
(cd /usr/src/MINGW-packages/mingw-w64-git &&
cp PKGBUILD.`$version PKGBUILD &&
git commit -s -m \"mingw-w64-git: new version (`$version)\" PKGBUILD &&
git bundle create \"`$b\"/MINGW-packages.bundle origin/main..main)
"@
- name: Clean up temporary files
if: always()
shell: bash
run: rm -rf home
- name: Publish mingw-w64-${{matrix.arch.name}}-git
uses: actions/upload-artifact@v1
with:
name: pkg-${{matrix.arch.name}}
path: artifacts
artifacts:
runs-on: windows-latest
needs: pkg
strategy:
matrix:
artifact:
- name: installer
fileprefix: Git
fileextension: exe
- name: portable
fileprefix: PortableGit
fileextension: exe
- name: archive
fileprefix: Git
fileextension: tar.bz2
- name: mingit
fileprefix: MinGit
fileextension: zip
- name: mingit-busybox
fileprefix: MinGit
fileextension: zip
arch:
- name: x86_64
bitness: 64
- name: i686
bitness: 32
fail-fast: false
env:
MSYSTEM: MINGW${{matrix.arch.bitness}}
steps:
- name: Determine whether this job should be skipped
shell: bash
run: |
case " $BUILD_ONLY " in
' ') ;; # not set; build all
*" ${{matrix.artifact.name}} "*|*" ${{matrix.artifact.name}}-${{matrix.arch.name}} "*) ;; # build this artifact
*) echo "SKIP=true" >>$GITHUB_ENV;;
esac
- name: Download pkg-${{matrix.arch.name}}
if: env.SKIP != 'true'
uses: actions/download-artifact@v1
with:
name: pkg-${{matrix.arch.name}}
path: pkg-${{matrix.arch.name}}
- name: Download bundle-artifacts
if: env.SKIP != 'true'
uses: actions/download-artifact@v1
with:
name: bundle-artifacts
path: bundle-artifacts
- name: Download git-sdk-64-build-installers
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
shell: bash
run: |
# Use Git Bash to download and unpack the artifact
## Get artifact
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
id=${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
download_url="$(curl "$urlbase/$id/artifacts" |
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')"
curl -o artifacts.zip "$download_url"
## Unpack artifact
unzip artifacts.zip
- name: Download git-sdk-32-build-installers
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
shell: bash
run: |
# Use Git Bash to download and unpack the artifact
## Get artifact
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
id=$(curl "$urlbase?definitions=30&statusFilter=completed&resultFilter=succeeded&\$top=1" |
jq -r '.value[0].id')
download_url=$(curl "$urlbase/$id/artifacts" |
jq -r '.value[] | select(.name == "git-sdk-32-build-installers").resource.downloadUrl')
curl -o artifacts.zip "$download_url"
## Unpack artifact
unzip artifacts.zip
- name: Clone and update build-extra
if: env.SKIP != 'true'
shell: bash
run: |
d=git-sdk-${{matrix.arch.bitness}}-build-installers/usr/src/build-extra &&
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
- name: Prepare home directory for code-signing
env:
CODESIGN_P12: ${{secrets.CODESIGN_P12}}
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
if: env.SKIP != 'true' && (matrix.artifact.name == 'installer' || matrix.artifact.name == 'portable') && env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
shell: bash
run: |
mkdir -p home/.sig &&
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass &&
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
- name: Build ${{matrix.arch.bitness}}-bit ${{matrix.artifact.name}}
if: env.SKIP != 'true'
shell: powershell
run: |
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
set -x
/usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=`$(cat pkg-${{matrix.arch.name}}/ver) -o artifacts --${{matrix.artifact.name}} --pkg=pkg-${{matrix.arch.name}}/mingw-w64-${{matrix.arch.name}}-git-[0-9]*.tar.xz --pkg=pkg-${{matrix.arch.name}}/mingw-w64-${{matrix.arch.name}}-git-doc-html-[0-9]*.tar.xz &&
if test portable = '${{matrix.artifact.name}}' && test -n \"`$(git config alias.signtool)\"
then
git signtool artifacts/PortableGit-*.exe
fi &&
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed \"s/.* //\" >artifacts/sha-256.txt
"@
- name: Copy package-versions and pdbs
if: env.SKIP != 'true' && matrix.artifact.name == 'installer'
shell: powershell
run: |
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
cp /usr/src/build-extra/installer/package-versions.txt artifacts/ &&
a=`$PWD/artifacts &&
p=`$PWD/pkg-${{matrix.arch.name}} &&
(cd /usr/src/build-extra &&
mkdir -p cached-source-packages &&
cp \"`$p\"/*-pdb* cached-source-packages/ &&
GIT_CONFIG_PARAMETERS=\"'windows.sdk${{matrix.arch.bitness}}.path='\" ./please.sh bundle_pdbs --arch=${{matrix.arch.name}} --directory=\"`$a\" installer/package-versions.txt)
"@
- name: Clean up temporary files
if: always() && env.SKIP != 'true'
shell: bash
run: rm -rf home
- name: Publish ${{matrix.artifact.name}}-${{matrix.arch.name}}
if: env.SKIP != 'true'
uses: actions/upload-artifact@v1
with:
name: ${{matrix.artifact.name}}-${{matrix.arch.name}}
path: artifacts
nuget:
runs-on: windows-latest
needs: pkg
steps:
- name: Determine whether this job should be skipped
shell: bash
run: |
case " $BUILD_ONLY " in
' ') ;; # not set; build all
*" nuget "*) ;; # build this artifact
*) echo "SKIP=true" >>$GITHUB_ENV;;
esac
- name: Download pkg-x86_64
if: env.SKIP != 'true'
uses: actions/download-artifact@v1
with:
name: pkg-x86_64
path: pkg-x86_64
- name: Download bundle-artifacts
if: env.SKIP != 'true'
uses: actions/download-artifact@v1
with:
name: bundle-artifacts
path: bundle-artifacts
- name: Download git-sdk-64-build-installers
if: env.SKIP != 'true'
shell: bash
run: |
# Use Git Bash to download and unpack the artifact
## Get artifact
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
id=${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
download_url=$(curl "$urlbase/$id/artifacts" |
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')
curl -o artifacts.zip "$download_url"
## Unpack artifact
unzip artifacts.zip
- name: Clone and update build-extra
if: env.SKIP != 'true'
shell: bash
run: |
d=git-sdk-64-build-installers/usr/src/build-extra &&
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
- uses: nuget/setup-nuget@v1
if: env.SKIP != 'true'
- name: Build 64-bit NuGet packages
if: env.SKIP != 'true'
shell: powershell
run: |
& .\git-sdk-64-build-installers\usr\bin\bash.exe -lc @"
/usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=`$(cat pkg-x86_64/ver) -o artifacts --nuget --pkg=pkg-x86_64/mingw-w64-x86_64-git-[0-9]*.tar.xz --pkg=pkg-x86_64/mingw-w64-x86_64-git-doc-html-[0-9]*.tar.xz &&
/usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=`$(cat pkg-x86_64/ver) -o artifacts --nuget-mingit &&
openssl dgst -sha256 artifacts/Git*.nupkg | sed \"s/.* //\" >artifacts/sha-256.txt
"@
- name: Publish nuget-x86_64
if: env.SKIP != 'true'
uses: actions/upload-artifact@v1
with:
name: nuget-x86_64
path: artifacts