11<cfscript >
22 // firstly, check are we even deploying to s3
3- if ( (server .system .environment .DO_DEPLOY ?: false ) eq false ){
4- SystemOutput ( " skip, DO_DEPLOY is false" , 1 ,1 );
5- return ;
6- }
3+ DO_DEPLOY = server .system .environment .DO_DEPLOY ?: false ;
4+
75 // secondly, do we have the s3 extension?
86 s3ExtVersion = extensionList ().filter ( function (row ){ return row .name contains " s3" ; }).version ;
97 if ( s3Extversion eq " " ){
108 SystemOutput ( " ERROR! The S3 Extension isn't installed!" , true );
11- return ;
9+ return ;
1210 // throw "The S3 Extension isn't installed!"; // fatal
1311 } else {
1412 SystemOutput ( " Using S3 Extension: #s3ExtVersion #" , true );
1715 // finally check for S3 credentials
1816 if ( isNull ( server .system .environment .S3_ACCESS_ID_DOWNLOAD )
1917 || isNull ( server .system .environment .S3_SECRET_KEY_DOWNLOAD ) ) {
20- SystemOutput ( " no S3 credentials defined to upload to S3" , 1 , 1 );
21- return ;
18+ if ( DO_DEPLOY ){
19+ SystemOutput ( " no S3 credentials defined to upload to S3" , 1 , 1 );
20+ return ;
21+ }
2222 // throw "no S3 credentials defined to upload to S3";
2323 // trg.dir = "";
2424 }
3939 throw " missing jar or .lco file" ;
4040 }
4141
42- s3_bucket = " lucee-downloads" ;
43- trg .dir = " s3://#server .system .environment .S3_ACCESS_ID_DOWNLOAD #:#server .system .environment .S3_SECRET_KEY_DOWNLOAD #@/#s3_bucket #/" ;
44-
4542 // test s3 access
46- SystemOutput ( " Testing S3 Bucket Access" , 1 , 1 );
47- if (! DirectoryExists ( trg .dir ) )
48- throw " DirectoryExists failed for s3 bucket [#s3_bucket #]" ; // it usually will throw an error, rather than even reach this throw, if it fails
49-
50- trg .jar = trg .dir & src .jarName ;
51- trg .core = trg .dir & src .coreName ;
43+ if ( DO_DEPLOY ) {
44+ s3_bucket = " lucee-downloads" ;
45+ trg .dir = " s3://#server .system .environment .S3_ACCESS_ID_DOWNLOAD #:#server .system .environment .S3_SECRET_KEY_DOWNLOAD #@/#s3_bucket #/" ;
46+ SystemOutput ( " Testing S3 Bucket Access" , 1 , 1 );
47+ if (! DirectoryExists ( trg .dir ) )
48+ throw " DirectoryExists failed for s3 bucket [#s3_bucket #]" ; // it usually will throw an error, rather than even reach this throw, if it fails
49+ }
5250
5351 // we only upload / publish artifacts once LDEV-3921
52+ if ( DO_DEPLOY ){
53+ trg .jar = trg .dir & src .jarName ;
54+ trg .core = trg .dir & src .coreName ;
5455
55- if ( fileExists ( trg .jar ) && fileExists ( trg .core ) ){
56- SystemOutput ( " Build artifacts have already been uploaded for this version, nothing to do" , 1 , 1 );
57- return ;
58- }
59-
60- // copy jar
61- SystemOutput ( " upload #src .jarName # to S3" ,1 ,1 );
62- if ( fileExists ( trg .jar ) )
63- fileDelete ( trg .jar );
64- fileCopy ( src .jar , trg .jar );
56+ if ( fileExists ( trg .jar ) && fileExists ( trg .core ) ){
57+ SystemOutput ( " Build artifacts have already been uploaded for this version, nothing to do" , 1 , 1 );
58+ return ;
59+ }
6560
66- // copy core
67- SystemOutput ( " upload #src .coreName # to S3" ,1 ,1 );
68- if ( fileExists ( trg .core ) )
69- fileDelete ( trg .core );
70- fileCopy ( src .core , trg .core );
61+ // copy jar
62+ SystemOutput ( " upload #src .jarName # to S3" ,1 ,1 );
63+ if ( fileExists ( trg .jar ) )
64+ fileDelete ( trg .jar );
65+ fileCopy ( src .jar , trg .jar );
66+
67+ // copy core
68+ SystemOutput ( " upload #src .coreName # to S3" ,1 ,1 );
69+ if ( fileExists ( trg .core ) )
70+ fileDelete ( trg .core );
71+ fileCopy ( src .core , trg .core );
72+ }
7173
74+ /*
7275 // create war
7376 src.warName = "lucee-" & src.version & ".war";
7477 src.war = src.dir & src.warName;
7578 trg.war = trg.dir & src.warName;
7679
77- /*
80+
7881 SystemOutput( "upload #src.warName# to S3",1,1 );
7982 zip action = "zip" file = src.war overwrite = true {
8083
9396 fileCopy( src.war,trg.war );
9497 */
9598
96- // Lucee light build (no extensions)
99+ // Lucee light build (no extensions)
97100 src .lightName = " lucee-light-" & src .version & " .jar" ;
98- SystemOutput ( " build and upload #src .lightName # to S3" ,1 ,1 );
99101 src .light = src .dir & src .lightName ;
100- trg .light = trg .dir & src .lightName ;
102+ if ( DO_DEPLOY )
103+ SystemOutput ( " build and upload #src .lightName # to S3" ,1 ,1 );
104+ else
105+ SystemOutput ( " build #src .light #" ,1 ,1 );
106+
107+
101108 createLight ( src .jar ,src .light ,src .version , false );
102- fileCopy ( src .light ,trg .light );
109+ if ( DO_DEPLOY ){
110+ trg .light = trg .dir & src .lightName ;
111+ fileCopy ( src .light , trg .light );
112+ }
103113
104114 // Lucee zero build, built from light but also no admin or docs
105115 src .zeroName = " lucee-zero-" & src .version & " .jar" ;
106- SystemOutput ( " build and upload #src .zeroName # to S3" ,1 ,1 );
107116 src .zero = src .dir & src .zeroName ;
108- trg .zero = trg .dir & src .zeroName ;
117+ if ( DO_DEPLOY )
118+ SystemOutput ( " build and upload #src .zeroName # to S3" ,1 ,1 );
119+ else
120+ SystemOutput ( " build #src .zero #" ,1 ,1 );
121+
109122 createLight ( src .light , src .zero ,src .version , true );
110- fileCopy ( src .zero , trg .zero );
123+ if ( DO_DEPLOY ) {
124+ trg .zero = trg .dir & src .zeroName ;
125+ fileCopy ( src .zero , trg .zero );
126+ }
127+
111128
129+ if ( ! DO_DEPLOY ){
130+ SystemOutput ( " skipping build triggers, DO_DEPLOY is false" , 1 ,1 );
131+ return ;
132+ }
112133 // update provider
113134
114135 systemOutput (" Trigger builds" , true );
135156 http url = " https://api.github.com/repos/Ortus-Lucee/forgebox-cfengine-publisher/dispatches" method = " POST" result = " result" timeout = " 90" {
136157 httpparam type = " header" name = ' authorization' value = ' Bearer #gha_pat_token #' ;
137158 httpparam type = " body" value = ' #body .toJson () #' ;
138-
159+
139160 }
140161 systemOutput (" Forgebox build triggered, #result .statuscode # (always returns a 204 no content, see https://github.com/Ortus-Lucee/forgebox-cfengine-publisher/actions for output)" , true );
141162 } catch (e ){
142163 systemOutput (" Forgebox build ERRORED?" , true );
143164 echo (e );
144165 }
145-
166+
146167 // Lucee Docker builds
147168
148169 systemOutput (" Trigger Lucee Docker builds" , true );
149170
150171 gha_pat_token = server .system .environment .LUCEE_DOCKER_FILES_PAT_TOKEN ; // github person action token
151172 body = {
152- " event_type" : " build-docker-images" ,
153- " client_payload" : {
173+ " event_type" : " build-docker-images" ,
174+ " client_payload" : {
154175 " LUCEE_VERSION" : server .system .properties .luceeVersion
155- }
176+ }
156177 };
157178 try {
158179 http url = " https://api.github.com/repos/lucee/lucee-dockerfiles/dispatches" method = " POST" result = " result" timeout = " 90" {
172193 var tmpDir = getTempDirectory ();
173194
174195 local .tmpLoader = tmpDir & " lucee-loader-" & createUniqueId ( ); // the jar
175- if ( directoryExists ( tmpLoader ) )
196+ if ( directoryExists ( tmpLoader ) )
176197 directoryDelete ( tmpLoader ,true );
177198 directoryCreate ( tmpLoader );
178199
203224 var manifest = tmpCore & sep & " META-INF" & sep & " MANIFEST.MF" ;
204225 var content = fileRead ( manifest );
205226 var index = find ( ' Require-Extension' ,content );
206- if ( index > 0 )
227+ if ( index > 0 )
207228 content = mid ( content , 1 , index - 1 ) & variables .NL ;
208229 fileWrite ( manifest ,content );
209-
230+
210231 // zip core
211232 fileDelete ( lcoFile );
212233 zip action = " zip" source = tmpCore file = lcoFile ;
213-
234+
214235 // zip loader
215- if ( fileExists ( trg ) )
236+ if ( fileExists ( trg ) )
216237 fileDelete ( trg );
217238 zip action = " zip" source = tmpLoader file = trg ;
218-
239+
219240 }
220241 </cfscript >
0 commit comments