Skip to content

Commit 81501c0

Browse files
buchwasaldennington
authored andcommitted
macos: build arm-64
Add support for building osx-arm64 in addition to osx-x64 to produce native M1 binaries.
1 parent 3eb7bd7 commit 81501c0

File tree

11 files changed

+139
-26
lines changed

11 files changed

+139
-26
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
osx-build:
1313
name: Build macOS
1414
runs-on: macos-latest
15+
strategy:
16+
matrix:
17+
runtime: [ osx-x64, osx-arm64 ]
1518
steps:
1619
- uses: actions/checkout@v3
1720
with:
@@ -27,15 +30,19 @@ jobs:
2730

2831
- name: Build
2932
run: |
30-
dotnet build --configuration=MacRelease
33+
dotnet build src/osx/Installer.Mac/*.csproj \
34+
--configuration=MacRelease --no-self-contained \
35+
--runtime=${{ matrix.runtime }}
3136
3237
- name: Run macOS unit tests
3338
run: |
3439
dotnet test --configuration=MacRelease
3540
3641
- name: Lay out payload and symbols
3742
run: |
38-
src/osx/Installer.Mac/layout.sh --configuration=MacRelease --output=payload --symbol-output=symbols
43+
src/osx/Installer.Mac/layout.sh \
44+
--configuration=MacRelease --output=payload \
45+
--symbol-output=symbols --runtime=${{ matrix.runtime }}
3946
4047
- name: Create keychain
4148
env:
@@ -58,7 +65,7 @@ jobs:
5865
- name: Upload macOS artifacts
5966
uses: actions/upload-artifact@v3
6067
with:
61-
name: tmp.osx-build
68+
name: tmp.${{ matrix.runtime }}-build
6269
path: |
6370
payload
6471
symbols
@@ -67,6 +74,9 @@ jobs:
6774
name: Sign macOS payload
6875
# ESRP service requires signing to run on Windows
6976
runs-on: windows-latest
77+
strategy:
78+
matrix:
79+
runtime: [ osx-x64, osx-arm64 ]
7080
needs: osx-build
7181
steps:
7282
- name: Check out repository
@@ -75,7 +85,7 @@ jobs:
7585
- name: Download payload
7686
uses: actions/download-artifact@v3
7787
with:
78-
name: tmp.osx-build
88+
name: tmp.${{ matrix.runtime }}-build
7989

8090
- name: Zip unsigned payload
8191
shell: pwsh
@@ -109,7 +119,9 @@ jobs:
109119
APPLE_KEY_CODE: ${{ secrets.APPLE_KEY_CODE }}
110120
APPLE_SIGNING_OP_CODE: ${{ secrets.APPLE_SIGNING_OPERATION_CODE }}
111121
run: |
112-
python .github\run_esrp_signing.py payload $env:APPLE_KEY_CODE $env:APPLE_SIGNING_OP_CODE --params 'Hardening' '--options=runtime'
122+
python .github\run_esrp_signing.py payload `
123+
$env:APPLE_KEY_CODE $env:APPLE_SIGNING_OP_CODE `
124+
--params 'Hardening' '--options=runtime'
113125
114126
- name: Unzip signed payload
115127
shell: pwsh
@@ -120,13 +132,16 @@ jobs:
120132
- name: Upload signed payload
121133
uses: actions/upload-artifact@v3
122134
with:
123-
name: osx-payload-sign
135+
name: ${{ matrix.runtime }}-payload-sign
124136
path: |
125137
signed
126138
127139
osx-pack:
128140
name: Package macOS payload
129141
runs-on: macos-latest
142+
strategy:
143+
matrix:
144+
runtime: [ osx-x64, osx-arm64 ]
130145
needs: osx-payload-sign
131146
steps:
132147
- name: Check out repository
@@ -147,27 +162,34 @@ jobs:
147162
- name: Download signed payload
148163
uses: actions/download-artifact@v3
149164
with:
150-
name: osx-payload-sign
165+
name: ${{ matrix.runtime }}-payload-sign
151166

152167
- name: Create component package
153168
run: |
154-
src/osx/Installer.Mac/pack.sh --payload=payload --version=$GitBuildVersionSimple --output=components/com.microsoft.gitcredentialmanager.component.pkg
169+
src/osx/Installer.Mac/pack.sh --payload=payload \
170+
--version=$GitBuildVersionSimple \
171+
--output=components/com.microsoft.gitcredentialmanager.component.pkg
155172
156173
- name: Create product archive
157174
run: |
158-
src/osx/Installer.Mac/dist.sh --package-path=components --version=$GitBuildVersionSimple --output=pkg/gcm-osx-x64-$GitBuildVersionSimple.pkg || exit 1
175+
src/osx/Installer.Mac/dist.sh --package-path=components \
176+
--version=$GitBuildVersionSimple --runtime=${{ matrix.runtime }} \
177+
--output=pkg/gcm-${{ matrix.runtime }}-$GitBuildVersionSimple.pkg || exit 1
159178
160179
- name: Upload package
161180
uses: actions/upload-artifact@v3
162181
with:
163-
name: tmp.osx-pack
182+
name: tmp.${{ matrix.runtime }}-pack
164183
path: |
165184
pkg
166185
167186
osx-sign:
168187
name: Sign and notarize macOS package
169188
# ESRP service requires signing to run on Windows
170189
runs-on: windows-latest
190+
strategy:
191+
matrix:
192+
runtime: [ osx-x64, osx-arm64 ]
171193
needs: osx-pack
172194
steps:
173195
- name: Check out repository
@@ -176,7 +198,7 @@ jobs:
176198
- name: Download unsigned package
177199
uses: actions/download-artifact@v3
178200
with:
179-
name: tmp.osx-pack
201+
name: tmp.${{ matrix.runtime }}-pack
180202
path: pkg
181203

182204
- name: Zip unsigned package
@@ -236,7 +258,7 @@ jobs:
236258
- name: Publish signed package
237259
uses: actions/upload-artifact@v3
238260
with:
239-
name: osx-sign
261+
name: ${{ matrix.runtime }}-sign
240262
path: signed/*.pkg
241263

242264
# ================================
@@ -468,8 +490,12 @@ jobs:
468490
- name: Archive macOS payload and symbols
469491
run: |
470492
mkdir osx-payload-and-symbols
471-
tar -C osx-payload-sign -czf osx-payload-and-symbols/gcm-osx-x64-$GitBuildVersionSimple.tar.gz .
472-
tar -C tmp.osx-build/symbols -czf osx-payload-and-symbols/gcm-osx-x64-$GitBuildVersionSimple-symbols.tar.gz .
493+
494+
tar -C osx-x64-payload-sign -czf osx-payload-and-symbols/gcm-osx-x64-$GitBuildVersionSimple.tar.gz .
495+
tar -C tmp.osx-x64-build/symbols -czf osx-payload-and-symbols/gcm-osx-x64-$GitBuildVersionSimple-symbols.tar.gz .
496+
497+
tar -C osx-arm64-payload-sign -czf osx-payload-and-symbols/gcm-osx-arm64-$GitBuildVersionSimple.tar.gz .
498+
tar -C tmp.osx-arm64-build/symbols -czf osx-payload-and-symbols/gcm-osx-arm64-$GitBuildVersionSimple-symbols.tar.gz .
473499
474500
- name: Archive Windows payload and symbols
475501
shell: pwsh
@@ -527,7 +553,8 @@ jobs:
527553
uploadDirectoryToRelease('win-x86-payload-and-symbols'),
528554
529555
// Upload macOS artifacts
530-
uploadDirectoryToRelease('osx-sign'),
556+
uploadDirectoryToRelease('osx-x64-sign'),
557+
uploadDirectoryToRelease('osx-arm64-sign'),
531558
uploadDirectoryToRelease('osx-payload-and-symbols'),
532559
533560
// Upload Linux artifacts

src/osx/Installer.Mac/Installer.Mac.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
2222

2323
<Target Name="CoreCompile" DependsOnTargets="GetBuildVersion" Condition="'$(OSPlatform)'=='osx'">
24-
<Message Text="$(MSBuildProjectDirectory)\build.sh --configuration='$(Configuration)' --version='$(BuildVersionSimple)'" Importance="High" />
25-
<Exec Command="$(MSBuildProjectDirectory)\build.sh --configuration='$(Configuration)' --version='$(BuildVersionSimple)'" />
24+
<Message Text="$(MSBuildProjectDirectory)\build.sh --configuration='$(Configuration)' --version='$(BuildVersionSimple)' --runtime='$(RuntimeIdentifier)'" Importance="High" />
25+
<Exec Command="$(MSBuildProjectDirectory)\build.sh --configuration='$(Configuration)' --version='$(BuildVersionSimple)' --runtime='$(RuntimeIdentifier)'" />
2626
</Target>
2727

2828
<Target Name="CoreClean">

src/osx/Installer.Mac/build.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ case "$i" in
2222
CONFIGURATION="${i#*=}"
2323
shift # past argument=value
2424
;;
25+
--runtime=*)
26+
RUNTIME="${i#*=}"
27+
shift
28+
;;
2529
--version=*)
2630
VERSION="${i#*=}"
2731
shift # past argument=value
@@ -38,15 +42,30 @@ if [ -z "$VERSION" ]; then
3842
die "--version was not set"
3943
fi
4044

45+
if [ -z "$RUNTIME" ]; then
46+
TEST_RUNTIME=`uname -m`
47+
case $TEST_RUNTIME in
48+
"x86_64")
49+
RUNTIME="osx-x64"
50+
;;
51+
"arm64")
52+
RUNTIME="osx-arm64"
53+
;;
54+
*)
55+
die "Unknown runtime '$TEST_RUNTIME'"
56+
;;
57+
esac
58+
fi
59+
4160
OUTDIR="$INSTALLER_OUT/pkg/$CONFIGURATION"
4261
PAYLOAD="$OUTDIR/payload"
4362
COMPONENTDIR="$OUTDIR/components"
4463
COMPONENTOUT="$COMPONENTDIR/com.microsoft.gitcredentialmanager.component.pkg"
4564
DISTOUT="$OUTDIR/gcm-osx-x64-$VERSION.pkg"
4665

4766
# Layout and pack
48-
"$INSTALLER_SRC/layout.sh" --configuration="$CONFIGURATION" --output="$PAYLOAD" || exit 1
67+
"$INSTALLER_SRC/layout.sh" --configuration="$CONFIGURATION" --output="$PAYLOAD" --runtime="$RUNTIME" || exit 1
4968
"$INSTALLER_SRC/pack.sh" --payload="$PAYLOAD" --version="$VERSION" --output="$COMPONENTOUT" || exit 1
50-
"$INSTALLER_SRC/dist.sh" --package-path="$COMPONENTDIR" --version="$VERSION" --output="$DISTOUT" || exit 1
69+
"$INSTALLER_SRC/dist.sh" --package-path="$COMPONENTDIR" --version="$VERSION" --output="$DISTOUT" --runtime="$RUNTIME" || exit 1
5170

5271
echo "Build of Installer.Mac complete."

src/osx/Installer.Mac/dist.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ SRC="$ROOT/src"
1111
OUT="$ROOT/out"
1212
INSTALLER_SRC="$SRC/osx/Installer.Mac"
1313
RESXPATH="$INSTALLER_SRC/resources"
14-
DISTPATH="$INSTALLER_SRC/distribution.xml"
1514

1615
# Product information
1716
IDENTIFIER="com.microsoft.gitcredentialmanager.dist"
@@ -32,6 +31,10 @@ case "$i" in
3231
DISTOUT="${i#*=}"
3332
shift # past argument=value
3433
;;
34+
--runtime=*)
35+
RUNTIME="${i#*=}"
36+
shift
37+
;;
3538
*)
3639
# unknown option
3740
;;
@@ -50,6 +53,28 @@ fi
5053
if [ -z "$DISTOUT" ]; then
5154
die "--output was not set"
5255
fi
56+
if [ -z "$RUNTIME" ]; then
57+
TEST_RUNTIME=`uname -m`
58+
case $TEST_RUNTIME in
59+
"x86_64")
60+
RUNTIME="osx-x64"
61+
;;
62+
"arm64")
63+
RUNTIME="osx-arm64"
64+
;;
65+
*)
66+
die "Unknown runtime '$TEST_RUNTIME'"
67+
;;
68+
esac
69+
fi
70+
71+
echo "Building for runtime '$RUNTIME'"
72+
73+
if [ "$RUNTIME" == "osx-x64"]; then
74+
DISTPATH="$INSTALLER_SRC/distribution.x64.xml"
75+
else
76+
DISTPATH="$INSTALLER_SRC/distribution.arm64.xml"
77+
fi
5378

5479
# Cleanup any old package
5580
if [ -e "$DISTOUT" ]; then

src/osx/Installer.Mac/distribution.xml renamed to src/osx/Installer.Mac/distribution.arm64.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<installer-gui-script minSpecVersion="1">
33
<title>Git Credential Manager</title>
44
<background file="background.png" mime-type="image/png" alignment="bottomleft" scaling="tofit" />
5-
<options customize="never" />
5+
<options customize="never" hostArchitectures="arm64"/>
66
<welcome file="welcome.html" mime-type="text/html" />
77
<conclusion file="conclusion.html" mime-type="text/html" />
88
<license file="LICENSE" />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<installer-gui-script minSpecVersion="1">
3+
<title>Git Credential Manager</title>
4+
<background file="background.png" mime-type="image/png" alignment="bottomleft" scaling="tofit" />
5+
<options customize="never" hostArchitectures="x86_64" />
6+
<welcome file="welcome.html" mime-type="text/html" />
7+
<conclusion file="conclusion.html" mime-type="text/html" />
8+
<license file="LICENSE" />
9+
<volume-check>
10+
<allowed-os-versions>
11+
<os-version min="10.13" />
12+
</allowed-os-versions>
13+
</volume-check>
14+
<pkg-ref id="gcmcore" />
15+
<choices-outline>
16+
<line choice="default" />
17+
</choices-outline>
18+
<choice id="default" visible="true" enabled="false" title="Git Credential Manager" description="Git Credential Manager application.">
19+
<pkg-ref id="gcmcore">com.microsoft.gitcredentialmanager.component.pkg</pkg-ref>
20+
</choice>
21+
</installer-gui-script>

src/osx/Installer.Mac/layout.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ GITLAB_UI_SRC="$SRC/shared/GitLab.UI.Avalonia"
2727

2828
# Build parameters
2929
FRAMEWORK=net6.0
30-
RUNTIME=osx-x64
3130

3231
# Parse script arguments
3332
for i in "$@"
@@ -41,6 +40,10 @@ case "$i" in
4140
PAYLOAD="${i#*=}"
4241
shift # past argument=value
4342
;;
43+
--runtime=*)
44+
RUNTIME="${i#*=}"
45+
shift # past argument=value
46+
;;
4447
--symbol-output=*)
4548
SYMBOLOUT="${i#*=}"
4649
;;
@@ -50,6 +53,24 @@ case "$i" in
5053
esac
5154
done
5255

56+
# Determine a runtime if one was not provided
57+
if [ -z "$RUNTIME" ]; then
58+
TEST_RUNTIME=`uname -m`
59+
case $TEST_RUNTIME in
60+
"x86_64")
61+
RUNTIME="osx-x64"
62+
;;
63+
"arm64")
64+
RUNTIME="osx-arm64"
65+
;;
66+
*)
67+
die "Unknown runtime '$TEST_RUNTIME'"
68+
;;
69+
esac
70+
fi
71+
72+
echo "Building for runtime '$RUNTIME'"
73+
5374
# Perform pre-execution checks
5475
CONFIGURATION="${CONFIGURATION:=Debug}"
5576
if [ -z "$PAYLOAD" ]; then

src/shared/Atlassian.Bitbucket.UI.Avalonia/Atlassian.Bitbucket.UI.Avalonia.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
55
<TargetFramework>net6.0</TargetFramework>
6-
<RuntimeIdentifiers>osx-x64;linux-x64</RuntimeIdentifiers>
6+
<RuntimeIdentifiers>osx-x64;linux-x64;osx-arm64</RuntimeIdentifiers>
77
<RootNamespace>Atlassian.Bitbucket.UI</RootNamespace>
88
<AssemblyName>Atlassian.Bitbucket.UI</AssemblyName>
99
</PropertyGroup>

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

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

src/shared/GitHub.UI.Avalonia/GitHub.UI.Avalonia.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
55
<TargetFramework>net6.0</TargetFramework>
6-
<RuntimeIdentifiers>osx-x64;linux-x64</RuntimeIdentifiers>
6+
<RuntimeIdentifiers>osx-x64;linux-x64;osx-arm64</RuntimeIdentifiers>
77
<RootNamespace>GitHub.UI</RootNamespace>
88
<AssemblyName>GitHub.UI</AssemblyName>
99
</PropertyGroup>

0 commit comments

Comments
 (0)