Skip to content

Commit b75bcfb

Browse files
committed
try autobuild/sign
1 parent 927beb7 commit b75bcfb

7 files changed

Lines changed: 1595 additions & 1 deletion

File tree

Project/Sources/Classes/SystemWorkerProperties.4dm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ Function onData($systemworker : Object; $data : Object)
2222
// not needed for Curl
2323
// in Gdrive or Dropbox used when asking for Authentication
2424
This:C1470.data.text+=$data.data
25-
If ((This:C1470.type="gdrive") | (This:C1470.type="dropbox"))
25+
If ((This:C1470.type="gdrive") && (This:C1470.data.text="@Authentication@"))
26+
$systemworker.terminate()
27+
End if
28+
29+
If ((This:C1470.type="dropbox") && (This:C1470.data.text="@authorization@"))
2630
$systemworker.terminate()
2731
End if
2832

Project/Sources/Classes/_Build.4dm

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
Class constructor
2+
This:C1470._SettingsUsed:=""
3+
This:C1470._Source:=""
4+
5+
Function Compile($options : Object)->$error : Object
6+
If (Count parameters:C259>0)
7+
$error:=Compile project:C1760($options)
8+
Else
9+
$error:=Compile project:C1760
10+
End if
11+
12+
Function Build($PathToSettings : Text)->$error : Object
13+
If (Count parameters:C259>0)
14+
This:C1470._SettingsUsed:=$PathToSettings
15+
Else
16+
This:C1470._SettingsUsed:=File:C1566(Build application settings file:K5:60).platformPath
17+
End if
18+
BUILD APPLICATION:C871(This:C1470._SettingsUsed)
19+
20+
If (OK=0)
21+
$errortext:=File:C1566(Build application log file:K5:46).getText()
22+
$error:=New object:C1471("success"; False:C215; "log"; $errortext)
23+
Else
24+
$error:=New object:C1471("success"; True:C214)
25+
End if
26+
27+
Function Notarize($zipfilepath : Text; $appleUserID : Text; $bundleID)->$error : Object
28+
ASSERT:C1129($zipfilepath#""; "zip file path must not be empty")
29+
ASSERT:C1129($appleUserID#""; "apple ID must not be empty")
30+
ASSERT:C1129($bundleID#""; "bundle ID must not be empty")
31+
$in:=""
32+
$out:=""
33+
$err:=""
34+
$cmd:="xcrun altool --notarize-app --primary-bundle-id "+Char:C90(34)+$bundleID+Char:C90(34)+" --username "+Char:C90(34)+$appleUserID+Char:C90(34)+\
35+
" --password \"@keychain:altool\" --file "+Char:C90(34)+Convert path system to POSIX:C1106($zipfilepath)+Char:C90(34)
36+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
37+
If (($err#"") & ($err#"@CFURLRequestSetHTTPCookieStorageAcceptPolicy@"))
38+
$error:=New object:C1471("success"; False:C215; "log"; $err)
39+
Else
40+
If ($out="No errors@")
41+
$col:=Split string:C1554($out; Char:C90(10))
42+
If ($col[1]="RequestUUID = @")
43+
$error:=New object:C1471("success"; True:C214; "uuid"; Substring:C12($col[1]; Length:C16("RequestUUID = ")))
44+
Else
45+
$error:=New object:C1471("success"; False:C215; "log"; $out)
46+
End if
47+
Else
48+
$error:=New object:C1471("success"; False:C215; "log"; $out)
49+
End if
50+
End if
51+
52+
Function Zip($sourcepath : Text; $targetpath : Text)->$error : Object
53+
// if $sourcepath is ommitted, it reads path from settings, only for components on Mac
54+
If (Count parameters:C259=0)
55+
If (This:C1470._SettingsUsed#"")
56+
$settings:=File:C1566(This:C1470._SettingsUsed; fk platform path:K87:2).getText()
57+
$settingsXML:=DOM Parse XML variable:C720($settings)
58+
$Found:=DOM Find XML element:C864($settingsXML; "/Preferences4D/BuildApp/BuildMacDestFolder")
59+
If (ok=1)
60+
DOM GET XML ELEMENT VALUE:C731($Found; $value)
61+
Case of
62+
: ($value="::@")
63+
// cannot use Folder(fk database folder).parent, as we need to go outside of protected area
64+
$sourcefolder:=Folder:C1567(Get 4D folder:C485(Database folder:K5:14); fk platform path:K87:2)
65+
$sourcefolder:=Folder:C1567($sourcefolder.parent.platformPath+Substring:C12($value; 3)+Folder separator:K24:12+"Components"; fk platform path:K87:2)
66+
$sourcefolderfiles:=$sourcefolder.folders()
67+
If ($sourcefolderfiles.length>0)
68+
$source:=$sourcefolderfiles[0].platformPath
69+
End if
70+
: ($value=":@")
71+
$sourcefolder:=Folder:C1567(Folder:C1567(fk database folder:K87:14).platformPath+Substring:C12($value; 2)+"Components"; fk platform path:K87:2)
72+
$sourcefolderfiles:=$sourcefolder.folders()
73+
If ($sourcefolderfiles.length>0)
74+
$source:=$sourcefolderfiles[0].platformPath
75+
End if
76+
Else
77+
$source:=$value
78+
End case
79+
End if
80+
DOM CLOSE XML:C722($settingsXML)
81+
End if
82+
Else
83+
$source:=$sourcepath
84+
End if
85+
This:C1470._Source:=$source
86+
87+
If (Count parameters:C259<2)
88+
If (($source#"") & ($source="@.4dbase:"))
89+
$target:=Replace string:C233($source; ".4dbase:"; ".zip")
90+
End if
91+
Else
92+
$target:=$targetpath
93+
End if
94+
95+
// now we can finally zip
96+
If (($source#"") & ($target#""))
97+
If (Test path name:C476($target)=Is a document:K24:1)
98+
DELETE DOCUMENT:C159($target) // just to be sure that zip works and we can fetch errors
99+
End if
100+
$cmd:="/usr/bin/ditto -c -k --keepParent "+Char:C90(34)+Convert path system to POSIX:C1106($source)+Char:C90(34)+" "+Char:C90(34)+Convert path system to POSIX:C1106($target)+Char:C90(34)
101+
$in:=""
102+
$out:=""
103+
$err:=""
104+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
105+
106+
If ($err#"")
107+
$error:=New object:C1471("success"; False:C215; "reason"; "Zip error "+$err)
108+
Else
109+
$error:=New object:C1471("success"; True:C214; "target"; $target)
110+
End if
111+
Else
112+
$error:=New object:C1471("success"; False:C215; "reason"; "source or target path empty")
113+
End if
114+
115+
Function CheckNotarizeResult($uuid : Text; $appleUserID : Text)->$error : Object
116+
ASSERT:C1129($uuid#""; "uuid must not be empty")
117+
ASSERT:C1129($appleUserID#""; "userid must not be empty")
118+
119+
$cmd:="xcrun altool --notarization-info "+$uuid+" -u "+Char:C90(34)+$appleUserID+Char:C90(34)+" -p \"@keychain:altool\""
120+
$in:=""
121+
$out:=""
122+
$err:=""
123+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
124+
If (($err#"") & ($err#"@CFURLRequestSetHTTPCookieStorageAcceptPolicy@"))
125+
$error:=New object:C1471("success"; False:C215; "log"; "Notarize check: "+$err)
126+
Else
127+
/* out in form
128+
No errors getting notarization info.
129+
130+
Date: 2020-10-21 09:37:09 +0000
131+
Hash: dbc021eb12665fb13a9a18304214e89c9bb7560246a01b08f97dbae549697bfd
132+
LogFileURL: https://osxapps-ssl.itunes.apple.com/itunes-assets/Enigma124/v4/3f/84/9f/3f849f12-4cd5-0546-4181-a5d93c9cb074/developer_log.json?accessKey=1603467816_2930840265156000602_k5fSZxEZa3Cs89MYH3GfQYEpecMBF1ErZYK2rgbGgY0HoMPs1CgH5nlLAaYQRtEymMK6IsLkdXUgfL2FTG7IfYQe12Zj8wzuirYUB3rQXvfF6a6DrX%2BQxe6Wjc1DkD8kz14lR%2Bqk6VdfVGAOAsy%2B2%2FJ80DgIxv779wR14Jn2a40%3D
133+
RequestUUID: 7ee7da40-ef75-45f4-ba9d-6b8d61c29b67
134+
Status: invalid
135+
Status Code: 2
136+
Status Message: Package Invalid
137+
*/
138+
C_COLLECTION:C1488($lines; $parts)
139+
$lines:=Split string:C1554($out; Char:C90(10); sk trim spaces:K86:2+sk ignore empty strings:K86:1)
140+
$result:=New object:C1471
141+
For each ($line; $lines)
142+
$parts:=Split string:C1554($line; ":"; sk trim spaces:K86:2+sk ignore empty strings:K86:1)
143+
If ($parts.length=2)
144+
$result[$parts[0]]:=$parts[1]
145+
End if
146+
End for each
147+
148+
Case of
149+
: ($result.Status=Null:C1517)
150+
$error:=New object:C1471("success"; False:C215; "log"; "Notarize check error status missing "+$out)
151+
: ($result.Status="invalid")
152+
$error:=New object:C1471("success"; False:C215; "log"; "Notarize check error status invalid "+$out)
153+
: ($result.Status="in progress")
154+
$error:=New object:C1471("success"; True:C214; "status"; "in progress")
155+
: ($result.Status="success")
156+
$error:=New object:C1471("success"; True:C214; "status"; "success")
157+
End case
158+
End if
159+
160+
Function Staple($zipfilepath : Text; )->$error : Object
161+
$cmd:="xcrun stapler staple '"+Convert path system to POSIX:C1106($zipfilepath)+"'"
162+
$in:=""
163+
$out:=""
164+
$err:=""
165+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
166+
If (($err#"") & ($err#"@CFURLRequestSetHTTPCookieStorageAcceptPolicy@"))
167+
$error:=New object:C1471("success"; False:C215; "log"; "Staple error "+$out)
168+
Else
169+
$source:=This:C1470._Source
170+
$error:=This:C1470.Zip($source)
171+
End if
172+
173+
Function CommitAndPush($message : Text)->$error : Object
174+
$path:=Get 4D folder:C485(Database folder:K5:14; *)
175+
SET ENVIRONMENT VARIABLE:C812("_4D_OPTION_CURRENT_DIRECTORY"; $path)
176+
$in:=""
177+
$out:=""
178+
$err:=""
179+
LAUNCH EXTERNAL PROCESS:C811("git add --all"; $in; $out; $err)
180+
If (($out#"") | ($err#""))
181+
$error:=New object:C1471("success"; False:C215; "Error git add"; $out+" "+$err)
182+
Else
183+
SET ENVIRONMENT VARIABLE:C812("_4D_OPTION_CURRENT_DIRECTORY"; $path)
184+
$command:="git commit -a -q -m "+Char:C90(34)+$message+Char:C90(34)
185+
LAUNCH EXTERNAL PROCESS:C811($command; $in; $out; $err)
186+
If (($out#"") | ($err#""))
187+
$error:=New object:C1471("success"; False:C215; "Error git commit"; $out+" "+$err)
188+
Else
189+
SET ENVIRONMENT VARIABLE:C812("_4D_OPTION_CURRENT_DIRECTORY"; $path)
190+
LAUNCH EXTERNAL PROCESS:C811("git push"; $in; $out; $err)
191+
If ($err#"")
192+
$error:=New object:C1471("success"; False:C215; "Error git push"; $err)
193+
Else
194+
$error:=New object:C1471("success"; True:C214; "git commit"; $out)
195+
End if
196+
End if
197+
End if
198+
199+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//%attributes = {}
2+
//%attributes = {}
3+
/* internal method, only to build/update
4+
handles component build, notarize (needs to run on Mac) and upload to git
5+
6+
to use setup build application settings using dialog.requires to enter an Apple certificate
7+
certificate such as "Developer ID Application: Companyname (id)"
8+
follow https://blog.4d.com/how-to-notarize-your-merged-4d-application/
9+
10+
in case you have several xcode, select the 'good' one with
11+
###########
12+
sudo xcode-select -s /path/to/Xcode10.app
13+
Tested with XCode 12
14+
Run XCode at least once manual to make sure it is correctly installed and license is accepted.
15+
After an XCode/System update another manual run might be necesssary to accept modified license.
16+
17+
###########
18+
expects that you have installed your password in keychain named "altool" with:
19+
security add-generic-password -a "<apple_id>" -w "<password>" -s "altool"
20+
Sign in to your Apple ID account page. In the Security section, click the “Generate Password” option below the “App-Specific Passwords” option, enter a password label as requested and click the “Create” button.
21+
If unclear, read blog!
22+
23+
########### NOTES
24+
you might need to start Xcode once manually after every macOS update to accept Xcode changes
25+
you might need to start Xcode to accept Apple contract changes or update expired certificates (visit developer.apple.com)
26+
*/
27+
28+
$appleUserID:="Thomas.Maul"+Char:C90(64)+"4D.com" // I don't like my email on github in clear text
29+
$bundleID:="FileTransfer.de.4D.com"
30+
31+
var $builder : cs:C1710._Build
32+
33+
$builder:=cs:C1710._Build.new()
34+
35+
$progress:=Progress New
36+
Progress SET MESSAGE($progress; "Compile...")
37+
38+
$error:=$builder.Compile()
39+
If ($error.success=True:C214)
40+
Progress SET MESSAGE($progress; "Build...")
41+
$error:=$builder.Build()
42+
End if
43+
44+
If ($error.success=True:C214)
45+
Progress SET MESSAGE($progress; "Zip...")
46+
$error:=$builder.Zip()
47+
End if
48+
49+
If ($error.success=True:C214)
50+
$target:=$error.target
51+
Progress SET MESSAGE($progress; "Notarize...")
52+
$error:=$builder.Notarize($target; $appleUserID; $bundleID) // returned by zip
53+
End if
54+
55+
If ($error.success=True:C214)
56+
$UUID:=$error.uuid
57+
If ($uuid="")
58+
$error:=New object:C1471("success"; False:C215; "log"; "Notarize UUID empty")
59+
Else
60+
// now we need to wait - show progress bar?
61+
62+
$finished:=False:C215
63+
While ((Not:C34($finished)) & (Not:C34(Process aborted:C672)))
64+
Progress SET MESSAGE($progress; "Checking Notarization: "+String:C10(Current time:C178))
65+
DELAY PROCESS:C323(Current process:C322; 30*60) // check twice a minute
66+
$error:=$builder.CheckNotarizeResult($uuid; $appleUserID)
67+
Case of
68+
: ($error.success=False:C215)
69+
$finished:=True:C214
70+
: (($error.success=True:C214) & ($error.status="in progress"))
71+
// nothing, continue loop
72+
: (($error.success=True:C214) & ($error.status="success"))
73+
// finished! Now we can staple and rezip
74+
Progress SET MESSAGE($progress; "Success - now running staple")
75+
$error:=$builder.Staple($target)
76+
$finished:=True:C214
77+
End case
78+
End while
79+
End if
80+
End if
81+
82+
//If ($error.success=True)
83+
//Progress SET MESSAGE($progress; "Push to Git...")
84+
//$message:=Request("Commit message"; Timestamp)
85+
//$error:=$builder.CommitAndPush($message)
86+
//End if
87+
88+
Progress QUIT($progress)
89+
90+
91+
If ($error.success=False:C215)
92+
ALERT:C41(JSON Stringify:C1217($error; *))
93+
SET TEXT TO PASTEBOARD:C523(JSON Stringify:C1217($error; *))
94+
End if
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?><preferences stamp="2">
2+
<com.4d>
3+
<compiler>
4+
<options syntax_file="true"/>
5+
</compiler>
6+
<general component_classStore_name="FileTransfer"/>
7+
</com.4d>
8+
</preferences>

0 commit comments

Comments
 (0)