1
+ # This file incorporates work covered by the following copyright and permission notice:
2
+ #
3
+ # Copyright (c) Mikael Hermansson and Godot Jolt contributors.
4
+ # Copyright (c) Dragos Daian.
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ # this software and associated documentation files (the "Software"), to deal in
8
+ # the Software without restriction, including without limitation the rights to
9
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ # the Software, and to permit persons to whom the Software is furnished to do so,
11
+ # subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ name : GDExtension Sign
24
+ description : Sign Mac GDExtension
25
+
26
+ inputs :
27
+ FRAMEWORK_PATH :
28
+ description : The path of the artifact. Eg. bin/addons/my_addon/bin/libmy_addon.macos.template_release.universal.framework
29
+ required : true
30
+ SIGN_FLAGS :
31
+ description : The extra flags to use. Eg. --deep
32
+ required : false
33
+ APPLE_CERT_BASE64 :
34
+ required : true
35
+ description : Base64 file from p12 certificate.
36
+ APPLE_CERT_PASSWORD :
37
+ required : true
38
+ description : Password set when creating p12 certificate from .cer certificate.
39
+ APPLE_DEV_PASSWORD :
40
+ required : true
41
+ description : Apple App-Specific Password. Eg. abcd-abcd-abcd-abcd
42
+ APPLE_DEV_ID :
43
+ required : true
44
+ description : Email used for Apple Id. Eg. email@provider.com
45
+ APPLE_DEV_TEAM_ID :
46
+ required : true
47
+ description : Apple Team Id. Eg. 1ABCD23EFG
48
+ APPLE_DEV_APP_ID :
49
+ required : true
50
+ description : |
51
+ Certificate name from get info -> Common name . Eg. Developer ID Application: Common Name (1ABCD23EFG)
52
+ outputs :
53
+ zip_path :
54
+ value : ${{ steps.sign.outputs.path }}
55
+
56
+
57
+ runs :
58
+ using : composite
59
+ steps :
60
+ - name : Sign
61
+ id : sign
62
+ shell : pwsh
63
+ run : |
64
+ #!/usr/bin/env pwsh
65
+
66
+ # Copyright (c) Mikael Hermansson and Godot Jolt contributors.
67
+
68
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
69
+ # this software and associated documentation files (the "Software"), to deal in
70
+ # the Software without restriction, including without limitation the rights to
71
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
72
+ # the Software, and to permit persons to whom the Software is furnished to do so,
73
+ # subject to the following conditions:
74
+
75
+ # The above copyright notice and this permission notice shall be included in all
76
+ # copies or substantial portions of the Software.
77
+
78
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
79
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
80
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
81
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
82
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
83
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84
+
85
+ # Taken from https://github.com/godot-jolt/godot-jolt/blob/master/scripts/ci_sign_macos.ps1
86
+
87
+ Set-StrictMode -Version Latest
88
+ $ErrorActionPreference = "Stop"
89
+
90
+ $CodesignPath = Get-Command codesign | Resolve-Path
91
+
92
+ $CertificateBase64 = "${{inputs.APPLE_CERT_BASE64}}"
93
+ $CertificatePassword = "${{inputs.APPLE_CERT_PASSWORD}}"
94
+ $CertificatePath = [IO.Path]::ChangeExtension((New-TemporaryFile), "p12")
95
+
96
+ $Keychain = "ephemeral.keychain"
97
+ $KeychainPassword = (New-Guid).ToString().Replace("-", "")
98
+
99
+ $DevId = "${{ inputs.APPLE_DEV_ID }}"
100
+ $DevTeamId = "${{ inputs.APPLE_DEV_TEAM_ID }}"
101
+ $DevPassword = "${{ inputs.APPLE_DEV_PASSWORD }}"
102
+ $DeveloperIdApplication = "${{ inputs.APPLE_DEV_APP_ID }}"
103
+
104
+ if (!$CertificateBase64) { throw "No certificate provided" }
105
+ if (!$CertificatePassword) { throw "No certificate password provided" }
106
+ if (!$DevId) { throw "No Apple Developer ID provided" }
107
+ if (!$DeveloperIdApplication) { throw "No Apple Developer ID Application provided" }
108
+ if (!$DevTeamId) { throw "No Apple Team ID provided" }
109
+ if (!$DevPassword) { throw "No Apple Developer password provided" }
110
+
111
+ Write-Output "Decoding certificate..."
112
+
113
+ $Certificate = [Convert]::FromBase64String($CertificateBase64)
114
+
115
+ Write-Output "Writing certificate to disk..."
116
+
117
+ [IO.File]::WriteAllBytes($CertificatePath, $Certificate)
118
+
119
+ Write-Output "Creating keychain..."
120
+
121
+ security create-keychain -p $KeychainPassword $Keychain
122
+
123
+ Write-Output "Setting keychain as default..."
124
+
125
+ security default-keychain -s $Keychain
126
+
127
+ Write-Output "Importing certificate into keychain..."
128
+ security import $CertificatePath `
129
+ -k ~/Library/Keychains/$Keychain `
130
+ -P $CertificatePassword `
131
+ -T $CodesignPath
132
+ Write-Output "Check identities..."
133
+
134
+ security find-identity
135
+
136
+ Write-Output "Granting access to keychain..."
137
+
138
+ security set-key-partition-list -S "apple-tool:,apple:" -s -k $KeychainPassword $Keychain
139
+
140
+ $Framework = "${{ inputs.FRAMEWORK_PATH }}"
141
+ $SignFlags = "${{ inputs.SIGN_FLAGS }}"
142
+ $Archive = [IO.Path]::ChangeExtension((New-TemporaryFile), "zip")
143
+
144
+ Write-Output "Signing '$Framework'..."
145
+
146
+ & $CodesignPath --verify --timestamp --verbose "$SignFlags" --sign $DeveloperIdApplication "$Framework"
147
+
148
+ Write-Output "Verifying signing..."
149
+
150
+ & $CodesignPath --verify -dvvv "$Framework"
151
+
152
+ Get-ChildItem -Force -Recurse -Path "$Framework"
153
+
154
+ Write-Output "Archiving framework to '$Archive'..."
155
+
156
+ ditto -ck -rsrc --sequesterRsrc --keepParent "$Framework" "$Archive"
157
+
158
+ Write-Output "Submitting archive for notarization..."
159
+
160
+ $output = xcrun notarytool submit "$Archive" `
161
+ --apple-id $DevId `
162
+ --team-id $DevTeamId `
163
+ --password $DevPassword `
164
+ --wait
165
+ echo $output
166
+ $matches = $output -match '((\d|[a-z])+-(\d|[a-z])+-(\d|[a-z])+-(\d|[a-z])+-(\d|[a-z])+)'
167
+ if ($output) {
168
+ $id_res = $matches[0].Substring(6)
169
+ }
170
+ xcrun notarytool log $id_res `
171
+ --apple-id $DevId `
172
+ --team-id $DevTeamId `
173
+ --password $DevPassword `
174
+ developer_log.json
175
+ get-content developer_log.json
176
+
177
+ echo "path=$Archive" >> $env:GITHUB_OUTPUT
0 commit comments