From 82d1ce3a5dced0c55b10aca8220825f5a1d047a4 Mon Sep 17 00:00:00 2001 From: Joshua DeGeorge Date: Thu, 2 Jan 2025 12:18:42 -0800 Subject: [PATCH] Updating patch build process and adding to release deployment. Adjusted update bat script to clear dropins, lib, and pull patch from updated location. Added installer build instructions to README files. --- .github/workflows/build_installer.yaml | 13 +++ README.md | 51 ++++++++++ wrims-gui/README.md | 55 ++++++++++- wrims-gui/build.gradle | 96 +++++++++++-------- .../installer/WRIMS2_GUI_Update_and_Start.bat | 33 +++++++ 5 files changed, 207 insertions(+), 41 deletions(-) create mode 100644 wrims-gui/src/main/resources/installer/WRIMS2_GUI_Update_and_Start.bat diff --git a/.github/workflows/build_installer.yaml b/.github/workflows/build_installer.yaml index 03be22406..87cbef894 100644 --- a/.github/workflows/build_installer.yaml +++ b/.github/workflows/build_installer.yaml @@ -26,9 +26,22 @@ jobs: ./gradlew clean ./gradlew build ./gradlew :wrims-gui:zipWrimsGui + ./gradlew :wrims-gui:zipWrimsPatch - name: Attach WRIMS Installer zip to github deployment run: | gh release upload ${{ github.event.release.tag_name }} wrims-gui/build/installer/wrims_gui_x64_${{ github.event.release.tag_name }}.zip --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Attach WRIMS Patch zip to github deployment + run: | + gh release upload ${{ github.event.release.tag_name }} wrims-gui/build/patch/wrims_patch_v2.2.0_basis.zip --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Attach WRIMS Patch release date to github deployment + run: | + gh release upload ${{ github.event.release.tag_name }} wrims-gui/build/patch/releasedate_v2.2.0_basis.log --repo ${{ github.repository }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 142b45080..da862a68a 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,54 @@ The jar that's built from this branch (wrims-core) of the project does not conta antler classes. To run wrims using this jar, you'll need to include the antler runtime (v 3.5.2) in addition to the wrims-core jar to replace the old WRIMSv2.jar. +## How to build wrims installer From GitHub Releases +The installer and patch zip files are automatically generated when a new "Release" is created from +the github wrims site (https://github.com/CentralValleyModeling/wrims). + +1. From the github wrims home page (https://github.com/CentralValleyModeling/wrims/) click the "Releases" + link on the right hand side. Direct link: https://github.com/CentralValleyModeling/wrims/releases + +2. From the Releases page, select "Draft a new release" button at the top of the page. + Direct link: https://github.com/CentralValleyModeling/wrims/releases/new + +3. Click the "Choose a tag" drop down and type in a new tag name in the "Find or create new tag" field. + For an internal release, use a date stamp in the format of "YYYYMMDD" (e.g. 20241224). + +4. Click the "Target" branch drop down and select the branch you'd like to build the installer from. + +5. Click "Generate release notes" to automatically pull PR change logs into the release notes. + +6. Enter a title in the "Release Title" field. Typically, this matches the tag name. + +7. (OPTIONAL) Add any additional notes to the Description field + +8. If this is a non-production ready release, check the "Set as a pre-release" checkbox. + +9. Click "Publish Release" + +The installer and patch zip will be automatically generated and added to the new Release. + +## How to build the installer/patch zip files locally +The installer can be built by running the "zipWrimsGui" task in the wrims-gui module. +The patch can be built by running the "zipWrimsPatch" task in the wrims-gui module. + +The generated wrims install zip file will be located in the /wrims-gui/build/installer +folder. The installer file will be named: wrims_gui_x64_.zip + +The generated wrims patch zip file will be located in the /wrims-gui/build/patch +folder. The patch file will be named: wrims_patch_v2.2.0_basis.zip + +### From developer linux terminal: +You can build the installer and patch by running the following linux command from the root of the project: +``` +./gradlew :wrims-gui:zipWrimsGui +./gradlew :wrims-gui:zipWrimsPatch +``` + +### From developer windows command line / terminal: +You can build the installer and patch by running the following command from the root of the project: +``` +gradlew.bat :wrims-gui:zipWrimsGui +gradlew.bat :wrims-gui:zipWrimsPatch +``` + diff --git a/wrims-gui/README.md b/wrims-gui/README.md index 5962eb1a0..95ba20888 100644 --- a/wrims-gui/README.md +++ b/wrims-gui/README.md @@ -1,6 +1,59 @@ # WRIMS-GUI: The zipped distribuition builder for WRIMS-GUI -Given the outstanding limitations of the current Eclipse Luna (does not support build-ship), +NOTE: Given the outstanding limitations of the current Eclipse Luna (does not support build-ship), This gradle module uses an existing template copy of the WRIMS-GUI project to build a distributable zip file with the latest updated dropin jars and configuration file required to enable them. +## How to build the installer/patch zip files +The installer can be built by running the "zipWrimsGui" task in the wrims-gui module. +The patch can be built by running the "zipWrimsPatch" task in the wrims-gui module. + +The generated wrims install zip file will be located in the /wrims-gui/build/installer +folder. The installer file will be named: wrims_gui_x64_.zip + +The generated wrims patch zip file will be located in the /wrims-gui/build/patch +folder. The patch file will be named: wrims_patch_v2.2.0_basis.zip + +### From developer linux terminal: +You can build the installer and patch by running the following linux command from the root of the project: +``` +./gradlew :wrims-gui:zipWrimsGui +./gradlew :wrims-gui:zipWrimsPatch +``` + +### From developer windows command line / terminal: +You can build the installer and patch by running the following command from the root of the project: +``` +gradlew.bat :wrims-gui:zipWrimsGui +gradlew.bat :wrims-gui:zipWrimsPatch +``` + +### From GitHub Releases +The installer and patch zip files are automatically generated when a new "Release" is created from +the github wrims site (https://github.com/CentralValleyModeling/wrims). + +1. From the github wrims home page (https://github.com/CentralValleyModeling/wrims/) click the "Releases" +link on the right hand side. Direct link: https://github.com/CentralValleyModeling/wrims/releases + +2. From the Releases page, select "Draft a new release" button at the top of the page. +Direct link: https://github.com/CentralValleyModeling/wrims/releases/new + +3. Click the "Choose a tag" drop down and type in a new tag name in the "Find or create new tag" field. +For an internal release, use a date stamp in the format of "YYYYMMDD" (e.g. 20241224). + +4. Click the "Target" branch drop down and select the branch you'd like to build the installer from. + +5. Click "Generate release notes" to automatically pull PR change logs into the release notes. + +6. Enter a title in the "Release Title" field. Typically, this matches the tag name. + +7. (OPTIONAL) Add any additional notes to the Description field + +8. If this is a non-production ready release, check the "Set as a pre-release" checkbox. + +9. Click "Publish Release" + +The installer and patch zip will be automatically generated and added to the new Release. + + + diff --git a/wrims-gui/build.gradle b/wrims-gui/build.gradle index 59d51381b..30798616c 100644 --- a/wrims-gui/build.gradle +++ b/wrims-gui/build.gradle @@ -14,12 +14,22 @@ dependencies { def date = new Date() def formattedDate = date.format('yyyyMMdd') +def releaseDate = date.format('MM/dd/yyyy') def wrimsGuiFolder = "wrims_gui_x64_${version}" def wrimsGuiDownload = "${buildDir}/download/wrims2_gui_download.zip" +def wrimsPatchFolder = "wrims_patch_v2.2.0_basis" +def wrimsPatchReleaseDateFile = "releasedate_v2.2.0_basis.log" + +//task to unzip the contents of the third-party jar into a temp folder +tasks.register('unzipThirdPartyLibs', Copy) { + from(zipTree(project(':third-party').tasks.named('jar').get().archiveFile)) + into("${buildDir}/third-party") +} //download the latest WRIMS GUI installer from DWR tasks.register('downloadWrimsGuiInstaller', Download) { + dependsOn unzipThirdPartyLibs src 'https://data.cnra.ca.gov/dataset/0f6b03b4-7de8-4579-8aa0-60f73d9d21fb/resource/89f60e4a-c0c2-4ca2-acac-beb6bdb5d69e/download/wrims2_gui_x64_20240129.zip' dest new File(wrimsGuiDownload) onlyIfModified true @@ -96,16 +106,9 @@ tasks.register('copyWrimsCoreToLib', Copy) { into("${buildDir}/installer/${wrimsGuiFolder}/lib") } -//task to unzip the contents of the third-party jar into a temp folder -tasks.register('unzipThirdPartyJar', Copy) { - dependsOn copyWrimsCoreToLib - from(zipTree(project(':third-party').tasks.named('jar').get().archiveFile)) - into("${buildDir}/third-party") -} - //task to copy all files from ${buildDir}/third-party/lib_x64 to ${buildDir}/installer/${wrimsGuiFolder}/lib tasks.register('copyThirdPartyToLib', Copy) { - dependsOn unzipThirdPartyJar + dependsOn copyWrimsCoreToLib from("${buildDir}/third-party/lib_x64") from("${buildDir}/third-party/heclib") into("${buildDir}/installer/${wrimsGuiFolder}/lib") @@ -121,25 +124,18 @@ tasks.register('copyResources', Copy) { } } -/** - * Running the WRIMS2_GUI_Start.bat file will launch the WRIMS exe with a -clean argument that - * forces an update of some ecplise files and ensures the user can then run the WRIMS GUI - * with the updated packages using the WRIMS2GUI_x64.exe file going forward. - */ -tasks.register('runWrimsGui') { - dependsOn copyResources +//Add the release date to the installer +//generate a releasedate.log file that contains the current date in MM/DD/YYYY format +tasks.register('addReleaseDate', DefaultTask) { doLast { - def processBuilder = new ProcessBuilder('cmd', '/c', 'WRIMS2_GUI_Start.bat') - processBuilder.directory(new File("${buildDir}/installer/${wrimsGuiFolder}")) - def process = processBuilder.start() - Thread.sleep(60000) - def taskkill = new ProcessBuilder('cmd', '/c', 'taskkill', '/IM', 'WRIMS2_GUI_x64.exe', '/F').start() + def releaseDateFile = file("${buildDir}/installer/releasedate.log") + releaseDateFile.text = new Date().format('MM/dd/yyyy') } } // Task that zips the wrims_gui_x64_${version} folder into a zip file tasks.register('zipWrimsGui', Zip) { - dependsOn runWrimsGui + dependsOn copyThirdPartyToLib from("${buildDir}/installer/${wrimsGuiFolder}") archiveFileName = "${wrimsGuiFolder}.zip" destinationDirectory = file("${buildDir}/installer") @@ -148,54 +144,74 @@ tasks.register('zipWrimsGui', Zip) { //-------- PATCH INSTALLER BUILD TASKS--------------- // Task to copy JARs to patch folder tasks.register('copyJarsToPatchDropins', Copy) { - dependsOn unzipThirdPartyJar + dependsOn unzipThirdPartyLibs from(project(':third-party').tasks.named('jar').get().archiveFile) from(project(':wrims-ide').tasks.named('jar').get().archiveFile) from(project(':dwr-hecdssvue').tasks.named('jar').get().archiveFile) from(project(':jdiagram').tasks.named('jar').get().archiveFile) from(project(':xtext-editor').tasks.named('jar').get().archiveFile) from(project(':xtext-editor-ui').tasks.named('jar').get().archiveFile) - into("${buildDir}/patch/${wrimsGuiFolder}/dropins") + into("${buildDir}/patch/${wrimsPatchFolder}/dropins") } //task to download native libraries (dlls) -tasks.register('copyPatchLibs', Sync) { syncTask -> +tasks.register('getNativesForPatch', Sync) { syncTask -> dependsOn copyJarsToPatchDropins syncTask.from configurations.windows_x64.collect { zipTree(it) } - syncTask.into file("${buildDir}/patch/${wrimsGuiFolder}/lib") -} - -//task to copy all files from ${buildDir}/third-party/lib_x64 to ${buildDir}/installer/${wrimsGuiFolder}/lib -tasks.register('copyDllsToPatchLib', Copy) { - dependsOn copyPatchLibs - from("${buildDir}/third-party/lib_x64") - from("${buildDir}/third-party/heclib") - into("${buildDir}/patch/${wrimsGuiFolder}/lib") + syncTask.into file("${buildDir}/patch/${wrimsPatchFolder}/lib") } // Task to copy JARs to dropins folder tasks.register('copyWrimsCoreToPatchLib', Copy) { - dependsOn copyDllsToPatchLib + dependsOn getNativesForPatch from(project(':wrims-core').tasks.named('jar').get().archiveFile) - into("${buildDir}/patch/${wrimsGuiFolder}/lib") + into("${buildDir}/patch/${wrimsPatchFolder}/lib") } +//task to copy all files from ${buildDir}/third-party/lib_x64 to ${buildDir}/installer/${wrimsPatchFolder}/lib +tasks.register('copyThirdPartyToPatchLib', Copy) { + dependsOn copyWrimsCoreToPatchLib + from("${buildDir}/third-party/lib_x64") + from("${buildDir}/third-party/heclib") + into("${buildDir}/patch/${wrimsPatchFolder}/lib") +} + + //Copies all updated resource files into the installer tasks.register('copyResourcesToPatch', Copy) { - dependsOn copyWrimsCoreToPatchLib + dependsOn copyThirdPartyToPatchLib from("src/main/resources/installer") - into("${buildDir}/patch/${wrimsGuiFolder}") + into("${buildDir}/patch/${wrimsPatchFolder}") filter { line -> line.replace('${WRIMS_VERSION}', version) } } +//Add the release date to the patch +//generate a releasedate.log file that contains the current date in MM/DD/YYYY format +tasks.register('addReleaseDateToPatch', DefaultTask) { + dependsOn copyResourcesToPatch + doLast { + def releaseDateFile = file("${buildDir}/patch/${wrimsPatchFolder}/releasedate.log") + releaseDateFile.text = new Date().format('MM/dd/yyyy') + } +} + +//Add the release date for patch deployment in releasedate_v2.2.0_basis.log file that contains the current date in MM/DD/YYYY format +tasks.register('addReleaseDateToPatchDeployment', DefaultTask) { + dependsOn addReleaseDateToPatch + doLast { + def patchReleaseDateFile = file("${buildDir}/patch/${wrimsPatchReleaseDateFile}") + patchReleaseDateFile.text = new Date().format('MM/dd/yyyy') + } +} + //Zip patch files // Task that zips the wrims_gui_x64_${version} folder into a zip file tasks.register('zipWrimsPatch', Zip) { - dependsOn copyResourcesToPatch - from("${buildDir}/patch/${wrimsGuiFolder}") - archiveFileName = "${wrimsGuiFolder}_Patch.zip" + dependsOn addReleaseDateToPatchDeployment + from("${buildDir}/patch/${wrimsPatchFolder}") + archiveFileName = "${wrimsPatchFolder}.zip" destinationDirectory = file("${buildDir}/patch") } diff --git a/wrims-gui/src/main/resources/installer/WRIMS2_GUI_Update_and_Start.bat b/wrims-gui/src/main/resources/installer/WRIMS2_GUI_Update_and_Start.bat new file mode 100644 index 000000000..6e94bfe8e --- /dev/null +++ b/wrims-gui/src/main/resources/installer/WRIMS2_GUI_Update_and_Start.bat @@ -0,0 +1,33 @@ +@echo off +if "%~n0%~x0" == "WRIMS2_GUI_Update_and_Start.bat" ( + copy WRIMS2_GUI_Update_and_Start.bat WRIMS2_GUI_Update_and_Start_tmp.bat > update.log + start /B WRIMS2_GUI_Update_and_Start_tmp.bat + Exit +) +echo Reset tmp directory... +if not exist "C:\tmp\" mkdir C:\tmp +if exist "C:\tmp\releasedate.log" del C:\tmp\releasedate.log > update.log +if exist "C:\tmp\wrims_patch_v2.2.0_basis.zip" del C:\tmp\wrims_patch_v2.2.0_basis.zip > update.log +if exist "C:\tmp\wrims_patch_v2.2.0_basis" ( + del /S /Q C:\tmp\wrims_patch_v2.2.0_basis\*.* > update.log + rmdir /S /Q C:\tmp\wrims_patch_v2.2.0_basis > update.log +) + +echo Download the patch release date... +curl\bin\curl https://data.cnra.ca.gov/dataset/0f6b03b4-7de8-4579-8aa0-60f73d9d21fb/resource/23861121-d916-4442-94e0-1d5309c44762/download/releasedate_v2.2.0_basis.log -L --insecure -o C:\tmp\releasedate.log +echo Compare with the local release date... +FC C:\tmp\releasedate.log releasedate.log> nul +if %errorlevel% EQU 1 ( + echo Download Update Patch... + curl\bin\curl https://data.cnra.ca.gov/dataset/0f6b03b4-7de8-4579-8aa0-60f73d9d21fb/resource/e58abe5c-005f-4f3f-9bed-87e03b4ee4f6/download/wrims_patch_v2.2.0_basis.zip -L --insecure -o C:\tmp\wrims_patch_v2.2.0_basis.zip + echo Clear the old dropins and libs directories + del /S /Q dropins\*.* > update.log + del /S /Q lib\*.* > update.log + echo Unzip the Patch and Update... + powershell -command "Expand-Archive C:\tmp\wrims_patch_v2.2.0_basis.zip c:\tmp\wrims_patch_v2.2.0_basis" + xcopy /S /E /Y C:\tmp\wrims_patch_v2.2.0_basis . > update.log +) +echo Start WRIMS 2 GUI +start WRIMS2_GUI_Start +Exit +