Skip to content

Commit

Permalink
LDEV-4845 download latest java and tomcat automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jul 19, 2024
1 parent da94b5f commit 3a8ef57
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 51 deletions.
80 changes: 29 additions & 51 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,18 @@ on:
LUCEE_VERSION:
required: true
type: string
DRY_RUN:
required: false
default: false
type: boolean
repository_dispatch:
types: [build-installers]

env:
LUCEE_VERSION: ${{ github.event.inputs.LUCEE_VERSION }}
JRE_LINUX_URL: https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%2B8/OpenJDK11U-jre_x64_linux_hotspot_11.0.24_8.tar.gz
JRE_LINUX_NAME: OpenJDK11U-jre_x64_linux_hotspot_11.0.24_8.tar.gz
JRE_LINUX_DIR: jdk-11.0.24+8-jre
JRE_WIN_URL: https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.24%2B8/OpenJDK11U-jre_x64_windows_hotspot_11.0.24_8.zip
JRE_WIN_NAME: OpenJDK11U-jre_x64_windows_hotspot_11.0.24_8.zip
JRE_WIN_DIR: jdk-11.0.24+8-jre
TOMCAT_LINUX_URL: https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.91/bin/apache-tomcat-9.0.91.tar.gz
TOMCAT_LINUX_NAME: apache-tomcat-9.0.91.tar.gz
TOMCAT_WIN_URL: https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.91/bin/apache-tomcat-9.0.91-windows-x64.zip
TOMCAT_WIN_NAME: apache-tomcat-9.0.91.zip
TOMCAT_DIR: apache-tomcat-9.0.91
IB_URL: https://releases.installbuilder.com/installbuilder/installbuilder-enterprise-24.3.0-linux-x64-installer.run
IB_NAME: installbuilder-enterprise-24.3.0-linux-x64-installer.run
lucee_build_version: 6.0.3.1

jobs:
build-installers:
Expand Down Expand Up @@ -59,61 +53,45 @@ jobs:
pwd
ls -l
mv lucee-${{ env.LUCEE_VERSION }}.jar lucee/lucee/lib/
- name: Download JRE Linux
run: |
mkdir linux_jre
cd linux_jre
curl "${{ env.JRE_LINUX_URL }}" -o ${{ env.JRE_LINUX_NAME }} -L
tar zxf ${{ env.JRE_LINUX_NAME }}
ls -l
cp -r ${{ env.JRE_LINUX_DIR }}/* ../jre/jre64-lin/jre/
rm -rf ${{ env.JRE_LINUX_DIR }}
- name: Download JRE Windows
run: |
mkdir win_jre
cd win_jre
curl "${{ env.JRE_WIN_URL }}" -o ${{ env.JRE_WIN_NAME }} -L
unzip ${{ env.JRE_WIN_NAME }}
ls -l
cp -r ${{ env.JRE_WIN_DIR }}/* ../jre/jre64-win/jre/
rm -rf ${{ env.JRE_WIN_DIR }}
- name: Download and prepare Tomcat Linux
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: lucee-script-runner-maven-cache

- name: Download latest Tomcat and Java
uses: lucee/script-runner@main
with:
webroot: ${{ github.workspace }}/
execute: /download-latest-java-tomcat.cfm
luceeVersion: ${{ env.lucee_build_version }}

- name: Prepare Tomcat Linux
run: |
pwd
curl ${{ env.TOMCAT_LINUX_URL }} -o ${{ env.TOMCAT_LINUX_NAME }} -s
ls -l
cd lucee/tomcat9/
rm -rf tomcat
rm -rfv ${{ env.TOMCAT_DIR }}
ls -l
tar zxf ../../${{ env.TOMCAT_LINUX_NAME }}
cd ../..
pwd
mv lucee/tomcat9/${{ env.TOMCAT_DIR }} lucee/tomcat9/tomcat
rm -rf lucee/tomcat9/tomcat/webapps
mv src-tomcat/linux lucee/tomcat9/tomcat
cp -ar lucee/tomcat9/tomcat-lucee-conf/* lucee/tomcat9/tomcat
- name: Build Lucee Installer - Linux x64
run: |
cd lucee
/tmp/ib/bin/builder build lucee.xml linux-x64 --verbose --license license.xml
- name: Download and prepare Tomcat Windows
- name: Prepare Tomcat Windows
run: |
pwd
curl ${{ env.TOMCAT_WIN_URL }} -o ${{ env.TOMCAT_WIN_NAME }} -s
ls -l
cd lucee/tomcat9/
rm -rfv tomcat
rm -rfv ${{ env.TOMCAT_DIR }}
unzip ../../${{ env.TOMCAT_WIN_NAME }}
cd ../..
pwd
mv lucee/tomcat9/${{ env.TOMCAT_DIR }} lucee/tomcat9/tomcat
rm -rf lucee/tomcat9/tomcat/webapps
mv src-tomcat/windows lucee/tomcat9/tomcat
cp -ar lucee/tomcat9/tomcat-lucee-conf/* lucee/tomcat9/tomcat
- name: Build Lucee Installer - Windows x64
run: |
cd lucee
/tmp/ib/bin/builder build lucee.xml windows-x64 --verbose --license license.xml
- name: check linux installer has correct version
run: |
ls -laht /tmp/ib/output/
Expand All @@ -139,6 +117,7 @@ jobs:
path: /tmp/ib/output/*.exe
retention-days: 1
compression-level: 0

test-linux:
runs-on: ubuntu-latest
needs: build-installers
Expand Down Expand Up @@ -201,8 +180,8 @@ jobs:
publish-to-s3:
runs-on: ubuntu-latest
needs: [ test-windows, test-linux, build-installers ]
if: ${{ github.event.inputs.DRY_RUN != true }}
env:
luceeVersion: 6.0.0.585
S3_ACCESS_ID_DOWNLOAD: ${{ secrets.S3_ACCESS_ID_DOWNLOAD }}
S3_SECRET_KEY_DOWNLOAD: ${{ secrets.S3_SECRET_KEY_DOWNLOAD }}
steps:
Expand All @@ -220,11 +199,10 @@ jobs:
with:
path: ~/.m2
key: lucee-script-runner-maven-cache

- name: Publish Installers to S3
uses: lucee/script-runner@main
with:
webroot: ${{ github.workspace }}/
execute: /publish-to-s3.cfm
luceeVersion: ${{ env.luceeVersion }}
extensions:
extensionDir:
luceeVersion: ${{ env.lucee_build_version }}
155 changes: 155 additions & 0 deletions download-latest-java-tomcat.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<cfscript>
tmpDir = getDirectoryFromPath(getCurrentTemplatePath()) & "tmp-installer/";
log = [];
srcVersion = listToArray( server.system.environment.lucee_version, "." );
version = listToArray( srcVersion,"." );
dump(version);
flush;
tomcat_version = "9.0";
java_version = 11;
if ( version[ 1 ] gt 6 ||
(version[ 1 ] gte 6 && version[ 2 ] gte 1 )){
java_version = 21;
}
if ( version[ 1 ] gt 6 ||
(version[ 1 ] gte 6 && version[ 2 ] gte 2 )){
tomcat_version = "10.1";
}
logger("Using Java version #java_version# for Lucee #srcVersion#");
logger("Using Tomcat version #tomcat_version# for Lucee #srcVersion#");
tomcat = getTomcatVersion( tomcat_version );
java = getJavaVersion( java_version );
dump(java);
dump(tomcat);
extractArchive( "zip", java.windows.archive , "jre/jre64-win/jre/" );
extractArchive( "tgz", java.linux.archive , "jre/jre64-lin/jre/" );
extractArchive( "zip", tomcat.windows.archive , "src-tomcat/windows/" );
extractArchive( "tgz", tomcat.linux.archive , "src-tomcat/linux/" );
directoryDelete( "src-tomcat/linux/webapps", true );
directoryDelete( "src-tomcat/windows/webapps", true );
dump( log );
function extractArchive( format, src, dest ){
arguments.dest = getDirectoryFromPath(getCurrentTemplatePath()) & "tmp-installer/" & arguments.dest;
var tmpDest = getTempDirectory() & "tmp-installer-" & createUUID() & "/";
if ( directoryExists( tmpDest ) )
directoryDelete( tmpDest );
directoryCreate( tmpdest );
logger(" extracting [#arguments.src# ] into [#arguments.dest#]" );
extract( arguments.format, arguments.src, tmpDest );
var files = directoryList(tmpDest, true);
if ( directoryExists( arguments.dest ) )
directoryDelete( arguments.dest, true );
logger("copying [#files[ 1 ]# ] into [#arguments.dest#]" );
directoryCopy( files[ 1 ], arguments.dest, true );
directoryDelete( tmpDest, true );
}
function getTomcatVersion( required string version ){
var tomcat_metadata = "https://repo1.maven.org/maven2/org/apache/tomcat/embed/tomcat-embed-core/maven-metadata.xml"
http method="get" url=tomcat_metadata;
var releases = xmlParse(cfhttp.filecontent);
var srcVersions = XmlSearch(releases,"/metadata/versioning/versions/");
var versions = [];
for (var v in srcVersions[1].xmlChildren ) {
// ignore the m3 type versions
if ( Find( arguments.version, v.xmlText) ==1
&& listLen(v.xmlText, "." ) eq 3
&& isNumeric( listLast( v.xmlText, "." ) ) ) {
arrayAppend( versions, listLast( v.xmlText, "." ) );
}
}
if ( ArrayLen (versions ) ==0 )
throw "no versions found matching [#arguments.version#]";
ArraySort( versions, "numeric", "desc" );
var latest_version = arguments.version & "." & versions[ 1 ];
var baseUrl = "https://dlcdn.apache.org/tomcat/tomcat-#listFirst(arguments.version,".")#/v#latest_version#/bin/";
var tomcat = {
"windows": {
"url": baseUrl & "apache-tomcat-" & latest_version & ".zip",
},
"linux": {
"url": baseUrl & "apache-tomcat-" & latest_version & ".tar.gz",
}
};
for ( var os in tomcat ){
var download_url = tomcat[os].url;
var filename = listLast( download_url, "/" );
http method="get" url=download_url path=getTempDirectory() file=filename;
var info = fileInfo(getTempDirectory() & filename);
logger("downloaded [#info.path#], #numberformat(int(info.size/1024/1024))# Mb");
tomcat[os]["archive"] = info.path;
}
return tomcat;
}
function getJavaVersion( required string version ){
var java = {
"windows": {
"api": "https://api.adoptium.net/v3/assets/latest/#java_version#/hotspot?architecture=x64&os=windows&vendor=eclipse"
},
"linux": {
"api": "https://api.adoptium.net/v3/assets/latest/#java_version#/hotspot?architecture=x64&os=linux&vendor=eclipse"
}
}
for ( os in java ){
http method="get" url=java[os].api;
java[os]["url"] = getJava( cfhttp.filecontent, "jre", "jdk");
var download_url = java[os].url;
var filename = listLast( download_url, "/" );
http method="get" url=download_url path=getTempDirectory() file=filename;
var info = fileInfo(getTempDirectory() & filename);
logger("downloaded [#info.path#], #numberformat(int(info.size/1024/1024))# Mb");
java[os]["archive"] = info.path;
}
return java;
}
function getJava( json, type, project ){
var releases = deserializeJSON( arguments.json );
for ( var r in releases ){
if ( isStruct(r.binary)
&& r.binary.image_type == arguments.type
&& r.binary.project == arguments.project ) {
return r.binary.package.link;
}
}
throw (message="#arguments.type# and #arguments.project# not found?", detail=arguments.json)
}
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 ) ) );
}
// dump(log);
</cfscript>
3 changes: 3 additions & 0 deletions publish-to-s3.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
throw fail;
}
logger ("" );
throw "disabled for testing"!
if ( listLen( version, "-" ) gt 1 ){
logger( "Not publishing to S3, only stable releases are published" );
} else {
Expand Down

0 comments on commit 3a8ef57

Please sign in to comment.