Skip to content

Commit f71175c

Browse files
dschoGit for Windows Build Agent
authored andcommitted
git-artifacts: Use the shiny new setup-git-for-windows-sdk Action
This simplifies the workflow dramatically. Note that we have to reinstate that `/usr/bin/git` hack (a shell script that simply redirects to `/mingw64/bin/git.exe`) in the `pkg` job manually, since we no longer cache the `build-installers` artifact _after_ installing that hack in `bundle-artifacts`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d33f6e8 commit f71175c

File tree

1 file changed

+81
-203
lines changed

1 file changed

+81
-203
lines changed

.github/workflows/git-artifacts.yml

Lines changed: 81 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,13 @@ jobs:
3939
git config --global user.name "$USER_NAME" &&
4040
git config --global user.email "$USER_EMAIL" &&
4141
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >>$GITHUB_ENV
42-
- name: Determine latest git-sdk-64-extra-artifacts build ID
43-
id: determine-latest-sdk64-extra-build-id
44-
shell: bash
45-
run: |
46-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
47-
id=$(curl "$urlbase?definitions=29&statusFilter=completed&resultFilter=succeeded&\$top=1" |
48-
jq -r '.value[0].id')
49-
50-
echo "Latest ID is ${id}"
51-
echo "::set-output name=id::$id"
52-
- name: Cache git-sdk-64-build-installers
53-
id: cache-sdk-build-installers
54-
uses: actions/cache@v2
42+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
5543
with:
56-
path: git-sdk-64-build-installers
57-
key: build-installers-64-${{ steps.determine-latest-sdk64-extra-build-id.outputs.id }}
58-
- name: Download git-sdk-64-build-installers
59-
if: steps.cache-sdk-build-installers.outputs.cache-hit != 'true'
60-
shell: bash
61-
run: |
62-
# Use Git Bash to download and unpack the artifact
63-
64-
## Get artifact
65-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
66-
id=${{ steps.determine-latest-sdk64-extra-build-id.outputs.id }}
67-
download_url=$(curl "$urlbase/$id/artifacts" |
68-
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')
69-
70-
curl -o artifacts.zip "$download_url"
71-
72-
## Unpack artifact
73-
unzip artifacts.zip
44+
flavor: build-installers
7445
- name: Clone build-extra
7546
shell: bash
7647
run: |
77-
d=git-sdk-64-build-installers/usr/src/build-extra &&
48+
d=/usr/src/build-extra &&
7849
if test ! -d $d/.git
7950
then
8051
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
@@ -88,7 +59,7 @@ jobs:
8859
run: |
8960
echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import &&
9061
mkdir -p home &&
91-
git config --global gpg.program "$PWD/git-sdk-64-build-installers/usr/src/build-extra/gnupg-with-gpgkey.sh" &&
62+
git config --global gpg.program "/usr/src/build-extra/gnupg-with-gpgkey.sh" &&
9263
info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" &&
9364
git config --global user.name "${info% <*}" &&
9465
git config --global user.email "<${info#*<}"
@@ -97,28 +68,26 @@ jobs:
9768
- name: Generate bundle artifacts
9869
env:
9970
GPGKEY: ${{secrets.GPGKEY}}
100-
shell: powershell
71+
shell: bash
10172
run: |
102-
& .\git-sdk-64-build-installers\git-cmd.exe --command=usr\bin\bash.exe -lc @"
103-
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "`$@"\n' >/usr/bin/git &&
104-
mkdir -p bundle-artifacts &&
73+
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"\n' >/usr/bin/git &&
74+
mkdir -p bundle-artifacts &&
10575
106-
{ test -n \"`$REPOSITORY\" || REPOSITORY='${{github.repository}}'; } &&
107-
{ test -n \"`$REF\" || REF='${{github.ref}}'; } &&
108-
git -c init.defaultBranch=main init --bare &&
109-
git remote add -f origin https://github.com/git-for-windows/git &&
110-
git fetch \"https://github.com/`$REPOSITORY\" \"`$REF:`$REF\" &&
76+
{ test -n "$REPOSITORY" || REPOSITORY='${{github.repository}}'; } &&
77+
{ test -n "$REF" || REF='${{github.ref}}'; } &&
78+
git -c init.defaultBranch=main init --bare &&
79+
git remote add -f origin https://github.com/git-for-windows/git &&
80+
git fetch "https://github.com/$REPOSITORY" "$REF:$REF" &&
11181
112-
tag_name=\"`$(git describe --match 'v[0-9]*' FETCH_HEAD)-`$(date +%Y%m%d%H%M%S)\" &&
113-
echo \"prerelease-`${tag_name#v}\" >bundle-artifacts/ver &&
114-
echo \"`${tag_name#v}\" >bundle-artifacts/display_version &&
115-
echo \"`$tag_name\" >bundle-artifacts/next_version &&
116-
git tag `$(test -z \"`$GPGKEY\" || echo \" -s\") -m \"Snapshot build\" \"`$tag_name\" FETCH_HEAD &&
117-
git bundle create bundle-artifacts/git.bundle origin/main..\"`$tag_name\" &&
82+
tag_name="$(git describe --match 'v[0-9]*' FETCH_HEAD)-$(date +%Y%m%d%H%M%S)" &&
83+
echo "prerelease-${tag_name#v}" >bundle-artifacts/ver &&
84+
echo "${tag_name#v}" >bundle-artifacts/display_version &&
85+
echo "$tag_name" >bundle-artifacts/next_version &&
86+
git tag $(test -z "$GPGKEY" || echo " -s") -m "Snapshot build" "$tag_name" FETCH_HEAD &&
87+
git bundle create bundle-artifacts/git.bundle origin/main.."$tag_name" &&
11888
119-
sh -x /usr/src/build-extra/please.sh mention feature \"Snapshot of `$(git show -s --pretty='tformat:%h (%s, %ad)' --date=short FETCH_HEAD)\" &&
120-
git -C /usr/src/build-extra bundle create \"`$PWD/bundle-artifacts/build-extra.bundle\" origin/main..main
121-
"@
89+
sh -x /usr/src/build-extra/please.sh mention feature "Snapshot of $(git show -s --pretty='tformat:%h (%s, %ad)' --date=short FETCH_HEAD)" &&
90+
git -C /usr/src/build-extra bundle create "$PWD/bundle-artifacts/build-extra.bundle" origin/main..main
12291
- name: Clean up temporary files
12392
if: always()
12493
shell: bash
@@ -166,29 +135,10 @@ jobs:
166135
git config --global user.name "$USER_NAME" &&
167136
git config --global user.email "$USER_EMAIL" &&
168137
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >>$GITHUB_ENV
169-
- name: Cache git-sdk-64-build-installers
138+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
170139
if: env.SKIP != 'true'
171-
id: cache-sdk-build-installers
172-
uses: actions/cache@v2
173140
with:
174-
path: git-sdk-64-build-installers
175-
key: build-installers-64-${{ needs.bundle-artifacts.outputs.latest-sdk64-extra-build-id }}
176-
- name: Download git-sdk-64-build-installers
177-
if: env.SKIP != 'true' && steps.cache-sdk-build-installers.outputs.cache-hit != 'true'
178-
shell: bash
179-
run: |
180-
# Use Git Bash to download and unpack the artifact
181-
182-
## Get artifact
183-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
184-
id=${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
185-
download_url=$(curl "$urlbase/$id/artifacts" |
186-
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')
187-
188-
curl -o artifacts.zip "$download_url"
189-
190-
## Unpack artifact
191-
unzip artifacts.zip
141+
flavor: build-installers
192142
- name: Download bundle-artifacts
193143
if: env.SKIP != 'true'
194144
uses: actions/download-artifact@v1
@@ -199,7 +149,7 @@ jobs:
199149
if: env.SKIP != 'true'
200150
shell: bash
201151
run: |
202-
d=git-sdk-64-build-installers/usr/src/build-extra &&
152+
d=/usr/src/build-extra &&
203153
if test ! -d $d/.git
204154
then
205155
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
@@ -242,32 +192,33 @@ jobs:
242192
if: env.SKIP != 'true'
243193
env:
244194
GPGKEY: "${{secrets.GPGKEY}}"
245-
shell: powershell
195+
shell: bash
246196
run: |
247-
& git-sdk-64-build-installers\usr\bin\sh.exe -lc @"
248-
set -x
197+
set -x
249198
250-
# Restrict `PATH` to MSYS2 and to Visual Studio (to let `cv2pdb` find the relevant DLLs)
251-
PATH=\"`/mingw64/bin:/usr/bin:/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin${{matrix.arch.bin}}:/C/Windows/system32\"
199+
# Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
200+
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"\n' >/usr/bin/git &&
252201
253-
type -p mspdb140.dll || exit 1
254-
sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.bitness}}-bit --build-src-pkg -o artifacts HEAD &&
255-
cp bundle-artifacts/ver artifacts/ &&
256-
if test -n \"`$GPGKEY\"
257-
then
258-
for tar in artifacts/*.tar*
259-
do
260-
/usr/src/build-extra/gnupg-with-gpgkey.sh --detach-sign --no-armor `$tar
261-
done
262-
fi &&
202+
# Restrict `PATH` to MSYS2 and to Visual Studio (to let `cv2pdb` find the relevant DLLs)
203+
PATH="/mingw64/bin:/usr/bin:/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin${{matrix.arch.bin}}:/C/Windows/system32"
263204
264-
b=`$PWD/artifacts &&
265-
version=`$(cat bundle-artifacts/next_version) &&
266-
(cd /usr/src/MINGW-packages/mingw-w64-git &&
267-
cp PKGBUILD.`$version PKGBUILD &&
268-
git commit -s -m \"mingw-w64-git: new version (`$version)\" PKGBUILD &&
269-
git bundle create \"`$b\"/MINGW-packages.bundle origin/main..main)
270-
"@
205+
type -p mspdb140.dll || exit 1
206+
sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.bitness}}-bit --build-src-pkg -o artifacts HEAD &&
207+
cp bundle-artifacts/ver artifacts/ &&
208+
if test -n "$GPGKEY"
209+
then
210+
for tar in artifacts/*.tar*
211+
do
212+
/usr/src/build-extra/gnupg-with-gpgkey.sh --detach-sign --no-armor $tar
213+
done
214+
fi &&
215+
216+
b=$PWD/artifacts &&
217+
version=$(cat bundle-artifacts/next_version) &&
218+
(cd /usr/src/MINGW-packages/mingw-w64-git &&
219+
cp PKGBUILD.$version PKGBUILD &&
220+
git commit -s -m "mingw-w64-git: new version ($version)" PKGBUILD &&
221+
git bundle create "$b"/MINGW-packages.bundle origin/main..main)
271222
- name: Clean up temporary files
272223
if: always() && env.SKIP != 'true'
273224
shell: bash
@@ -417,63 +368,15 @@ jobs:
417368
with:
418369
name: bundle-artifacts
419370
path: bundle-artifacts
420-
- name: Cache git-sdk-64-build-installers
371+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
421372
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
422-
id: cache-sdk64-build-installers
423-
uses: actions/cache@v2
424373
with:
425-
path: git-sdk-64-build-installers
426-
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
427-
- name: Download git-sdk-64-build-installers
428-
if: env.SKIP != 'true' && matrix.arch.bitness == '64' && steps.cache-sdk64-build-installers.outputs.cache-hit != 'true'
429-
shell: bash
430-
run: |
431-
# Use Git Bash to download and unpack the artifact
432-
433-
## Get artifact
434-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
435-
id=${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
436-
download_url="$(curl "$urlbase/$id/artifacts" |
437-
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')"
438-
439-
curl -o artifacts.zip "$download_url"
440-
441-
## Unpack artifact
442-
unzip artifacts.zip
443-
- name: Determine latest git-sdk-32-extra-artifacts build ID
374+
flavor: build-installers
375+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
444376
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
445-
id: determine-latest-sdk32-extra-build-id
446-
shell: bash
447-
run: |
448-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
449-
id=$(curl "$urlbase?definitions=30&statusFilter=completed&resultFilter=succeeded&\$top=1" |
450-
jq -r '.value[0].id')
451-
452-
echo "Latest ID is ${id}"
453-
echo "::set-output name=id::$id"
454-
- name: Cache git-sdk-32-build-installers
455-
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
456-
id: cache-sdk32-build-installers
457-
uses: actions/cache@v2
458377
with:
459-
path: git-sdk-32-build-installers
460-
key: build-installers-32-${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
461-
- name: Download git-sdk-32-build-installers
462-
if: env.SKIP != 'true' && matrix.arch.bitness == '32' && steps.cache-sdk32-build-installers.outputs.cache-hit != 'true'
463-
shell: bash
464-
run: |
465-
# Use Git Bash to download and unpack the artifact
466-
467-
## Get artifact
468-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
469-
id=${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
470-
download_url=$(curl "$urlbase/$id/artifacts" |
471-
jq -r '.value[] | select(.name == "git-sdk-32-build-installers").resource.downloadUrl')
472-
473-
curl -o artifacts.zip "$download_url"
474-
475-
## Unpack artifact
476-
unzip artifacts.zip
378+
flavor: build-installers
379+
architecture: i686
477380
- name: Download arm64 artifact
478381
if: env.SKIP != 'true' && matrix.arch.arm64 == true
479382
uses: actions/download-artifact@v1
@@ -484,7 +387,7 @@ jobs:
484387
if: env.SKIP != 'true'
485388
shell: bash
486389
run: |
487-
d=git-sdk-${{matrix.arch.bitness}}-build-installers/usr/src/build-extra &&
390+
d=/usr/src/build-extra &&
488391
if test ! -d $d/.git
489392
then
490393
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
@@ -506,38 +409,34 @@ jobs:
506409
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
507410
- name: Build ${{matrix.arch.bitness}}-bit ${{matrix.artifact.name}}
508411
if: env.SKIP != 'true'
509-
shell: powershell
412+
shell: bash
510413
run: |
511-
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
512-
set -x
513-
if test "${{matrix.arch.arm64}}" = true
514-
then
515-
ARM64="--include-arm64-artifacts=\"$PWD/arm64\""
516-
else
517-
ARM64=
518-
fi
414+
set -x
415+
if test "${{matrix.arch.arm64}}" = true
416+
then
417+
ARM64="--include-arm64-artifacts=\"$PWD/arm64\""
418+
else
419+
ARM64=
420+
fi
519421
520-
eval /usr/src/build-extra/please.sh make_installers_from_mingw_w64_git `$ARM64 --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 &&
521-
if test portable = '${{matrix.artifact.name}}' && test -n \"`$(git config alias.signtool)\"
522-
then
523-
git signtool artifacts/PortableGit-*.exe
524-
fi &&
525-
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed \"s/.* //\" >artifacts/sha-256.txt
526-
"@
422+
eval /usr/src/build-extra/please.sh make_installers_from_mingw_w64_git $ARM64 --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 &&
423+
if test portable = '${{matrix.artifact.name}}' && test -n "$(git config alias.signtool)"
424+
then
425+
git signtool artifacts/PortableGit-*.exe
426+
fi &&
427+
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed "s/.* //" >artifacts/sha-256.txt
527428
- name: Copy package-versions and pdbs
528429
if: env.SKIP != 'true' && matrix.artifact.name == 'installer'
529-
shell: powershell
430+
shell: bash
530431
run: |
531-
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
532-
cp /usr/src/build-extra/installer/package-versions.txt artifacts/ &&
432+
cp /usr/src/build-extra/installer/package-versions.txt artifacts/ &&
533433
534-
a=`$PWD/artifacts &&
535-
p=`$PWD/pkg-${{matrix.arch.name}} &&
536-
(cd /usr/src/build-extra &&
537-
mkdir -p cached-source-packages &&
538-
cp \"`$p\"/*-pdb* cached-source-packages/ &&
539-
GIT_CONFIG_PARAMETERS=\"'windows.sdk${{matrix.arch.bitness}}.path='\" ./please.sh bundle_pdbs --arch=${{matrix.arch.name}} --directory=\"`$a\" installer/package-versions.txt)
540-
"@
434+
a=$PWD/artifacts &&
435+
p=$PWD/pkg-${{matrix.arch.name}} &&
436+
(cd /usr/src/build-extra &&
437+
mkdir -p cached-source-packages &&
438+
cp "$p"/*-pdb* cached-source-packages/ &&
439+
GIT_CONFIG_PARAMETERS="'windows.sdk${{matrix.arch.bitness}}.path='" ./please.sh bundle_pdbs --arch=${{matrix.arch.name}} --directory="$a" installer/package-versions.txt)
541440
- name: Clean up temporary files
542441
if: always() && env.SKIP != 'true'
543442
shell: bash
@@ -578,34 +477,15 @@ jobs:
578477
with:
579478
name: bundle-artifacts
580479
path: bundle-artifacts
581-
- name: Cache git-sdk-64-build-installers
480+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
582481
if: env.SKIP != 'true'
583-
id: cache-sdk-build-installers
584-
uses: actions/cache@v2
585482
with:
586-
path: git-sdk-64-build-installers
587-
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
588-
- name: Download git-sdk-64-build-installers
589-
if: env.SKIP != 'true' && steps.cache-sdk-build-installers.outputs.cache-hit != 'true'
590-
shell: bash
591-
run: |
592-
# Use Git Bash to download and unpack the artifact
593-
594-
## Get artifact
595-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
596-
id=${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
597-
download_url=$(curl "$urlbase/$id/artifacts" |
598-
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')
599-
600-
curl -o artifacts.zip "$download_url"
601-
602-
## Unpack artifact
603-
unzip artifacts.zip
483+
flavor: build-installers
604484
- name: Clone and update build-extra
605485
if: env.SKIP != 'true'
606486
shell: bash
607487
run: |
608-
d=git-sdk-64-build-installers/usr/src/build-extra &&
488+
d=/usr/src/build-extra &&
609489
if test ! -d $d/.git
610490
then
611491
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
@@ -618,13 +498,11 @@ jobs:
618498
if: env.SKIP != 'true'
619499
- name: Build 64-bit NuGet packages
620500
if: env.SKIP != 'true'
621-
shell: powershell
501+
shell: bash
622502
run: |
623-
& .\git-sdk-64-build-installers\usr\bin\bash.exe -lc @"
624-
/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 &&
625-
/usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=`$(cat pkg-x86_64/ver) -o artifacts --nuget-mingit &&
626-
openssl dgst -sha256 artifacts/Git*.nupkg | sed \"s/.* //\" >artifacts/sha-256.txt
627-
"@
503+
/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 &&
504+
/usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=$(cat pkg-x86_64/ver) -o artifacts --nuget-mingit &&
505+
openssl dgst -sha256 artifacts/Git*.nupkg | sed "s/.* //" >artifacts/sha-256.txt
628506
- name: Publish nuget-x86_64
629507
if: env.SKIP != 'true'
630508
uses: actions/upload-artifact@v1

0 commit comments

Comments
 (0)