Skip to content

Commit 17b1c95

Browse files
authored
Certify mac os binary (#75)
* Add mac os signing of mac os
1 parent 8ce4aaa commit 17b1c95

File tree

4 files changed

+170
-51
lines changed

4 files changed

+170
-51
lines changed

.github/workflows/pull_request_check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
if: matrix.os == 'windows-latest'
9292
uses: actions/upload-artifact@v4
9393
with:
94-
name: aspect-model-editor-vDEV-SNAPSHOT-win
94+
name: ame-backend-win
9595
path: |
9696
aspect-model-editor-runtime/target/ame-backend-DEV-SNAPSHOT-win.exe
9797
aspect-model-editor-runtime/target/*.dll
@@ -102,7 +102,7 @@ jobs:
102102
if: matrix.os == 'ubuntu-20.04'
103103
uses: actions/upload-artifact@v4
104104
with:
105-
name: ame-backend-${{ matrix.os }}
105+
name: ame-backend-linux
106106
path: |
107107
aspect-model-editor-runtime/target/ame-backend-DEV-SNAPSHOT-linux
108108
aspect-model-editor-runtime/target/*.so
@@ -111,5 +111,5 @@ jobs:
111111
if: matrix.os == 'macos-12'
112112
uses: actions/upload-artifact@v4
113113
with:
114-
name: ame-backend-${{ matrix.os }}
114+
name: ame-backend-mac
115115
path: aspect-model-editor-runtime/target/ame-backend-DEV-SNAPSHOT-mac

.github/workflows/tagged_release.yml

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99

1010
jobs:
11-
gh_tagged_release:
11+
build:
1212
name: Create tagged release
1313
runs-on: ${{ matrix.os }}
1414
strategy:
@@ -126,29 +126,21 @@ jobs:
126126
aspect-model-editor-runtime/target/*.bat
127127
aspect-model-editor-runtime/target/lib/
128128
129-
# Release Mac and Linux executables
130-
- name: Create GitHub release (Mac)
131-
if: ${{ (matrix.os == 'macos-12') && (!contains( github.ref, '-M' )) }}
132-
uses: svenstaro/upload-release-action@latest
129+
- name: Upload binary (Mac)
130+
if: matrix.os == 'macos-12'
131+
uses: actions/upload-artifact@v4
133132
with:
134-
file_glob: true
135-
overwrite: true
136-
prerelease: false
137-
repo_token: ${{ secrets.GITHUB_TOKEN }}
138-
file: aspect-model-editor-runtime/target/ame-backend!(*.txt)-mac
139-
tag: v${{ github.event.inputs.release_version }}
133+
name: ame-backend-v${{ github.event.inputs.release_version }}-mac
134+
path: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-mac
140135

141-
- name: Create GitHub pre-release (Mac)
142-
if: ${{ (matrix.os == 'macos-12') && (contains( github.ref, '-M' )) }}
143-
uses: svenstaro/upload-release-action@latest
136+
- name: Upload binary (Linux)
137+
if: matrix.os == 'ubuntu-20.04'
138+
uses: actions/upload-artifact@v4
144139
with:
145-
file_glob: true
146-
overwrite: true
147-
prerelease: true
148-
repo_token: ${{ secrets.GITHUB_TOKEN }}
149-
file: aspect-model-editor-runtime/target/ame-backend!(*.txt)-mac
150-
tag: v${{ github.event.inputs.release_version }}
140+
name: ame-backend-v${{ github.event.inputs.release_version }}-linux
141+
path: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-linux
151142

143+
# Release Linux executables
152144
- name: Create GitHub release (Linux)
153145
if: ${{ (matrix.os == 'ubuntu-20.04') && (!contains( github.ref, '-M' )) }}
154146
uses: svenstaro/upload-release-action@latest
@@ -157,7 +149,7 @@ jobs:
157149
overwrite: true
158150
prerelease: false
159151
repo_token: ${{ secrets.GITHUB_TOKEN }}
160-
file: aspect-model-editor-runtime/target/ame-backend!(*.txt)-linux
152+
file: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-linux
161153
tag: v${{ github.event.inputs.release_version }}
162154

163155
- name: Create GitHub pre-release (Linux)
@@ -168,54 +160,56 @@ jobs:
168160
overwrite: true
169161
prerelease: true
170162
repo_token: ${{ secrets.GITHUB_TOKEN }}
171-
file: aspect-model-editor-runtime/target/ame-backend!(*.txt)-linux
163+
file: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-linux
172164
tag: v${{ github.event.inputs.release_version }}
173165

174-
- name: Setup Git
175-
run: |
176-
git config user.name github-actions
177-
git config user.email [email protected]
166+
release:
167+
needs: build
168+
runs-on: ubuntu-latest
169+
steps:
170+
- name: Checkout project
171+
uses: actions/checkout@v3
178172

179-
# Sign Windows executable
180-
- name: Get Artifact ID (Windows)
181-
if: matrix.os == 'windows-latest'
173+
# Sign (Windows & Mac) executable
174+
- name: Get Artifact ID (Windows & Mac)
182175
shell: bash
183176
run: |
184177
# Get the list of artifacts for the specified workflow run
185178
response=$(curl -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${{ github.repository_owner }}/$(echo '${{ github.repository }}' | cut -d'/' -f2)/actions/runs/${{ github.run_id }}/artifacts")
186179
187-
# Filter out the ID of the artifact with a name that contains "windows"
188-
artifact_id=$(echo "$response" | jq -r '.artifacts[] | select(.name | contains("win")) | .id')
180+
# Filter out the ID of the artifacts
181+
artifact_id_win=$(echo "$response" | jq -r '.artifacts[] | select(.name | contains("win")) | .id')
182+
artifact_id_mac=$(echo "$response" | jq -r '.artifacts[] | select(.name | contains("mac")) | .id')
189183
190184
# Save the artifact ID in an environment variable
191-
echo "ARTIFACT_ID=$artifact_id" >> $GITHUB_ENV
185+
echo "ARTIFACT_ID_WIN=$artifact_id_win" >> $GITHUB_ENV
186+
echo "ARTIFACT_ID_MAC=$artifact_id_mac" >> $GITHUB_ENV
192187
env:
193188
TOKEN: ${{ secrets.GITHUB_TOKEN }}
194189

195-
- name: Commit Artifact url and version changes and push to pre release branch for jenkins (Windows)
196-
if: matrix.os == 'windows-latest'
190+
- name: Commit Artifact url and version changes and push to pre release branch for jenkins (Windows & Mac)
197191
shell: bash
198192
run: |
199-
ARTIFACT_URL_WIN="https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/actions/artifacts/$ARTIFACT_ID/zip"
193+
ARTIFACT_URL_WIN="https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/actions/artifacts/$ARTIFACT_ID_WIN/zip"
194+
ARTIFACT_URL_MAC="https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/actions/artifacts/$ARTIFACT_ID_MAC/zip"
200195
BRANCH_NAME="pre_release_configuration"
201196
202197
echo "artifact_url_win=$ARTIFACT_URL_WIN" > parameters.txt
198+
echo "artifact_url_mac=$ARTIFACT_URL_MAC" >> parameters.txt
203199
echo "version=${{ github.event.inputs.release_version }}" >> parameters.txt
204200
205201
git config --global user.email "[email protected]"
206202
git config --global user.name "github-actions"
207203
git checkout -b $BRANCH_NAME
208204
git add parameters.txt
209-
git commit -m "Add parameters.txt with artifact_url_win and version"
205+
git commit -m "Add parameters.txt with artifact_url_win, artifact_url_mac and version"
210206
git push origin $BRANCH_NAME
211207
env:
212208
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
213209

214210
- name: Trigger Jenkins Job, for signing executable
215-
if: matrix.os == 'windows-latest'
216211
shell: bash
217212
run: |
218213
DATA='{"repository": {"url": "https://github.com/eclipse-esmf/esmf-aspect-model-editor-backend", "html_url": "https://github.com/eclipse-esmf/esmf-aspect-model-editor-backend", "owner": { "name": "ESMF"}}, "pusher": { "name": "GitHub Action", "email": "[email protected]"}}'
219214
SHA1="$(echo -n "${DATA}" | openssl dgst -sha1 -hmac "${WEBHOOK_SECRET}" | sed 's/SHA1(stdin)= //')"
220215
curl -X POST https://ci.eclipse.org/esmf/github-webhook/ -H "Content-Type: application/json" -H "X-GitHub-Event: push" -H "X-Hub-Signature: sha1=${SHA1}" -d "${DATA}"
221-

.jenkins/Jenkinsfile

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.json.JsonSlurper;
2+
13
pipeline {
24
agent any
35

@@ -24,7 +26,8 @@ pipeline {
2426
}
2527
}
2628

27-
echo "Artifact URL: ${env.artifact_url_win}"
29+
echo "Artifact URL Win: ${env.artifact_url_win}"
30+
echo "Artifact URL Mac: ${env.artifact_url_mac}"
2831
echo "Version: ${env.version}"
2932
} else {
3033
echo "Error: parameters.txt does not exist."
@@ -33,37 +36,98 @@ pipeline {
3336
}
3437
}
3538

36-
stage('Download and unpack artifact') {
39+
stage('Download and unpack Windows artifact') {
3740
steps {
3841
script {
42+
def winOsFile = "ame-backend-v${env.version}-win.zip"
3943
sh "curl -L -H 'Accept: application/vnd.github.v3+json' \
4044
-H 'Authorization: Bearer ${GITHUB_BOT_TOKEN}' \
4145
'${env.artifact_url_win}' \
42-
--output 'aspect-model-editor-v${env.version}-win.zip'"
46+
--output '${winOsFile}'"
4347
sh "mkdir -p unpack_dir"
44-
sh "unzip -o aspect-model-editor-v${env.version}-win.zip -d unpack_dir"
48+
sh "unzip -o ame-backend-v${env.version}-win.zip -d unpack_dir"
49+
sh "rm '${winOsFile}'"
4550
sh "ls -a unpack_dir"
4651
}
4752
}
4853
}
4954

50-
stage('Sign Applications') {
55+
stage('Sign Windows Applications') {
5156
steps {
5257
script {
5358
sh "mkdir -p signed_dir"
5459
sh "find unpack_dir -name '*.dll' -exec mv {} signed_dir \\;"
5560
sh "curl -o signed_dir/ame-backend-${env.version}-win.exe -F file=@unpack_dir/ame-backend-${env.version}-win.exe https://cbi.eclipse.org/authenticode/sign"
56-
sh "zip -r aspect-model-editor-v${env.version}-win-signed.zip signed_dir"
61+
sh "zip -r ame-backend-v${env.version}-win.zip signed_dir"
62+
sh "ls -a signed_dir"
63+
}
64+
}
65+
}
66+
67+
stage('Download Mac artifact') {
68+
steps {
69+
script {
70+
def macOsFile = "ame-backend-v${env.version}-mac.zip"
71+
sh "curl -L -H 'Accept: application/vnd.github.v3+json' \
72+
-H 'Authorization: Bearer ${GITHUB_BOT_TOKEN}' \
73+
'${env.artifact_url_mac}' \
74+
--output '${macOsFile}'"
75+
sh "unzip -o ame-backend-v${env.version}-mac.zip -d unpack_dir"
76+
sh "rm '${macOsFile}'"
77+
sh "ls -a unpack_dir"
78+
}
79+
}
80+
}
81+
82+
stage('Sign Mac Applications') {
83+
steps {
84+
script {
85+
sh "mkdir -p signed_dir"
86+
sh "curl -o signed_dir/ame-backend-${env.version}-mac -F file=@unpack_dir/ame-backend-${env.version}-mac -F [email protected] https://cbi.eclipse.org/macos/codesign/sign"
87+
sh "ls -a signed_dir"
88+
}
89+
}
90+
}
91+
92+
stage('MacOS Notarization') {
93+
steps {
94+
script {
95+
sh "zip -j ame-backend-${env.version}-mac.zip signed_dir/ame-backend-${env.version}-mac"
96+
97+
def macOsFile = "ame-backend-${env.version}-mac.zip"
98+
99+
def jsonOptions = "options={\"primaryBundleId\": \"org.eclipse.esmf\", \"staple\": true};type=application/json"
100+
def response = sh(script: "curl -X POST -F file=@${macOsFile} -F '${jsonOptions}' https://cbi.eclipse.org/macos/xcrun/notarize", returnStdout: true).trim()
101+
102+
def jsonSlurper = new JsonSlurper()
103+
def json = jsonSlurper.parseText(response)
104+
String uuid = json.uuid
105+
106+
while (json.notarizationStatus.status == 'IN_PROGRESS') {
107+
sleep(time: 1, unit: 'MINUTES')
108+
response = sh(script: "curl https://cbi.eclipse.org/macos/xcrun/${uuid}/status", returnStdout: true).trim()
109+
json = jsonSlurper.parseText(response)
110+
}
111+
112+
if (json.notarizationStatus.status != 'COMPLETE') {
113+
echo "Notarization failed: ${response}"
114+
error("Notarization failed.")
115+
}
116+
117+
sh "rm '${macOsFile}'"
118+
119+
sh "curl -JO -o ame-backend-v${env.version}-mac.zip https://cbi.eclipse.org/macos/xcrun/${uuid}/download"
57120
}
58121
}
59122
}
60123

61-
stage('Release signed WINDOWS artifact to GitHub Releases') {
124+
stage('Release signed Windows and Mac artifact to GitHub Releases') {
62125
steps {
63126
script {
64127
def repo = "eclipse-esmf/esmf-aspect-model-editor-backend"
65128
def tagName = "v${env.version}"
66-
def fileName = "aspect-model-editor-v${env.version}-win-signed.zip"
129+
def fileNameWin = "ame-backend-v${env.version}-win.zip"
130+
def fileNameMac = "ame-backend-v${env.version}-mac.zip"
67131
def releaseId = ""
68132

69133
def tagExists = sh(script: """
@@ -99,8 +163,18 @@ pipeline {
99163
-H "Accept: application/vnd.github+json" \\
100164
-H "Authorization: Bearer \$GITHUB_BOT_TOKEN" \
101165
-H "Content-Type: application/octet-stream" \
102-
--data-binary @${fileName} \
103-
"https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${fileName}"
166+
--data-binary @${fileNameWin} \
167+
"https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${fileNameWin}"
168+
"""
169+
170+
sh """
171+
curl -L \
172+
-X POST \
173+
-H "Accept: application/vnd.github+json" \\
174+
-H "Authorization: Bearer \$GITHUB_BOT_TOKEN" \
175+
-H "Content-Type: application/octet-stream" \
176+
--data-binary @${fileNameMac} \
177+
"https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${fileNameMac}"
104178
"""
105179

106180
sh """

entitlements.plist

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<!-- Allow JIT (Just In Time) compilation -->
6+
<key>com.apple.security.cs.allow-jit</key>
7+
<true/>
8+
9+
<!-- Allow unsigned executable memory -->
10+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
11+
<true/>
12+
13+
<!-- Allow DYLD environment variables -->
14+
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
15+
<true/>
16+
17+
<!-- Disable Library Validation -->
18+
<key>com.apple.security.cs.disable-library-validation</key>
19+
<true/>
20+
21+
<!-- Debugging entitlements (remove in production) -->
22+
<key>com.apple.security.get-task-allow</key>
23+
<true/>
24+
25+
<!-- Networking entitlements -->
26+
<key>com.apple.security.network.client</key>
27+
<true/>
28+
<key>com.apple.security.network.server</key>
29+
<true/>
30+
31+
<!-- File Access entitlements -->
32+
<key>com.apple.security.files.user-selected.read-write</key>
33+
<true/>
34+
<key>com.apple.security.files.downloads.read-write</key>
35+
<true/>
36+
<key>com.apple.security.files.all.read-write</key>
37+
<true/>
38+
39+
<!-- Enable audio input -->
40+
<key>com.apple.security.device.audio-input</key>
41+
<false/>
42+
43+
<!-- Enable camera input -->
44+
<key>com.apple.security.device.camera</key>
45+
<false/>
46+
47+
<!-- Access to location services -->
48+
<key>com.apple.security.personal-information.location</key>
49+
<false/>
50+
</dict>
51+
</plist>

0 commit comments

Comments
 (0)