@@ -13,15 +13,28 @@ jobs:
13
13
# Linux compiles itself
14
14
- os : ubuntu-24.04
15
15
bundle : linux
16
+ targets : |
17
+ cross-aarch64-unknown-linux-gnu
18
+ cross-aarch64-unknown-linux-musl
19
+ cross-x86_64-unknown-linux-gnu
20
+ cross-x86_64-unknown-linux-musl
16
21
17
22
# We can compile the windows target from linux
18
23
- os : ubuntu-24.04
19
24
bundle : windows
25
+ targets : |
26
+ cross-aarch64-pc-windows-gnullvm
27
+ cross-x86_64-pc-windows-gnullvm
20
28
21
29
# Apple SDK does not allow us to cross compile from non-apple-branded
22
30
# machines, so we run that bundle on a macOS runner
23
- - os : macos-latest
31
+ # Note: We use macos-13 here since it is the latest version that runs
32
+ # on an x86_64-apple-darwin machine
33
+ - os : macos-13
24
34
bundle : darwin
35
+ targets : |
36
+ cross-aarch64-apple-darwin
37
+ default
25
38
runs-on : ${{ matrix.os }}
26
39
permissions :
27
40
contents : write
@@ -47,7 +60,133 @@ jobs:
47
60
gc-max-store-size : 5G
48
61
49
62
- name : Build binaries
50
- run : nix build .#${{ matrix.bundle }}-release-bundle
63
+ run : |
64
+ mkdir release
65
+ for BUILD_TARGET in "${{ matrix.targets }}"; do
66
+ # Hack for x86_64-apple-darwin since it doesn't yet work with cross compilation
67
+ if [ "$BUILD_TARGET" == "default" ]; then
68
+ TARGET="x86_64-apple-darwin"
69
+ else
70
+ TARGET=${BUILD_TARGET#"cross-"}
71
+ fi
72
+
73
+ echo "Scaffolding release for $TARGET..."
74
+ mkdir -p "release/$TARGET/dist"
75
+ cp README.md LICENSE "release/$TARGET/dist"
76
+
77
+ echo "Building release for $TARGET..."
78
+ nix build .#$TARGET
79
+ cp result/bin/* "release/$TARGET/dist/"
80
+ done
81
+
82
+ - name : Sign Apple Binary
83
+ if : ${{ runner.os == 'macOS' }}
84
+ env :
85
+ MACOS_CERT_BUNDLE_PASSWORD : ${{ secrets.MACOS_CERT_BUNDLE_PASSWORD }}
86
+ MACOS_CERT_BUNDLE_BASE64 : ${{ secrets.MACOS_CERT_BUNDLE_BASE64 }}
87
+ MACOS_KEYCHAIN_PASSWORD : ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
88
+
89
+ APPLE_NOTARIZATION_PASSWORD : ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
90
+ APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
91
+ APPLE_USERNAME : ${{ secrets.APPLE_USERNAME }}
92
+
93
+ KEYCHAIN_NAME : " apollo-mcp-server-keychain"
94
+ ENTITLEMENTS_PATH : " macos-entitlements.plist"
95
+ VERSION : ${{ github.ref }}
96
+ run : |
97
+ echo "Pre-check: Valid Codesigning Identify"
98
+ security find-identity -v -p codesigning
99
+ echo "Pre-check: Codesigning Identify"
100
+ security find-identity -p codesigning
101
+ echo "Pre-check: Any Identify"
102
+ security find-identity
103
+
104
+ echo "|||||||||||||||||||||||||||||||||||||||||||||"
105
+
106
+ # Create a temporary keychain
107
+ EPHEMERAL_KEYCHAIN=`mktemp`
108
+
109
+ echo "Creating keychain..."
110
+ security create-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" $KEYCHAIN_NAME
111
+ echo "Removing relock timeout on keychain..."
112
+ security set-keychain-settings $KEYCHAIN_NAME
113
+
114
+ echo "Decoding certificate bundle..."
115
+ echo "${MACOS_CERT_BUNDLE_BASE64}" | base64 --decode > $EPHEMERAL_KEYCHAIN/certificate.p12
116
+
117
+ echo "Importing codesigning certificate to build keychain..."
118
+ security import $EPHEMERAL_KEYCHAIN/certificate.p12 -k $KEYCHAIN_NAME -P "${MACOS_CERT_BUNDLE_PASSWORD}" -T /usr/bin/codesign
119
+
120
+ echo "Adding the codesign tool to the security partition-list..."
121
+ security set-key-partition-list -S "apple-tool:,apple:,codesign:" -s -k "${MACOS_KEYCHAIN_PASSWORD}" $KEYCHAIN_NAME
122
+
123
+ echo "Setting default keychain..."
124
+ security default-keychain -d user -s $KEYCHAIN_NAME
125
+
126
+ echo "Unlocking keychain..."
127
+ security unlock-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" $KEYCHAIN_NAME
128
+
129
+ echo "Verifying keychain is set up correctly..."
130
+ security find-identity -v -p codesigning
131
+
132
+ echo "|||||||||||||||||||||||||||||||||||||||||||||"
133
+
134
+ echo "Post-check: Valid Codesigning Identify"
135
+ security find-identity -v -p codesigning
136
+ echo "Post-check: Codesigning Identify"
137
+ security find-identity -p codesigning
138
+ echo "Post-check: Any Identify"
139
+ security find-identity
140
+
141
+ echo "|||||||||||||||||||||||||||||||||||||||||||||"
142
+ # Sign each binary
143
+ for RELEASE in release/*/; do
144
+ RELEASE=${RELEASE%/}
145
+ RELEASE=${RELEASE#"release/"}
146
+
147
+ BINARY_PATH="release/$RELEASE/dist/apollo-mcp-server"
148
+ echo "Starting code signing for $RELEASE..."
149
+
150
+ echo "> Signing code (step 1)..."
151
+ codesign --sign "$APPLE_TEAM_ID" --options runtime --entitlements $ENTITLEMENTS_PATH --force --timestamp "$BINARY_PATH" -v
152
+
153
+ echo "> Signing code (step 2)..."
154
+ codesign -vvv --deep --strict "$BINARY_PATH"
155
+
156
+ echo "> Zipping dist..."
157
+ TMP_DIST=`mktemp`
158
+ mkdir $TMP_DIST/dist
159
+ cp "$BINARY_PATH" "$TMP_DIST/dist/"
160
+ zip -r "$TMP_DIST/apollo-mcp-server-$VERSION.zip" "$TMP_DIST/dist"
161
+
162
+ echo "> Beginning notarization process (might take up to 20m)..."
163
+ xcrun notarytool submit "$TMP_DIST/apollo-mcp-server-$VERSION.zip" \
164
+ --apple-id "$APPLE_USERNAME" \
165
+ --password "$APPLE_NOTARIZATION_PASSWORD" \
166
+ --team-id "$APPLE_TEAM_ID" \
167
+ --wait \
168
+ --timeout 20m
169
+
170
+ echo "> Cleaning up release..."
171
+ rm -rf $TMP_DIST
172
+ done
173
+
174
+ echo "Cleaning up ephemeral keychain..."
175
+ rm -rf $EPHEMERAL_KEYCHAIN/
176
+
177
+ - name : Create release bundles
178
+ env :
179
+ VERSION : ${{ github.ref }}
180
+ run : |
181
+ mkdir artifacts
182
+ for RELEASE in release/*/; do
183
+ # Remove trailing slash and leading parent
184
+ RELEASE=${RELEASE%/}
185
+ RELEASE=${RELEASE#"release/"}
186
+
187
+ echo "Creating an artifact for $RELEASE"
188
+ tar -C release/$RELEASE -cf - dist/ | gzip -9 > artifacts/apollo-mcp-server-$VERSION-$RELEASE.tar.gz
189
+ done
51
190
52
191
- name : Upload release artifacts
53
192
uses : softprops/action-gh-release@v2
0 commit comments