Skip to content

Commit abcdc80

Browse files
committed
git-artifacts (CI): add support for CLANGARM64
This replaces earlier efforts to generate ARM64 artifacts by adding support for the new CLANGARM64 MSYSTEM. As GitHub Actions doesn't support ARM64 yet for Hosted Runners, building ARM64 artifacts is optional for now as it requires a Self-hosted Runner. Signed-off-by: Dennis Ameling <[email protected]>
1 parent 450817f commit abcdc80

File tree

1 file changed

+113
-134
lines changed

1 file changed

+113
-134
lines changed

.github/workflows/git-artifacts.yml

Lines changed: 113 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
repository:
1515
description: 'Optionally override from where to fetch the specified ref'
1616
required: false
17+
build_arm64:
18+
description: 'Optionally build ARM64 artifacts (requires a self-hosted ARM64 runner to be active in this repo)'
19+
required: false
1720

1821
env:
1922
GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
@@ -22,6 +25,7 @@ env:
2225
USERPROFILE: "${{github.workspace}}\\home"
2326
BUILD_ONLY: "${{github.event.inputs.build_only}}"
2427
REPOSITORY: "${{github.event.inputs.repository}}"
28+
BUILD_ARM64: "${{github.event.inputs.build_arm64}}"
2529
REF: "${{github.event.inputs.ref}}"
2630

2731
jobs:
@@ -96,26 +100,34 @@ jobs:
96100
name: bundle-artifacts
97101
path: bundle-artifacts
98102
pkg:
99-
runs-on: windows-latest
103+
# Hack to ensure that the "determine skip" step works if no self-hosted ARM64 runner is available
104+
runs-on: ${{ ((matrix.arch.name == 'aarch64' && github.event.inputs.build_arm64 == 'true') && fromJSON('["Windows", "ARM64"]')) || 'windows-latest' }}
100105
needs: bundle-artifacts
101106
strategy:
102107
matrix:
103108
arch:
104109
- name: x86_64
105-
bitness: 64
110+
pacman_arch: x86_64
106111
bin: /amd64
107112
- name: i686
108-
bitness: 32
113+
pacman_arch: i686
114+
bin: ''
115+
- name: aarch64
116+
pacman_arch: clang-aarch64
109117
bin: ''
110118
steps:
111119
- name: Determine whether this job should be skipped
112120
shell: bash
113121
run: |
122+
if test "${{matrix.arch.name}}" = "aarch64" && test "$BUILD_ARM64" != "true"
123+
then
124+
echo "SKIP=true" >>$GITHUB_ENV
125+
exit 0
126+
fi
114127
for e in ${BUILD_ONLY:-pkg}
115128
do
116129
case $e in
117130
*-${{matrix.arch.name}}) exit 0;; # build this artifact
118-
*-arm64) test i686 != ${{matrix.arch.name}} || exit 0;; # pkg-i686 is required for the ARM64 version
119131
*-*) ;; # not this build artifact, keep looking
120132
*) exit 0;; # build this artifact
121133
esac
@@ -135,6 +147,9 @@ jobs:
135147
if: env.SKIP != 'true'
136148
with:
137149
flavor: build-installers
150+
architecture: ${{ (matrix.arch.name == 'aarch64' && 'aarch64') || 'x86_64' }}
151+
# We only have to clean up on self-hosted runners
152+
cleanup: ${{ (runner.arch == 'ARM64' && true) || false }}
138153
- name: Download bundle-artifacts
139154
if: env.SKIP != 'true'
140155
uses: actions/download-artifact@v1
@@ -184,7 +199,29 @@ jobs:
184199
git config --global user.email "<${info#*<}"
185200
env:
186201
GPGKEY: ${{secrets.GPGKEY}}
187-
- name: Build mingw-w64-${{matrix.arch.name}}-git
202+
# Until there is a Git SDK for arm64, we'll need to install a few packages manually
203+
# We install prebuilt binaries to save lots of CI time
204+
- name: Install aarch64 deps
205+
if: env.SKIP != 'true' && matrix.arch.name == 'aarch64'
206+
shell: bash
207+
run: |
208+
set -x
209+
210+
package_dir="tmp-aarch64-deps"
211+
release_url="https://github.com/dennisameling/git/releases/download/v2.39.0.windows.99"
212+
packages="mingw-w64-clang-aarch64-openssl-1.1.1.s-1-any.pkg.tar.zst mingw-w64-clang-aarch64-curl-7.86.0-1-any.pkg.tar.zst"
213+
214+
mkdir -p $package_dir && cd $package_dir
215+
216+
for package in $packages
217+
do
218+
curl -LOf $release_url/$package || exit 1
219+
done
220+
221+
pacman -U --noconfirm $packages
222+
223+
cd ../
224+
- name: Build mingw-w64-${{matrix.arch.pacman_arch}}-git
188225
if: env.SKIP != 'true'
189226
env:
190227
GPGKEY: "${{secrets.GPGKEY}}"
@@ -195,11 +232,21 @@ jobs:
195232
# Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
196233
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"\n' >/usr/bin/git &&
197234
198-
# Restrict `PATH` to MSYS2 and to Visual Studio (to let `cv2pdb` find the relevant DLLs)
199-
PATH="/mingw64/bin:/usr/bin:/c/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/:/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin${{matrix.arch.bin}}:/C/Windows/system32"
235+
# We don't use `cv2pdb` on aarch64, which we build using Clang instead of GCC
236+
if test "${{matrix.arch.name}}" != "aarch64"
237+
then
238+
# Restrict `PATH` to MSYS2 and to Visual Studio (to let `cv2pdb` find the relevant DLLs)
239+
PATH="/mingw64/bin:/usr/bin:/c/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/:/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin${{matrix.arch.bin}}:/C/Windows/system32"
240+
type -p mspdb140.dll || exit 1
241+
else
242+
# We don't want to build dashed built-ins anymore. Let's do this on aarch64 only to begin with
243+
export SKIP_DASHED_BUILT_INS=YesPlease
244+
fi &&
245+
246+
# Temp until https://github.com/git-for-windows/build-extra/pull/452 is merged
247+
/mingw64/bin/curl.exe https://raw.githubusercontent.com/git-for-windows/build-extra/3d6fc6dfe74902644c042500ad80e17abd134bfc/please.sh -o /usr/src/build-extra/please.sh &&
200248
201-
type -p mspdb140.dll || exit 1
202-
sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.bitness}}-bit --build-src-pkg -o artifacts HEAD &&
249+
sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.name}} --build-src-pkg -o artifacts HEAD &&
203250
cp bundle-artifacts/ver artifacts/ &&
204251
if test -n "$GPGKEY"
205252
then
@@ -219,94 +266,16 @@ jobs:
219266
if: always() && env.SKIP != 'true'
220267
shell: bash
221268
run: rm -rf home
222-
- name: Publish mingw-w64-${{matrix.arch.name}}-git
269+
- name: Publish mingw-w64-${{matrix.arch.pacman_arch}}-git
223270
if: env.SKIP != 'true'
224271
uses: actions/upload-artifact@v1
225272
with:
226273
name: pkg-${{matrix.arch.name}}
227274
path: artifacts
228-
build-arm64:
229-
needs: bundle-artifacts
230-
runs-on: windows-latest
231-
steps:
232-
- name: Determine whether this job should be skipped
233-
shell: bash
234-
run: |
235-
for e in ${BUILD_ONLY:-pkg}
236-
do
237-
case $e in
238-
*-arm64) exit 0;; # build this artifact
239-
*-*) ;; # not this build artifact, keep looking
240-
*) exit 0;; # build this artifact
241-
esac
242-
done
243-
echo "SKIP=true" >>$GITHUB_ENV
244-
- name: Configure user
245-
if: env.SKIP != 'true'
246-
shell: bash
247-
run:
248-
USER_NAME="${{github.actor}}" &&
249-
USER_EMAIL="${{github.actor}}@users.noreply.github.com" &&
250-
mkdir -p "$HOME" &&
251-
git config --global user.name "$USER_NAME" &&
252-
git config --global user.email "$USER_EMAIL"
253-
- name: Download bundle-artifacts
254-
if: env.SKIP != 'true'
255-
uses: actions/download-artifact@v1
256-
with:
257-
name: bundle-artifacts
258-
path: bundle-artifacts
259-
- name: Check out git/git
260-
if: env.SKIP != 'true'
261-
shell: bash
262-
run: |
263-
git -c init.defaultBranch=main init &&
264-
git remote add -f origin https://github.com/git-for-windows/git &&
265-
git fetch --tags bundle-artifacts/git.bundle $(cat bundle-artifacts/next_version) &&
266-
git reset --hard $(cat bundle-artifacts/next_version)
267-
- name: initialize vcpkg
268-
if: env.SKIP != 'true'
269-
uses: actions/checkout@v2
270-
with:
271-
repository: 'microsoft/vcpkg'
272-
path: 'compat/vcbuild/vcpkg'
273-
- name: download vcpkg artifacts
274-
if: env.SKIP != 'true'
275-
uses: git-for-windows/get-azure-pipelines-artifact@v0
276-
with:
277-
repository: git/git
278-
definitionId: 9
279-
- name: add msbuild to PATH
280-
if: env.SKIP != 'true'
281-
uses: microsoft/setup-msbuild@v1
282-
- name: copy dlls to root
283-
if: env.SKIP != 'true'
284-
shell: powershell
285-
run: |
286-
& compat\vcbuild\vcpkg_copy_dlls.bat release arm64-windows
287-
if (!$?) { exit(1) }
288-
- name: generate Visual Studio solution
289-
if: env.SKIP != 'true'
290-
shell: bash
291-
run: |
292-
cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/arm64-windows \
293-
-DNO_GETTEXT=YesPlease -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON -DCMAKE_GENERATOR_PLATFORM=arm64 -DVCPKG_ARCH=arm64-windows \
294-
-DCMAKE_INSTALL_PREFIX="`pwd`/git-arm64" -DSKIP_DASHED_BUILT_INS=ON -DHOST_CPU=arm64
295-
- name: MSBuild
296-
if: env.SKIP != 'true'
297-
run: msbuild git.sln -property:Configuration=Release
298-
- name: Link the Git executables
299-
if: env.SKIP != 'true'
300-
run: msbuild INSTALL.vcxproj -property:Configuration=Release
301-
- name: upload build artifacts
302-
if: env.SKIP != 'true'
303-
uses: actions/upload-artifact@v1
304-
with:
305-
name: arm64-artifacts
306-
path: ./git-arm64
307275
artifacts:
308-
runs-on: windows-latest
309-
needs: [pkg, build-arm64]
276+
# Hack to ensure that the "determine skip" step works if no self-hosted ARM64 runner is available
277+
runs-on: ${{ ((matrix.arch.name == 'aarch64' && github.event.inputs.build_arm64 == 'true') && fromJSON('["Windows", "ARM64"]')) || 'windows-latest' }}
278+
needs: pkg
310279
strategy:
311280
matrix:
312281
artifact:
@@ -327,29 +296,32 @@ jobs:
327296
fileextension: zip
328297
arch:
329298
- name: x86_64
299+
pacman_arch: x86_64
330300
bitness: 64
331-
arm64: false
332-
- name: i686
333-
bitness: 32
334-
arm64: false
301+
msystem: MINGW64
335302
- name: i686
303+
pacman_arch: i686
336304
bitness: 32
337-
arm64: true
305+
msystem: MINGW32
306+
- name: aarch64
307+
pacman_arch: clang-aarch64
308+
bitness: 64
309+
msystem: CLANGARM64
338310
fail-fast: false
339311
env:
340-
MSYSTEM: MINGW${{matrix.arch.bitness}}
312+
MSYSTEM: ${{matrix.arch.msystem}}
341313
steps:
342314
- name: Determine whether this job should be skipped
343315
shell: bash
344316
run: |
345-
suffix=${{matrix.arch.name}}
346-
if test true = ${{matrix.arch.arm64}}
317+
if test "${{matrix.arch.name}}" = "aarch64" && test "$BUILD_ARM64" != "true"
347318
then
348-
suffix=arm64
319+
echo "SKIP=true" >>$GITHUB_ENV
320+
exit 0
349321
fi
350322
case " $BUILD_ONLY " in
351323
' ') ;; # not set; build all
352-
*" ${{matrix.artifact.name}} "*|*" ${{matrix.artifact.name}}-$suffix "*) ;; # build this artifact
324+
*" ${{matrix.artifact.name}} "*|*" ${{matrix.artifact.name}}-${{matrix.arch.name}}"*) ;; # build this artifact
353325
*) echo "SKIP=true" >>$GITHUB_ENV;;
354326
esac
355327
- name: Download pkg-${{matrix.arch.name}}
@@ -365,27 +337,43 @@ jobs:
365337
name: bundle-artifacts
366338
path: bundle-artifacts
367339
- uses: git-for-windows/setup-git-for-windows-sdk@v1
368-
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
369-
with:
370-
flavor: build-installers
371-
- uses: git-for-windows/setup-git-for-windows-sdk@v1
372-
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
340+
if: env.SKIP != 'true'
373341
with:
374342
flavor: build-installers
375-
architecture: i686
376-
- name: Download arm64 artifact
377-
if: env.SKIP != 'true' && matrix.arch.arm64 == true
378-
uses: actions/download-artifact@v1
379-
with:
380-
name: arm64-artifacts
381-
path: ${{github.workspace}}/arm64
382-
# Workaround for Git Credential Manager Core on ARM64: https://github.com/git-for-windows/git/issues/3015
383-
- name: Create git-credential-manager-core wrapper for ARM64
384-
if: env.SKIP != 'true' && matrix.arch.arm64 == true
343+
architecture: ${{matrix.arch.name}}
344+
# We only have to clean up on self-hosted runners
345+
cleanup: ${{ (runner.arch == 'ARM64' && true) || false }}
346+
# Until there is a Git SDK for arm64, we'll need to install a few packages manually
347+
# We install prebuilt binaries to save lots of CI time
348+
- name: Install aarch64 deps
349+
if: env.SKIP != 'true' && matrix.arch.name == 'aarch64'
385350
shell: bash
386351
run: |
387-
printf '%s\n' '#!/bin/sh' 'exec /mingw32/libexec/git-core/git-credential-manager-core.exe "$@"' > arm64/libexec/git-core/git-credential-manager-core
388-
chmod +x arm64/libexec/git-core/git-credential-manager-core
352+
set -x
353+
354+
package_dir="tmp-aarch64-deps"
355+
release_url="https://github.com/dennisameling/git/releases/download/v2.39.0.windows.99"
356+
packages="mingw-w64-clang-aarch64-openssl-1.1.1.s-1-any.pkg.tar.zst
357+
mingw-w64-clang-aarch64-curl-7.86.0-1-any.pkg.tar.zst
358+
mingw-w64-clang-aarch64-wintoast-1.0.0.181.9b0663d-1-any.pkg.tar.zst
359+
mingw-w64-clang-aarch64-xpdf-tools-4.00-1-any.pkg.tar.zst
360+
mingw-w64-clang-aarch64-git-credential-manager-2.0.886-1-any.pkg.tar.zst
361+
mingw-w64-clang-aarch64-git-lfs-3.3.0-1-any.pkg.tar.zst
362+
git-extra-1.1.616.ced335bb5-1-any.pkg.tar.zst"
363+
364+
mkdir -p $package_dir && cd $package_dir
365+
366+
for package in $packages
367+
do
368+
curl -LOf $release_url/$package || exit 1
369+
done
370+
371+
pacman -U --noconfirm $packages
372+
373+
# Some additional packages we need for most artifacts
374+
pacman -S --noconfirm mingw-w64-clang-aarch64-connect mingw-w64-clang-aarch64-antiword mingw-w64-clang-aarch64-odt2txt
375+
376+
cd ../
389377
- name: Clone and update build-extra
390378
if: env.SKIP != 'true'
391379
shell: bash
@@ -410,26 +398,23 @@ jobs:
410398
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
411399
echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass &&
412400
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
413-
- name: Build ${{matrix.arch.bitness}}-bit ${{matrix.artifact.name}}
401+
- name: Build ${{matrix.arch.name}} ${{matrix.artifact.name}}
414402
if: env.SKIP != 'true'
415403
shell: bash
416404
run: |
417405
set -x
418-
if test "${{matrix.arch.arm64}}" = true
419-
then
420-
ARM64="--include-arm64-artifacts=\"$PWD/arm64\""
421-
else
422-
ARM64=
423-
fi
424406
425-
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 &&
407+
# Temp until https://github.com/git-for-windows/build-extra/pull/452 is merged
408+
/mingw${{matrix.arch.bitness}}/bin/curl.exe https://raw.githubusercontent.com/git-for-windows/build-extra/3d6fc6dfe74902644c042500ad80e17abd134bfc/please.sh -o /usr/src/build-extra/please.sh &&
409+
410+
eval /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.pacman_arch}}-git-[0-9]*.tar.xz --pkg=pkg-${{matrix.arch.name}}/mingw-w64-${{matrix.arch.pacman_arch}}-git-doc-html-[0-9]*.tar.xz &&
426411
if test portable = '${{matrix.artifact.name}}' && test -n "$(git config alias.signtool)"
427412
then
428413
git signtool artifacts/PortableGit-*.exe
429414
fi &&
430415
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed "s/.* //" >artifacts/sha-256.txt
431416
- name: Copy package-versions and pdbs
432-
if: env.SKIP != 'true' && matrix.artifact.name == 'installer'
417+
if: env.SKIP != 'true' && matrix.artifact.name == 'installer' && matrix.arch.name != 'aarch64'
433418
shell: bash
434419
run: |
435420
cp /usr/src/build-extra/installer/package-versions.txt artifacts/ &&
@@ -445,17 +430,11 @@ jobs:
445430
shell: bash
446431
run: rm -rf home
447432
- name: Publish ${{matrix.artifact.name}}-${{matrix.arch.name}}
448-
if: env.SKIP != 'true' && matrix.arch.arm64 != true
433+
if: env.SKIP != 'true'
449434
uses: actions/upload-artifact@v1
450435
with:
451436
name: ${{matrix.artifact.name}}-${{matrix.arch.name}}
452437
path: artifacts
453-
- name: Publish ${{matrix.artifact.name}}-arm64
454-
if: env.SKIP != 'true' && matrix.arch.arm64 == true
455-
uses: actions/upload-artifact@v1
456-
with:
457-
name: ${{matrix.artifact.name}}-arm64
458-
path: artifacts
459438
nuget:
460439
runs-on: windows-latest
461440
needs: pkg

0 commit comments

Comments
 (0)