Skip to content

Commit c8e69f8

Browse files
nscurocoderpatros
authored andcommitted
Fix build for osx-arm64
Apparently binaries for apple silicon must be signed. However, a simple ad-hoc signature without certificate is enough. Signed-off-by: nscuro <[email protected]>
1 parent b4b9710 commit c8e69f8

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

.github/workflows/release.yml

+32-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
name: Release
2828
runs-on: ubuntu-20.04
2929
timeout-minutes: 30
30+
outputs:
31+
# Used by the release-osx-arm64 job to upload the osx-arm64 binary
32+
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
3033
steps:
3134
- uses: actions/[email protected]
3235
- uses: actions/[email protected]
@@ -45,7 +48,7 @@ jobs:
4548
REPO=cyclonedx/cyclonedx-cli
4649
dotnet build --configuration Release
4750
mkdir bin
48-
for runtime in linux-x64 linux-musl-x64 linux-arm linux-arm64 win-x64 win-x86 win-arm win-arm64 osx-x64 osx-arm64
51+
for runtime in linux-x64 linux-musl-x64 linux-arm linux-arm64 win-x64 win-x86 win-arm win-arm64 osx-x64
4952
do
5053
dotnet publish src/cyclonedx/cyclonedx.csproj -r $runtime --configuration Release /p:Version=$VERSION --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --output bin/$runtime
5154
done
@@ -161,12 +164,38 @@ jobs:
161164
asset_name: cyclonedx-osx-x64
162165
asset_content_type: application/octet-stream
163166

167+
# Binaries for Apple silicon must be signed, which can only be achieved on macOS.
168+
# See https://github.com/dotnet/runtime/issues/49091#issuecomment-797029172
169+
release-osx-arm64:
170+
name: Release osx-arm64
171+
needs: release
172+
runs-on: macos-latest
173+
timeout-minutes: 30
174+
steps:
175+
- uses: actions/[email protected]
176+
- uses: actions/[email protected]
177+
with:
178+
dotnet-version: '6.0'
179+
180+
- name: Create binary
181+
run: |
182+
VERSION=`cat semver.txt`
183+
echo "##[set-output name=version;]$VERSION"
184+
dotnet build --configuration Release
185+
mkdir bin
186+
dotnet publish src/cyclonedx/cyclonedx.csproj -r osx-arm64 --configuration Release /p:Version=$VERSION --self-contained true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --output bin/osx-arm64
187+
188+
# It is enough to "ad-hoc" sign the binary, we don't need a valid developer certificate for now.
189+
- name: Sign binary
190+
run: |
191+
codesign -f -s - bin/osx-arm64/cyclonedx
192+
164193
- name: Upload binary to github release
165194
uses: actions/[email protected]
166195
env:
167196
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168197
with:
169-
upload_url: ${{ steps.create_release.outputs.upload_url }}
198+
upload_url: ${{ needs.release.outputs.release_upload_url }}
170199
asset_path: bin/osx-arm64/cyclonedx
171200
asset_name: cyclonedx-osx-arm64
172-
asset_content_type: application/octet-stream
201+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)