Skip to content

Commit fc58c5c

Browse files
authored
Implement macOS build signing in workflow (#18)
1 parent ab0d10f commit fc58c5c

1 file changed

Lines changed: 65 additions & 24 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ jobs:
4444
shell: pwsh
4545
run: winget install -e --id Mono.Mono --silent --accept-source-agreements
4646
if: runner.os == 'Windows'
47-
# - uses: ilammy/msvc-dev-cmd@v1
48-
# if: runner.os == 'Windows'
4947

5048
- name: Download vcpkg
5149
uses: actions/checkout@v6
@@ -62,7 +60,7 @@ jobs:
6260
shell: pwsh
6361
run: ${{ github.workspace }}/vcpkg/bootstrap-vcpkg.bat
6462
- name: Add NuGet sources
65-
if: ${{ ! contains(matrix.config.os, 'windows') }}
63+
if: runner.os != 'Windows'
6664
run: |
6765
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
6866
sources add \
@@ -104,38 +102,88 @@ jobs:
104102
out/build/${{ matrix.config.preset }}/snfm_user_manual.md
105103
out/build/${{ matrix.config.preset }}/snfm_config_example.yaml
106104
105+
sign:
106+
runs-on: macos-latest
107+
needs: build
108+
steps:
109+
- name: unpack Apple signing credentials
110+
env:
111+
TEMP_PASSWORD: build.keychain
112+
run: |
113+
echo "${{secrets.MACOS_CERTIFICATE}}" | base64 -D > certificate.p12
114+
security create-keychain -p $TEMP_PASSWORD build.keychain
115+
security default-keychain -s build.keychain
116+
security unlock-keychain -p $TEMP_PASSWORD build.keychain
117+
security import certificate.p12 -k build.keychain -P "${{secrets.MACOS_CERTIFICATE_PWD}}" -T /usr/bin/codesign
118+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $TEMP_PASSWORD build.keychain
119+
- name: Get artifact (arm)
120+
uses: actions/download-artifact@v6
121+
with:
122+
name: snfm-macos-arm64-release
123+
path: macos-arm64
124+
- name: Get artifact (x64)
125+
uses: actions/download-artifact@v6
126+
with:
127+
name: snfm-macos-x64-release
128+
path: macos-x64
129+
- name: Create universal binaries
130+
run: |
131+
mkdir -p out
132+
ls -al macos-arm64
133+
lipo -create -output out/manage_files macos-arm64/manage_files macos-x64/manage_files
134+
lipo -create -output out/send_file macos-arm64/send_file macos-x64/send_file
135+
ls -al out
136+
- name: Sign macOS binaries
137+
run: |
138+
/usr/bin/codesign --options runtime --force -s ${{ secrets.MACOS_IDENTITY_ID }} out/manage_files
139+
/usr/bin/codesign --options runtime --force -s ${{ secrets.MACOS_IDENTITY_ID }} out/send_file
140+
- name: Zip for upload to Apple
141+
run: zip -j
142+
snfm-apple.zip
143+
out/manage_files
144+
out/send_file
145+
- name: Add additional files
146+
run: |
147+
cp macos-arm64/snfm_user_manual.md out
148+
cp macos-arm64/snfm_config_example.yaml out
149+
- name: Archive build
150+
uses: actions/upload-artifact@v5
151+
with:
152+
name: snfm-macos-universal-release
153+
path: out/
154+
- name: notarize macOS build
155+
run: xcrun notarytool submit --wait
156+
--apple-id ${{ secrets.APPLE_ID }}
157+
--team-id ${{ secrets.APPLE_DEVELOPER_TEAM_ID }}
158+
--password ${{ secrets.APP_SPECIFIC_PASS }}
159+
snfm-apple.zip
160+
107161
release:
108162
if: github.event_name == 'release'
109163
runs-on: ubuntu-latest
110164
needs: build
111165
steps:
112166
- name: Inject slug/short variables
113167
uses: rlespinasse/github-slug-action@v3.x
114-
- name: Get artifact
168+
- name: Get artifact (windows)
115169
uses: actions/download-artifact@v6
116170
with:
117171
name: snfm-windows-x64-release
118172
path: windows
119-
- name: Get artifact
173+
- name: Get artifact (linux)
120174
uses: actions/download-artifact@v6
121175
with:
122176
name: snfm-linux-x64-release
123177
path: linux
124-
- name: Get artifact
125-
uses: actions/download-artifact@v6
126-
with:
127-
name: snfm-macos-arm64-release
128-
path: macos-arm64
129-
- name: Get artifact
178+
- name: Get artifact (mac)
130179
uses: actions/download-artifact@v6
131180
with:
132-
name: snfm-macos-x64-release
133-
path: macos-x64
181+
name: snfm-macos-universal-release
182+
path: macos
134183
- name: Fix +x
135184
run: |
136185
chmod +x */send_file
137186
chmod +x */manage_files
138-
139187
- name: Archive Release
140188
uses: thedoctor0/zip-release@main
141189
with:
@@ -152,7 +200,7 @@ jobs:
152200
uses: thedoctor0/zip-release@main
153201
with:
154202
type: zip
155-
filename: ../snfm-macos-x64-release.zip
203+
filename: ../snfm-macos-universal-release.zip
156204
directory: macos
157205
- name: Upload binaries to release
158206
uses: svenstaro/upload-release-action@v2
@@ -173,12 +221,5 @@ jobs:
173221
with:
174222
tag: ${{ env.GITHUB_REF_SLUG }}
175223
overwrite: true
176-
asset_name: snfm-$tag-macos-x64.zip
177-
file: snfm-macos-x64-release.zip
178-
- name: Upload binaries to release
179-
uses: svenstaro/upload-release-action@v2
180-
with:
181-
tag: ${{ env.GITHUB_REF_SLUG }}
182-
overwrite: true
183-
asset_name: snfm-$tag-macos-arm64.zip
184-
file: snfm-macos-arm64-release.zip
224+
asset_name: snfm-$tag-macos-universal.zip
225+
file: snfm-macos-universal-release.zip

0 commit comments

Comments
 (0)