Skip to content

Commit

Permalink
Merge pull request #189 from CentralValleyModeling/Feature/wrims-devo…
Browse files Browse the repository at this point in the history
…ps-patch-update

Updating patch build process and adding to release deployment.
  • Loading branch information
hxiedwr authored Jan 7, 2025
2 parents 70f8821 + 66baa35 commit 89efdbe
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 40 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build_installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_<branch-name>.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
```

55 changes: 54 additions & 1 deletion wrims-gui/README.md
Original file line number Diff line number Diff line change
@@ -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_<branch-name>.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.




95 changes: 56 additions & 39 deletions wrims-gui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -121,25 +124,19 @@ 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') {
//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) {
dependsOn copyResources
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/${wrimsGuiFolder}/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 addReleaseDate
from("${buildDir}/installer/${wrimsGuiFolder}")
archiveFileName = "${wrimsGuiFolder}.zip"
destinationDirectory = file("${buildDir}/installer")
Expand All @@ -148,54 +145,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")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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

5 changes: 5 additions & 0 deletions wrims-gui/src/main/resources/installer/data/setting.prf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CBC
100000
false
true
''

0 comments on commit 89efdbe

Please sign in to comment.