Skip to content

Commit 27ab1e6

Browse files
committed
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 ac103b8 commit 27ab1e6

File tree

1 file changed

+81
-203
lines changed

1 file changed

+81
-203
lines changed

.github/workflows/git-artifacts.yml

+81-203
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
@@ -421,63 +372,15 @@ jobs:
421372
with:
422373
name: bundle-artifacts
423374
path: bundle-artifacts
424-
- name: Cache git-sdk-64-build-installers
375+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
425376
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
426-
id: cache-sdk64-build-installers
427-
uses: actions/cache@v2
428377
with:
429-
path: git-sdk-64-build-installers
430-
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
431-
- name: Download git-sdk-64-build-installers
432-
if: env.SKIP != 'true' && matrix.arch.bitness == '64' && steps.cache-sdk64-build-installers.outputs.cache-hit != 'true'
433-
shell: bash
434-
run: |
435-
# Use Git Bash to download and unpack the artifact
436-
437-
## Get artifact
438-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
439-
id=${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
440-
download_url="$(curl "$urlbase/$id/artifacts" |
441-
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')"
442-
443-
curl -o artifacts.zip "$download_url"
444-
445-
## Unpack artifact
446-
unzip artifacts.zip
447-
- name: Determine latest git-sdk-32-extra-artifacts build ID
378+
flavor: build-installers
379+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
448380
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
449-
id: determine-latest-sdk32-extra-build-id
450-
shell: bash
451-
run: |
452-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
453-
id=$(curl "$urlbase?definitions=30&statusFilter=completed&resultFilter=succeeded&\$top=1" |
454-
jq -r '.value[0].id')
455-
456-
echo "Latest ID is ${id}"
457-
echo "::set-output name=id::$id"
458-
- name: Cache git-sdk-32-build-installers
459-
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
460-
id: cache-sdk32-build-installers
461-
uses: actions/cache@v2
462381
with:
463-
path: git-sdk-32-build-installers
464-
key: build-installers-32-${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
465-
- name: Download git-sdk-32-build-installers
466-
if: env.SKIP != 'true' && matrix.arch.bitness == '32' && steps.cache-sdk32-build-installers.outputs.cache-hit != 'true'
467-
shell: bash
468-
run: |
469-
# Use Git Bash to download and unpack the artifact
470-
471-
## Get artifact
472-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
473-
id=${{ steps.determine-latest-sdk32-extra-build-id.outputs.id }}
474-
download_url=$(curl "$urlbase/$id/artifacts" |
475-
jq -r '.value[] | select(.name == "git-sdk-32-build-installers").resource.downloadUrl')
476-
477-
curl -o artifacts.zip "$download_url"
478-
479-
## Unpack artifact
480-
unzip artifacts.zip
382+
flavor: build-installers
383+
architecture: i686
481384
- name: Download arm64 artifact
482385
if: env.SKIP != 'true' && matrix.arch.arm64 == true
483386
uses: actions/download-artifact@v1
@@ -488,7 +391,7 @@ jobs:
488391
if: env.SKIP != 'true'
489392
shell: bash
490393
run: |
491-
d=git-sdk-${{matrix.arch.bitness}}-build-installers/usr/src/build-extra &&
394+
d=/usr/src/build-extra &&
492395
if test ! -d $d/.git
493396
then
494397
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
@@ -510,38 +413,34 @@ jobs:
510413
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
511414
- name: Build ${{matrix.arch.bitness}}-bit ${{matrix.artifact.name}}
512415
if: env.SKIP != 'true'
513-
shell: powershell
416+
shell: bash
514417
run: |
515-
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
516-
set -x
517-
if test "${{matrix.arch.arm64}}" = true
518-
then
519-
ARM64="--include-arm64-artifacts=\"$PWD/arm64\""
520-
else
521-
ARM64=
522-
fi
418+
set -x
419+
if test "${{matrix.arch.arm64}}" = true
420+
then
421+
ARM64="--include-arm64-artifacts=\"$PWD/arm64\""
422+
else
423+
ARM64=
424+
fi
523425
524-
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 &&
525-
if test portable = '${{matrix.artifact.name}}' && test -n \"`$(git config alias.signtool)\"
526-
then
527-
git signtool artifacts/PortableGit-*.exe
528-
fi &&
529-
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed \"s/.* //\" >artifacts/sha-256.txt
530-
"@
426+
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 &&
427+
if test portable = '${{matrix.artifact.name}}' && test -n "$(git config alias.signtool)"
428+
then
429+
git signtool artifacts/PortableGit-*.exe
430+
fi &&
431+
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed "s/.* //" >artifacts/sha-256.txt
531432
- name: Copy package-versions and pdbs
532433
if: env.SKIP != 'true' && matrix.artifact.name == 'installer'
533-
shell: powershell
434+
shell: bash
534435
run: |
535-
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
536-
cp /usr/src/build-extra/installer/package-versions.txt artifacts/ &&
436+
cp /usr/src/build-extra/installer/package-versions.txt artifacts/ &&
537437
538-
a=`$PWD/artifacts &&
539-
p=`$PWD/pkg-${{matrix.arch.name}} &&
540-
(cd /usr/src/build-extra &&
541-
mkdir -p cached-source-packages &&
542-
cp \"`$p\"/*-pdb* cached-source-packages/ &&
543-
GIT_CONFIG_PARAMETERS=\"'windows.sdk${{matrix.arch.bitness}}.path='\" ./please.sh bundle_pdbs --arch=${{matrix.arch.name}} --directory=\"`$a\" installer/package-versions.txt)
544-
"@
438+
a=$PWD/artifacts &&
439+
p=$PWD/pkg-${{matrix.arch.name}} &&
440+
(cd /usr/src/build-extra &&
441+
mkdir -p cached-source-packages &&
442+
cp "$p"/*-pdb* cached-source-packages/ &&
443+
GIT_CONFIG_PARAMETERS="'windows.sdk${{matrix.arch.bitness}}.path='" ./please.sh bundle_pdbs --arch=${{matrix.arch.name}} --directory="$a" installer/package-versions.txt)
545444
- name: Clean up temporary files
546445
if: always() && env.SKIP != 'true'
547446
shell: bash
@@ -582,34 +481,15 @@ jobs:
582481
with:
583482
name: bundle-artifacts
584483
path: bundle-artifacts
585-
- name: Cache git-sdk-64-build-installers
484+
- uses: git-for-windows/setup-git-for-windows-sdk@v0
586485
if: env.SKIP != 'true'
587-
id: cache-sdk-build-installers
588-
uses: actions/cache@v2
589486
with:
590-
path: git-sdk-64-build-installers
591-
key: build-installers-64-${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
592-
- name: Download git-sdk-64-build-installers
593-
if: env.SKIP != 'true' && steps.cache-sdk-build-installers.outputs.cache-hit != 'true'
594-
shell: bash
595-
run: |
596-
# Use Git Bash to download and unpack the artifact
597-
598-
## Get artifact
599-
urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
600-
id=${{ needs.pkg.outputs.latest-sdk64-extra-build-id }}
601-
download_url=$(curl "$urlbase/$id/artifacts" |
602-
jq -r '.value[] | select(.name == "git-sdk-64-build-installers").resource.downloadUrl')
603-
604-
curl -o artifacts.zip "$download_url"
605-
606-
## Unpack artifact
607-
unzip artifacts.zip
487+
flavor: build-installers
608488
- name: Clone and update build-extra
609489
if: env.SKIP != 'true'
610490
shell: bash
611491
run: |
612-
d=git-sdk-64-build-installers/usr/src/build-extra &&
492+
d=/usr/src/build-extra &&
613493
if test ! -d $d/.git
614494
then
615495
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
@@ -622,13 +502,11 @@ jobs:
622502
if: env.SKIP != 'true'
623503
- name: Build 64-bit NuGet packages
624504
if: env.SKIP != 'true'
625-
shell: powershell
505+
shell: bash
626506
run: |
627-
& .\git-sdk-64-build-installers\usr\bin\bash.exe -lc @"
628-
/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 &&
629-
/usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=`$(cat pkg-x86_64/ver) -o artifacts --nuget-mingit &&
630-
openssl dgst -sha256 artifacts/Git*.nupkg | sed \"s/.* //\" >artifacts/sha-256.txt
631-
"@
507+
/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 &&
508+
/usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=$(cat pkg-x86_64/ver) -o artifacts --nuget-mingit &&
509+
openssl dgst -sha256 artifacts/Git*.nupkg | sed "s/.* //" >artifacts/sha-256.txt
632510
- name: Publish nuget-x86_64
633511
if: env.SKIP != 'true'
634512
uses: actions/upload-artifact@v1

0 commit comments

Comments
 (0)