Skip to content

Commit d19c976

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 d19c976

File tree

1 file changed

+118
-133
lines changed

1 file changed

+118
-133
lines changed

.github/workflows/git-artifacts.yml

Lines changed: 118 additions & 133 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,37 @@ 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
112+
runner: windows-latest
107113
- name: i686
108-
bitness: 32
114+
pacman_arch: i686
109115
bin: ''
116+
runner: windows-latest
117+
- name: aarch64
118+
pacman_arch: clang-aarch64
119+
bin: ''
120+
runner: [Windows, ARM64]
110121
steps:
111122
- name: Determine whether this job should be skipped
112123
shell: bash
113124
run: |
125+
if test "${{matrix.arch.name}}" = "aarch64" && test "$BUILD_ARM64" != "true"
126+
then
127+
echo "SKIP=true" >>$GITHUB_ENV
128+
exit 0
129+
fi
114130
for e in ${BUILD_ONLY:-pkg}
115131
do
116132
case $e in
117133
*-${{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
119134
*-*) ;; # not this build artifact, keep looking
120135
*) exit 0;; # build this artifact
121136
esac
@@ -135,6 +150,9 @@ jobs:
135150
if: env.SKIP != 'true'
136151
with:
137152
flavor: build-installers
153+
architecture: ${{ (matrix.arch.name == 'aarch64' && 'aarch64') || 'x86_64' }}
154+
# We only have to clean up on self-hosted runners
155+
cleanup: ${{ (matrix.arch.runner != 'windows-latest' && true) || false }}
138156
- name: Download bundle-artifacts
139157
if: env.SKIP != 'true'
140158
uses: actions/download-artifact@v1
@@ -184,7 +202,29 @@ jobs:
184202
git config --global user.email "<${info#*<}"
185203
env:
186204
GPGKEY: ${{secrets.GPGKEY}}
187-
- name: Build mingw-w64-${{matrix.arch.name}}-git
205+
# Until there is a Git SDK for arm64, we'll need to install a few packages manually
206+
# We install prebuilt binaries to save lots of CI time
207+
- name: Install aarch64 deps
208+
if: env.SKIP != 'true' && matrix.arch.name == 'aarch64'
209+
shell: bash
210+
run: |
211+
set -x
212+
213+
package_dir="tmp-aarch64-deps"
214+
release_url="https://github.com/dennisameling/git/releases/download/v2.39.0.windows.99"
215+
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"
216+
217+
mkdir -p $package_dir && cd $package_dir
218+
219+
for package in $packages
220+
do
221+
curl -LOf $release_url/$package || exit 1
222+
done
223+
224+
pacman -U --noconfirm $packages
225+
226+
cd ../
227+
- name: Build mingw-w64-${{matrix.arch.pacman_arch}}-git
188228
if: env.SKIP != 'true'
189229
env:
190230
GPGKEY: "${{secrets.GPGKEY}}"
@@ -195,11 +235,21 @@ jobs:
195235
# Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
196236
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"\n' >/usr/bin/git &&
197237
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"
238+
# We don't use `cv2pdb` on aarch64, which we build using Clang instead of GCC
239+
if test "${{matrix.arch.name}}" != "aarch64"
240+
then
241+
# Restrict `PATH` to MSYS2 and to Visual Studio (to let `cv2pdb` find the relevant DLLs)
242+
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"
243+
type -p mspdb140.dll || exit 1
244+
else
245+
# We don't want to build dashed built-ins anymore. Let's do this on aarch64 only to begin with
246+
export SKIP_DASHED_BUILT_INS=YesPlease
247+
fi &&
248+
249+
# Temp until https://github.com/git-for-windows/build-extra/pull/452 is merged
250+
/mingw64/bin/curl.exe https://raw.githubusercontent.com/git-for-windows/build-extra/3d6fc6dfe74902644c042500ad80e17abd134bfc/please.sh -o /usr/src/build-extra/please.sh &&
200251
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 &&
252+
sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.name}} --build-src-pkg -o artifacts HEAD &&
203253
cp bundle-artifacts/ver artifacts/ &&
204254
if test -n "$GPGKEY"
205255
then
@@ -219,94 +269,16 @@ jobs:
219269
if: always() && env.SKIP != 'true'
220270
shell: bash
221271
run: rm -rf home
222-
- name: Publish mingw-w64-${{matrix.arch.name}}-git
272+
- name: Publish mingw-w64-${{matrix.arch.pacman_arch}}-git
223273
if: env.SKIP != 'true'
224274
uses: actions/upload-artifact@v1
225275
with:
226276
name: pkg-${{matrix.arch.name}}
227277
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
307278
artifacts:
308-
runs-on: windows-latest
309-
needs: [pkg, build-arm64]
279+
# Hack to ensure that the "determine skip" step works if no self-hosted ARM64 runner is available
280+
runs-on: ${{ ((matrix.arch.name == 'aarch64' && github.event.inputs.build_arm64 == 'true') && fromJSON('["Windows", "ARM64"]')) || 'windows-latest' }}
281+
needs: pkg
310282
strategy:
311283
matrix:
312284
artifact:
@@ -327,29 +299,35 @@ jobs:
327299
fileextension: zip
328300
arch:
329301
- name: x86_64
302+
pacman_arch: x86_64
330303
bitness: 64
331-
arm64: false
332-
- name: i686
333-
bitness: 32
334-
arm64: false
304+
msystem: MINGW64
305+
runner: windows-latest
335306
- name: i686
307+
pacman_arch: i686
336308
bitness: 32
337-
arm64: true
309+
msystem: MINGW32
310+
runner: windows-latest
311+
- name: aarch64
312+
pacman_arch: clang-aarch64
313+
bitness: 64
314+
msystem: CLANGARM64
315+
runner: [Windows, ARM64]
338316
fail-fast: false
339317
env:
340-
MSYSTEM: MINGW${{matrix.arch.bitness}}
318+
MSYSTEM: ${{matrix.arch.msystem}}
341319
steps:
342320
- name: Determine whether this job should be skipped
343321
shell: bash
344322
run: |
345-
suffix=${{matrix.arch.name}}
346-
if test true = ${{matrix.arch.arm64}}
323+
if test "${{matrix.arch.name}}" = "aarch64" && test "$BUILD_ARM64" != "true"
347324
then
348-
suffix=arm64
325+
echo "SKIP=true" >>$GITHUB_ENV
326+
exit 0
349327
fi
350328
case " $BUILD_ONLY " in
351329
' ') ;; # not set; build all
352-
*" ${{matrix.artifact.name}} "*|*" ${{matrix.artifact.name}}-$suffix "*) ;; # build this artifact
330+
*" ${{matrix.artifact.name}} "*|*" ${{matrix.artifact.name}}-${{matrix.arch.name}}"*) ;; # build this artifact
353331
*) echo "SKIP=true" >>$GITHUB_ENV;;
354332
esac
355333
- name: Download pkg-${{matrix.arch.name}}
@@ -365,27 +343,43 @@ jobs:
365343
name: bundle-artifacts
366344
path: bundle-artifacts
367345
- 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'
346+
if: env.SKIP != 'true'
373347
with:
374348
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
349+
architecture: ${{matrix.arch.name}}
350+
# We only have to clean up on self-hosted runners
351+
cleanup: ${{ (matrix.arch.runner != 'windows-latest' && true) || false }}
352+
# Until there is a Git SDK for arm64, we'll need to install a few packages manually
353+
# We install prebuilt binaries to save lots of CI time
354+
- name: Install aarch64 deps
355+
if: env.SKIP != 'true' && matrix.arch.name == 'aarch64'
385356
shell: bash
386357
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
358+
set -x
359+
360+
package_dir="tmp-aarch64-deps"
361+
release_url="https://github.com/dennisameling/git/releases/download/v2.39.0.windows.99"
362+
packages="mingw-w64-clang-aarch64-openssl-1.1.1.s-1-any.pkg.tar.zst
363+
mingw-w64-clang-aarch64-curl-7.86.0-1-any.pkg.tar.zst
364+
mingw-w64-clang-aarch64-wintoast-1.0.0.181.9b0663d-1-any.pkg.tar.zst
365+
mingw-w64-clang-aarch64-xpdf-tools-4.00-1-any.pkg.tar.zst
366+
mingw-w64-clang-aarch64-git-credential-manager-2.0.886-1-any.pkg.tar.zst
367+
mingw-w64-clang-aarch64-git-lfs-3.3.0-1-any.pkg.tar.zst
368+
git-extra-1.1.614.d551cf0cc-1-aarch64.pkg.tar.zst"
369+
370+
mkdir -p $package_dir && cd $package_dir
371+
372+
for package in $packages
373+
do
374+
curl -LOf $release_url/$package || exit 1
375+
done
376+
377+
pacman -U --noconfirm $packages
378+
379+
# Some additional packages we need for most artifacts
380+
pacman -S --noconfirm mingw-w64-clang-aarch64-connect mingw-w64-clang-aarch64-antiword mingw-w64-clang-aarch64-odt2txt
381+
382+
cd ../
389383
- name: Clone and update build-extra
390384
if: env.SKIP != 'true'
391385
shell: bash
@@ -410,19 +404,16 @@ jobs:
410404
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
411405
echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass &&
412406
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
413-
- name: Build ${{matrix.arch.bitness}}-bit ${{matrix.artifact.name}}
407+
- name: Build ${{matrix.arch.name}} ${{matrix.artifact.name}}
414408
if: env.SKIP != 'true'
415409
shell: bash
416410
run: |
417411
set -x
418-
if test "${{matrix.arch.arm64}}" = true
419-
then
420-
ARM64="--include-arm64-artifacts=\"$PWD/arm64\""
421-
else
422-
ARM64=
423-
fi
424412
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 &&
413+
# Temp until https://github.com/git-for-windows/build-extra/pull/452 is merged
414+
/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 &&
415+
416+
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 &&
426417
if test portable = '${{matrix.artifact.name}}' && test -n "$(git config alias.signtool)"
427418
then
428419
git signtool artifacts/PortableGit-*.exe
@@ -445,17 +436,11 @@ jobs:
445436
shell: bash
446437
run: rm -rf home
447438
- name: Publish ${{matrix.artifact.name}}-${{matrix.arch.name}}
448-
if: env.SKIP != 'true' && matrix.arch.arm64 != true
439+
if: env.SKIP != 'true'
449440
uses: actions/upload-artifact@v1
450441
with:
451442
name: ${{matrix.artifact.name}}-${{matrix.arch.name}}
452443
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
459444
nuget:
460445
runs-on: windows-latest
461446
needs: pkg

0 commit comments

Comments
 (0)