-
Notifications
You must be signed in to change notification settings - Fork 9
/
publish-to-s3.cfm
84 lines (70 loc) · 2.63 KB
/
publish-to-s3.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<cfscript>
log = [ "## Publishing installers to S3" ];
function logger( message ){
systemOutput( arguments.message, true );
arrayAppend( log, arguments.message );
}
function writeoutMarkdown( log ){
fileWrite( server.system.environment.GITHUB_STEP_SUMMARY, ArrayToList( arguments.log, chr( 10 ) ) );
}
logger( "Publish Installers to s3, using #server.lucee.version#" );
logger( " - for installers for Lucee #server.system.environment.LUCEE_INSTALLER_VERSION# " );
version = server.system.environment.LUCEE_INSTALLER_VERSION;
currDir = getDirectoryFromPath( getCurrentTemplatePath() );
files = directoryList( path=currDir, listinfo="query" );
logger( "" );
loop query="files" {
if ( files.name contains ".exe" or files.name contains ".run" )
logger( files.name & " " & numberFormat( files.size / 1024 / 1024 ) );
}
// do we have the s3 extension?
s3ExtVersion = extensionList().filter( function(row){ return row.name contains "s3"; }).version;
if ( s3Extversion eq "" ){
logger( "ERROR! The S3 Extension isn't installed!" );
writeoutMarkdown( log );
return;
//throw "The S3 Extension isn't installed!"; // fatal
} else {
logger( "Using S3 Extension: #s3ExtVersion#" );
}
// check for S3 credentials
if ( isNull( server.system.environment.S3_ACCESS_ID_DOWNLOAD )
|| isNull( server.system.environment.S3_SECRET_KEY_DOWNLOAD ) ) {
logger( "no S3 credentials defined to upload to S3");
writeoutMarkdown( log );
return;
}
trg = {};
s3_bucket = "lucee-downloads";
trg.dir = "s3://#server.system.environment.S3_ACCESS_ID_DOWNLOAD#:#server.system.environment.S3_SECRET_KEY_DOWNLOAD#@/#s3_bucket#/";
logger( "Testing S3 Bucket Access" );
if ( !directoryExists( trg.dir ) ){
fail = "DirectoryExists failed for s3 bucket [#s3_bucket#]";
logger( fail );
writeoutMarkdown( log );
throw fail;
}
logger ("" );
if ( listLen( version, "-" ) gt 1 ){
logger( "Not publishing to S3, only stable releases are published" );
} else {
trg.linux = "lucee-#version#-linux-x64-installer.run";
trg.windows = "lucee-#version#-windows-x64-installer.exe";
loop list="windows,linux" item="os" {
if ( !fileExists( currDir & trg[ os ] )){
logger( trg[ os ] & " installer missing?" );
} else if ( fileExists( trg.dir & trg[ os ] ) ){
logger( trg[ os ] & " already on s3" );
logger ("https://cdn.lucee.org/#trg[os]#");
} else {
logger( trg[ os ] & " to be uploaded on s3" );
fileCopy( currDir & trg[os], trg.dir & trg[ os ] );
logger ("https://cdn.lucee.org/#trg[os]#");
logger ("-- was uploaded" );
}
logger ("" );
}
logger( "Publishing step complete!" );
}
writeoutMarkdown( log );
</cfscript>