-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (107 loc) · 4.15 KB
/
build-macos.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build MacOS
on:
push:
branches:
- main
paths:
- '.github/workflows/build-macos.yml'
- 'src/**'
- 'include/**'
- 'example/**'
- 'CMakeLists.txt'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, macos-14]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Homebrew
run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Update CMake
run: brew install cmake
- name: Determine CPU Cores
id: cpu-info
run: echo "CPU_CORES=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release -- -j${{ env.CPU_CORES }}
- name: Install Apple Certificate
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
p12-password: ${{ secrets.APPLE_PASSWORD }}
- name: Install the provisioning profile
run: |
mkdir -p ~/Library/Developer/Xcode/Provisioning\ Profiles
echo "${{ secrets.APPLE_PROVISION_PROFILE }}" | base64 --decode > ~/Library/Developer/Xcode/Provisioning\ Profiles/Github_Actions.provisionprofile
- name: Code Sign Libraries
run: |
for dylib in lib/*.dylib; do
codesign --sign "${{ secrets.APPLE_DEVELOPER_ID_APPLICATION }}" --options runtime --timestamp $dylib
done
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os == 'macos-13' && 'macos-x86_64' || 'macos-arm64' }}
path: |
lib/
include/
create-universal-dylibs:
needs: build
runs-on: macos-latest
steps:
- name: Download x86_64 Build Artifacts
uses: actions/download-artifact@v3
with:
name: macos-x86_64
path: macos-x86_64
- name: Download arm64 Build Artifacts
uses: actions/download-artifact@v3
with:
name: macos-arm64
path: macos-arm64
- name: Create Universal dylibs
run: |
mkdir -p universal/lib
for dylib in macos-x86_64/lib/*.dylib; do
dylib_name=$(basename $dylib)
lipo -create macos-x86_64/lib/$dylib_name macos-arm64/lib/$dylib_name -output universal/lib/$dylib_name
done
- name: Add Include Directory
run: cp -r macos-x86_64/include universal/include
- name: Install Apple Certificate
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
p12-password: ${{ secrets.APPLE_PASSWORD }}
- name: Install the provisioning profile
run: |
mkdir -p ~/Library/Developer/Xcode/Provisioning\ Profiles
echo "${{ secrets.APPLE_PROVISION_PROFILE }}" | base64 --decode > ~/Library/Developer/Xcode/Provisioning\ Profiles/Github_Actions.provisionprofile
- name: Code Sign Universal Libraries
run: |
for dylib in universal/lib/*.dylib; do
codesign --sign "${{ secrets.APPLE_DEVELOPER_ID_APPLICATION }}" --options runtime --timestamp $dylib
done
- name: Compress Universal dylibs
run: ditto -c -k --sequesterRsrc "universal/lib/" "babylon.zip"
- name: Submit for Notarization
run: |
xcrun notarytool store-credentials --apple-id ${{ secrets.APPLE_ID }} --password ${{ secrets.APPLE_APPLICATION_SPECIFIC_PASSWORD }} --team-id ${{ secrets.APPLE_TEAM_ID }} --validate notorization_profile
xcrun notarytool submit --keychain-profile "notorization_profile" --progress --wait babylon.zip
- name: Staple Notarization
run: |
for dylib in universal/lib/*.dylib; do
xcrun stapler staple $dylib
done
- name: Upload Universal dylibs
uses: actions/upload-artifact@v3
with:
name: macos-universal
path: universal/