Skip to content

Commit 31ce754

Browse files
author
Matthew John Cheetham
authored
add support for Linux arm64 and Linux arm (git-ecosystem#1633)
Adds support for building and publishing Linux ARM64 and Linux ARM32
2 parents 749e287 + 628acd0 commit 31ce754

File tree

9 files changed

+104
-32
lines changed

9 files changed

+104
-32
lines changed

.github/workflows/continuous-integration.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ jobs:
5454
linux:
5555
name: Linux
5656
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
runtime: [ linux-x64, linux-arm64, linux-arm ]
5760

5861
steps:
5962
- uses: actions/checkout@v4
@@ -67,7 +70,10 @@ jobs:
6770
run: dotnet restore
6871

6972
- name: Build
70-
run: dotnet build --configuration LinuxRelease
73+
run: |
74+
dotnet build src/linux/Packaging.Linux/*.csproj \
75+
--configuration=Release --no-self-contained \
76+
--runtime=${{ matrix.runtime }}
7177
7278
- name: Test
7379
run: |
@@ -82,7 +88,7 @@ jobs:
8288
- name: Upload artifacts
8389
uses: actions/upload-artifact@v4
8490
with:
85-
name: linux-x64
91+
name: ${{ matrix.runtime }}
8692
path: |
8793
artifacts
8894

.github/workflows/release.yml

+24-14
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ jobs:
232232
runs-on: ubuntu-latest
233233
environment: release
234234
needs: prereqs
235+
strategy:
236+
matrix:
237+
runtime: [ linux-x64, linux-arm64, linux-arm ]
235238
steps:
236239
- uses: actions/checkout@v4
237240

@@ -241,7 +244,10 @@ jobs:
241244
dotnet-version: 8.0.x
242245

243246
- name: Build
244-
run: dotnet build --configuration=LinuxRelease
247+
run: |
248+
dotnet build src/linux/Packaging.Linux/*.csproj \
249+
--configuration=LinuxRelease --no-self-contained \
250+
--runtime=${{ matrix.runtime }}
245251
246252
- name: Run Linux unit tests
247253
run: |
@@ -286,18 +292,18 @@ jobs:
286292
run: |
287293
# Sign Debian package
288294
version=${{ needs.prereqs.outputs.version }}
289-
mv out/linux/Packaging.Linux/Release/deb/gcm-linux_amd64.$version.deb .
290-
debsigs --sign=origin --verify --check gcm-linux_amd64.$version.deb
295+
mv out/linux/Packaging.Linux/Release/deb/gcm-${{ matrix.runtime }}.$version.deb .
296+
debsigs --sign=origin --verify --check gcm-${{ matrix.runtime }}.$version.deb
291297
292298
# Generate tarball signature file
293299
mv -v out/linux/Packaging.Linux/Release/tar/* .
294-
gpg --batch --yes --armor --output gcm-linux_amd64.$version.tar.gz.asc \
295-
--detach-sig gcm-linux_amd64.$version.tar.gz
300+
gpg --batch --yes --armor --output gcm-${{ matrix.runtime }}.$version.tar.gz.asc \
301+
--detach-sig gcm-${{ matrix.runtime }}.$version.tar.gz
296302
297303
- name: Upload artifacts
298304
uses: actions/upload-artifact@v4
299305
with:
300-
name: linux-artifacts
306+
name: ${{ matrix.runtime }}-artifacts
301307
path: |
302308
./*.deb
303309
./*.asc
@@ -466,9 +472,9 @@ jobs:
466472
matrix:
467473
component:
468474
- os: ubuntu-latest
469-
artifact: linux-artifacts
475+
artifact: linux-x64-artifacts
470476
command: git-credential-manager
471-
description: linux
477+
description: linux-x64
472478
- os: macos-latest
473479
artifact: macos-osx-x64-artifacts
474480
command: git-credential-manager
@@ -510,15 +516,15 @@ jobs:
510516
Start-Process -Wait -FilePath "$exePath" -ArgumentList "/SILENT /VERYSILENT /NORESTART"
511517
}
512518
513-
- name: Install Linux (Debian package)
514-
if: contains(matrix.component.description, 'linux')
519+
- name: Install Linux x64 (Debian package)
520+
if: contains(matrix.component.description, 'linux-x64')
515521
run: |
516522
debpath=$(find ./*.deb)
517523
sudo apt install $debpath
518524
"${{ matrix.component.command }}" configure
519525
520-
- name: Install Linux (tarball)
521-
if: contains(matrix.component.description, 'linux')
526+
- name: Install Linux x64 (tarball)
527+
if: contains(matrix.component.description, 'linux-x64')
522528
run: |
523529
# Ensure we find only the source tarball, not the symbols
524530
tarpath=$(find . -name '*[[:digit:]].tar.gz')
@@ -598,7 +604,9 @@ jobs:
598604
az keyvault secret show --name "$GPG_PUBLIC_KEY_SECRET_NAME" \
599605
--vault-name "$AZURE_VAULT" --query "value" \
600606
| sed -e 's/^"//' -e 's/"$//' | base64 -d >gcm-public.asc
601-
mv gcm-public.asc linux-artifacts
607+
cp gcm-public.asc linux-x64-artifacts/
608+
cp gcm-public.asc linux-arm64-artifacts/
609+
mv gcm-public.asc linux-arm-artifacts
602610
603611
- uses: actions/github-script@v7
604612
with:
@@ -655,7 +663,9 @@ jobs:
655663
uploadDirectoryToRelease('osx-payload-and-symbols'),
656664
657665
// Upload Linux artifacts
658-
uploadDirectoryToRelease('linux-artifacts'),
666+
uploadDirectoryToRelease('linux-x64-artifacts'),
667+
uploadDirectoryToRelease('linux-arm64-artifacts'),
668+
uploadDirectoryToRelease('linux-arm-artifacts'),
659669
660670
// Upload .NET tool package
661671
uploadDirectoryToRelease('dotnet-tool-sign'),

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Basic HTTP authentication support|✓|✓|✓
4747
Proxy support|✓|✓|✓
4848
`amd64` support|✓|✓|✓
4949
`x86` support|✓|_N/A_|✗
50-
`arm64` support|best effort|✓|best effort, no packages
51-
`armhf` support|_N/A_|_N/A_|best effort, no packages
50+
`arm64` support|best effort|✓|✓
51+
`armhf` support|_N/A_|_N/A_|✓
5252

5353
(\*) GCM guarantees support only for [the Linux distributions that are officially
5454
supported by dotnet][dotnet-distributions].

docs/development.md

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ To build from the command line, run:
5454
dotnet build -c LinuxDebug
5555
```
5656

57+
If you want to build for a specific architecture, you can provide `linux-x64` or `linux-arm64` or `linux-arm` as the runtime:
58+
59+
```shell
60+
dotnet build -c LinuxDebug -r linux-arm64
61+
```
62+
5763
You can find a copy of the Debian package (.deb) file in `out/linux/Packaging.Linux/deb/Debug`.
5864

5965
The flat binaries can also be found in `out/linux/Packaging.Linux/payload/Debug`.

src/linux/Packaging.Linux/Packaging.Linux.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
2525

2626
<Target Name="CoreCompile" Condition="'$(OSPlatform)'=='linux'">
27-
<Message Text="$(MSBuildProjectDirectory)\build.sh --install-from-source=$(InstallFromSource) --configuration='$(Configuration)' --version='$(Version)' --install-prefix='$(InstallPrefix)'" Importance="High" />
28-
<Exec Command="$(MSBuildProjectDirectory)\build.sh --install-from-source=$(InstallFromSource) --configuration='$(Configuration)' --version='$(Version)' --install-prefix='$(InstallPrefix)'" />
27+
<Message Text="$(MSBuildProjectDirectory)\build.sh --install-from-source=$(InstallFromSource) --configuration='$(Configuration)' --version='$(Version)' --runtime='$(RuntimeIdentifier)' --install-prefix='$(InstallPrefix)'" Importance="High" />
28+
<Exec Command="$(MSBuildProjectDirectory)\build.sh --install-from-source=$(InstallFromSource) --configuration='$(Configuration)' --version='$(Version)' --runtime='$(RuntimeIdentifier)' --install-prefix='$(InstallPrefix)'" />
2929
</Target>
3030

3131
<Target Name="CoreClean">

src/linux/Packaging.Linux/build.sh

+28-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ case "$i" in
3030
INSTALL_FROM_SOURCE="${i#*=}"
3131
shift # past argument=value
3232
;;
33+
--runtime=*)
34+
RUNTIME="${i#*=}"
35+
shift # past argument=value
36+
;;
3337
--install-prefix=*)
3438
INSTALL_PREFIX="${i#*=}"
3539
shift # past argument=value
@@ -45,6 +49,28 @@ if [ ! -d "$INSTALL_PREFIX" ]; then
4549
mkdir -p "$INSTALL_PREFIX"
4650
fi
4751

52+
# Fall back to host architecture if no explicit runtime is given.
53+
if test -z "$RUNTIME"; then
54+
HOST_ARCH="`dpkg-architecture -q DEB_HOST_ARCH`"
55+
56+
case $HOST_ARCH in
57+
amd64)
58+
RUNTIME="linux-x64"
59+
;;
60+
arm64)
61+
RUNTIME="linux-arm64"
62+
;;
63+
armhf)
64+
RUNTIME="linux-arm"
65+
;;
66+
*)
67+
die "Could not determine host architecture!"
68+
;;
69+
esac
70+
fi
71+
72+
echo "Building for runtime ${RUNTIME}"
73+
4874
# Perform pre-execution checks
4975
CONFIGURATION="${CONFIGURATION:=Debug}"
5076
if [ -z "$VERSION" ]; then
@@ -56,7 +82,7 @@ PAYLOAD="$OUTDIR/payload"
5682
SYMBOLS="$OUTDIR/payload.sym"
5783

5884
# Lay out payload
59-
"$INSTALLER_SRC/layout.sh" --configuration="$CONFIGURATION" || exit 1
85+
"$INSTALLER_SRC/layout.sh" --configuration="$CONFIGURATION" --runtime="$RUNTIME" || exit 1
6086

6187
if [ $INSTALL_FROM_SOURCE = true ]; then
6288
echo "Installing to $INSTALL_PREFIX"
@@ -79,7 +105,7 @@ if [ $INSTALL_FROM_SOURCE = true ]; then
79105
echo "Install complete."
80106
else
81107
# Pack
82-
"$INSTALLER_SRC/pack.sh" --configuration="$CONFIGURATION" --payload="$PAYLOAD" --symbols="$SYMBOLS" --version="$VERSION" || exit 1
108+
"$INSTALLER_SRC/pack.sh" --configuration="$CONFIGURATION" --runtime="$RUNTIME" --payload="$PAYLOAD" --symbols="$SYMBOLS" --version="$VERSION" || exit 1
83109
fi
84110

85111
echo "Build of Packaging.Linux complete."

src/linux/Packaging.Linux/layout.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ case "$i" in
2323
CONFIGURATION="${i#*=}"
2424
shift # past argument=value
2525
;;
26+
--runtime=*)
27+
RUNTIME="${i#*=}"
28+
shift # past argument=value
29+
;;
2630
*)
2731
# unknown option
2832
;;
@@ -39,7 +43,10 @@ PROJ_OUT="$OUT/linux/Packaging.Linux"
3943

4044
# Build parameters
4145
FRAMEWORK=net8.0
42-
RUNTIME=linux-x64
46+
47+
if [ -z "$RUNTIME" ]; then
48+
die "--runtime was not set"
49+
fi
4350

4451
# Perform pre-execution checks
4552
CONFIGURATION="${CONFIGURATION:=Debug}"

src/linux/Packaging.Linux/pack.sh

+25-8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ case "$i" in
2828
SYMBOLS="${i#*=}"
2929
shift # past argument=value
3030
;;
31+
--runtime=*)
32+
RUNTIME="${i#*=}"
33+
shift # past argument=value
34+
;;
3135
--configuration=*)
3236
CONFIGURATION="${i#*=}"
3337
shift # past argument=value
@@ -51,20 +55,17 @@ fi
5155
if [ -z "$SYMBOLS" ]; then
5256
die "--symbols was not set"
5357
fi
54-
55-
ARCH="`dpkg-architecture -q DEB_HOST_ARCH`"
56-
57-
if test -z "$ARCH"; then
58-
die "Could not determine host architecture!"
58+
if [ -z "$RUNTIME" ]; then
59+
die "--runtime was not set"
5960
fi
6061

6162
TAROUT="$PROJ_OUT/$CONFIGURATION/tar/"
62-
TARBALL="$TAROUT/gcm-linux_$ARCH.$VERSION.tar.gz"
63-
SYMTARBALL="$TAROUT/gcm-linux_$ARCH.$VERSION-symbols.tar.gz"
63+
TARBALL="$TAROUT/gcm-$RUNTIME.$VERSION.tar.gz"
64+
SYMTARBALL="$TAROUT/gcm-$RUNTIME.$VERSION-symbols.tar.gz"
6465

6566
DEBOUT="$PROJ_OUT/$CONFIGURATION/deb"
6667
DEBROOT="$DEBOUT/root"
67-
DEBPKG="$DEBOUT/gcm-linux_$ARCH.$VERSION.deb"
68+
DEBPKG="$DEBOUT/gcm-$RUNTIME.$VERSION.deb"
6869
mkdir -p "$DEBROOT"
6970

7071
# Set full read, write, execute permissions for owner and just read and execute permissions for group and other
@@ -99,6 +100,22 @@ INSTALL_TO="$DEBROOT/usr/local/share/gcm-core/"
99100
LINK_TO="$DEBROOT/usr/local/bin/"
100101
mkdir -p "$DEBROOT/DEBIAN" "$INSTALL_TO" "$LINK_TO" || exit 1
101102

103+
# Determine architecture for debian control file from the runtime architecture
104+
case $RUNTIME in
105+
linux-x64)
106+
ARCH="amd64"
107+
;;
108+
linux-arm64)
109+
ARCH="arm64"
110+
;;
111+
linux-arm)
112+
ARCH="armhf"
113+
;;
114+
*)
115+
die "Incompatible runtime architecture given for pack.sh"
116+
;;
117+
esac
118+
102119
# make the debian control file
103120
# this is purposefully not indented, see
104121
# https://stackoverflow.com/questions/9349616/bash-eof-in-if-statement

src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<OutputType>Exe</OutputType>
55
<TargetFrameworks>net8.0</TargetFrameworks>
66
<TargetFrameworks Condition="'$(OSPlatform)'=='windows'">net472;net8.0</TargetFrameworks>
7-
<RuntimeIdentifiers>win-x86;osx-x64;linux-x64;osx-arm64</RuntimeIdentifiers>
7+
<RuntimeIdentifiers>win-x86;osx-x64;linux-x64;osx-arm64;linux-arm64;linux-arm</RuntimeIdentifiers>
88
<PlatformTarget Condition="'$(OSPlatform)'=='windows'">x86</PlatformTarget>
99
<AssemblyName>git-credential-manager</AssemblyName>
1010
<RootNamespace>GitCredentialManager</RootNamespace>

0 commit comments

Comments
 (0)