1111
1212jobs :
1313 build-sentry-native :
14- name : sentry-native (${{ matrix.os }})
15- runs-on : ${{ matrix.os }}
14+ name : sentry-native (${{ matrix.runner.container || matrix.runner.os }})
15+ runs-on : ${{ matrix.runner.os }}
16+ container : ${{ matrix.runner.container }}
1617 strategy :
1718 fail-fast : false
1819 matrix :
1920 # Pin ubuntu to ensure mono is installed
2021 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
21- os : [ubuntu-22.04, windows-latest, macos-15]
22+ runner : [
23+ {os: ubuntu-22.04},
24+ {os: ubuntu-latest, container: alpine:3.21, target: Linux-musl},
25+ {os: windows-latest},
26+ {os: macos-15}
27+ ]
2228
2329 steps :
30+ - name : Install build dependencies for Alpine Linux
31+ if : ${{ startsWith(matrix.runner.container, 'alpine') }}
32+ run : |
33+ apk update
34+ apk add bash build-base cmake curl-dev git powershell sudo tar wget
35+ git config --global --add safe.directory $GITHUB_WORKSPACE
36+
2437 - name : Checkout
2538 uses : actions/checkout@v4
2639
@@ -30,14 +43,15 @@ jobs:
3043 id : cache
3144 with :
3245 path : src/Sentry/Platforms/Native/sentry-native
33- key : sentry-native-${{ runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
46+ key : sentry-native-${{ matrix.runner.target || runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
3447 enableCrossOsArchive : true
3548
3649 - name : Remove unused applications
50+ if : ${{ !matrix.runner.container }}
3751 uses : ./.github/actions/freediskspace
3852
3953 - name : Install build dependencies
40- if : steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
54+ if : steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux' && !matrix.runner.container
4155 run : |
4256 sudo apt update
4357 sudo apt install libcurl4-openssl-dev
@@ -48,28 +62,46 @@ jobs:
4862
4963 build :
5064 needs : build-sentry-native
51- name : .NET (${{ matrix.os }})
52- runs-on : ${{ matrix.os }}
65+ name : .NET (${{ matrix.runner.container || matrix.runner.os }})
66+ runs-on : ${{ matrix.runner.os }}
67+ container : ${{ matrix.runner.container }}
5368
5469 strategy :
5570 fail-fast : false
5671 matrix :
5772 # Pin ubuntu to ensure mono is installed
5873 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
59- os : [ubuntu-22.04, windows-latest, macos-15]
74+ runner : [
75+ {os: ubuntu-22.04},
76+ {os: ubuntu-latest, container: alpine:3.21, target: Linux-musl},
77+ {os: windows-latest},
78+ {os: macos-15}
79+ ]
6080
6181 steps :
6282 - name : Cancel Previous Runs
6383 if : github.ref_name != 'main' && !startsWith(github.ref_name, 'release/')
6484 uses : styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # Tag: 0.12.1
6585
86+ - name : Install build dependencies for Alpine Linux
87+ if : ${{ startsWith(matrix.runner.container, 'alpine') }}
88+ run : |
89+ apk update
90+ apk add bash build-base cmake curl-dev git icu openjdk11 powershell sudo tar wget
91+ git config --global --add safe.directory $GITHUB_WORKSPACE
92+ # Grpc.Tools protoc is prebuilt with glibc (https://github.com/grpc/grpc/issues/24188#issuecomment-1403435551)
93+ apk add grpc-plugins
94+ echo "PROTOBUF_PROTOC=/usr/bin/protoc" >> $GITHUB_ENV
95+ echo "GRPC_PROTOC_PLUGIN=/usr/bin/grpc_csharp_plugin" >> $GITHUB_ENV
96+
6697 - name : Checkout
6798 uses : actions/checkout@v4
6899 with :
69100 submodules : recursive
70101 fetch-depth : 2 # default is 1 and codecov needs > 1
71102
72103 - name : Remove unused applications
104+ if : ${{ !matrix.runner.container }}
73105 uses : ./.github/actions/freediskspace
74106
75107 # We use macOS for the final publishing build so we get all the iOS/macCatalyst targets in the packages
@@ -78,13 +110,21 @@ jobs:
78110 run : echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV
79111
80112 - name : Download sentry-native (Linux)
81- if : ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Linux') }}
113+ if : ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Linux' && !matrix.runner.container ) }}
82114 uses : actions/cache/restore@v4
83115 with :
84116 path : src/Sentry/Platforms/Native/sentry-native
85117 key : sentry-native-Linux-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
86118 fail-on-cache-miss : true
87119
120+ - name : Download sentry-native (Linux musl)
121+ if : ${{ (env.CI_PUBLISHING_BUILD == 'true') || (startsWith(matrix.runner.container, 'alpine')) }}
122+ uses : actions/cache/restore@v4
123+ with :
124+ path : src/Sentry/Platforms/Native/sentry-native
125+ key : sentry-native-Linux-musl-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
126+ fail-on-cache-miss : true
127+
88128 - name : Download sentry-native (macOS)
89129 if : ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'macOS') }}
90130 uses : actions/cache/restore@v4
@@ -106,24 +146,25 @@ jobs:
106146 uses : ./.github/actions/environment
107147
108148 - name : Build Native Dependencies
149+ if : ${{ ! matrix.runner.container }}
109150 uses : ./.github/actions/buildnative
110151
111152 - name : Restore .NET Dependencies
112- run : dotnet restore Sentry-CI-Build-${{ runner.os }}.slnf --nologo
153+ run : dotnet restore Sentry-CI-Build-${{ matrix.runner.target || runner.os }}.slnf --nologo
113154
114155 - name : Build
115156 id : build
116- run : dotnet build Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog
157+ run : dotnet build Sentry-CI-Build-${{ matrix.runner.target || runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog
117158
118159 - name : Upload build logs
119160 if : ${{ steps.build.outcome != 'skipped' }}
120161 uses : actions/upload-artifact@v4
121162 with :
122- name : ${{ runner.os }}-build-logs
163+ name : ${{ matrix.runner.target || runner.os }}-build-logs
123164 path : build.binlog
124165
125166 - name : Test
126- run : dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage"
167+ run : dotnet test Sentry-CI-Build-${{ matrix.runner.target || runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage"
127168
128169 - name : Upload code coverage
129170 uses : codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d
@@ -132,14 +173,14 @@ jobs:
132173 if : failure()
133174 uses : actions/upload-artifact@v4
134175 with :
135- name : ${{ runner.os }}-verify-test-results
176+ name : ${{ matrix.runner.target || runner.os }}-verify-test-results
136177 path : " **/*.received.*"
137178
138179 # To save time and disk space, we only create and archive the Nuget packages when we're actually releasing.
139180
140181 - name : Create Nuget Packages
141182 if : env.CI_PUBLISHING_BUILD == 'true'
142- run : dotnet pack Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo
183+ run : dotnet pack Sentry-CI-Build-${{ matrix.runner.target || runner.os }}.slnf -c Release --no-build --nologo
143184
144185 - name : Archive Nuget Packages
145186 if : env.CI_PUBLISHING_BUILD == 'true'
0 commit comments