diff --git a/.github/actions/ssh/action.yml b/.github/actions/ssh/action.yml new file mode 100644 index 00000000..5c4886ab --- /dev/null +++ b/.github/actions/ssh/action.yml @@ -0,0 +1,42 @@ +name: SSH setup +description: Set up the SSH agent + +inputs: + config: + description: The SSH configuration + required: true + key: + description: The private SSH key + required: true + known-hosts: + description: The list of known hosts + required: true + +runs: + using: composite + + steps: + - name: Configure SSH + shell: sh + env: + CONFIG: ${{ inputs.config }} + KNOWN_HOSTS: ${{ inputs.known-hosts }} + run: | + mkdir -p ~/.ssh + echo "${CONFIG}" > ~/.ssh/config + echo "${KNOWN_HOSTS}" > ~/.ssh/known_hosts + + - name: Start SSH agent + shell: bash + env: + SOCKET: /tmp/ssh-agent.sock + run: | + echo "SSH_AUTH_SOCK=${SOCKET}" >> $GITHUB_ENV + ssh-agent -a ${SOCKET} > /dev/null + + - name: Add SSH key + shell: bash + env: + KEY: ${{ inputs.key }} + run: | + ssh-add - <<< "${KEY}" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..fb6355e9 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,26 @@ +name: Deploy (Production) + +on: + workflow_dispatch: {} + push: + branches: + - helma-🐜 + +jobs: + deploy: + runs-on: ubuntu-latest + + environment: + name: p3k.org + url: https://blog.p3k.org + + steps: + - name: Set up SSH agent + uses: antville/helma/.github/actions/ssh@helma-🐜 + with: + config: ${{ vars.SSH_CONFIG }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + known-hosts: ${{ vars.SSH_KNOWN_HOSTS }} + + - name: Copy files to production server + run: ssh staging-server deploy-helma diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 28a2249c..35333503 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,10 @@ jobs: build: runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + LC_TIME: en_US.UTF-8 + steps: - uses: actions/checkout@v4 @@ -28,16 +32,14 @@ jobs: run: ./gradlew assembleDist - name: Create release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release create "$GITHUB_REF_NAME" \ --repo "$GITHUB_REPOSITORY" \ - --title "Helma $GITHUB_REF_NAME" \ + --title "$(date +'%d %b %Y')" \ --generate-notes - name: Upload assets run: | gh release upload "$GITHUB_REF_NAME" \ - build/distributions/helma-*.* + build/distributions/helma-*.* \ --clobber diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml new file mode 100644 index 00000000..692beac1 --- /dev/null +++ b/.github/workflows/stage.yml @@ -0,0 +1,48 @@ +name: Deploy (Staging) + +on: workflow_dispatch + +jobs: + stage: + runs-on: ubuntu-latest + + environment: + name: stage + url: https://antville-test.click + + steps: + - uses: actions/checkout@v4 + + - name: Set up SSH agent + uses: ./.github/actions/ssh + with: + config: ${{ vars.SSH_CONFIG }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + known-hosts: ${{ vars.SSH_KNOWN_HOSTS }} + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Build with Gradle + run: ./gradlew installDist + + - name: Publish to staging server + run: | + rsync ./build/install/helma/ staging-server:./ \ + --verbose --archive --delete --compress \ + --filter '+ /bin' \ + --filter '+ /extras' \ + --filter '+ /launcher.jar' \ + --filter '- /lib/ext' \ + --filter '+ /lib' \ + --filter '+ /modules' \ + --filter '- /*' + + - name: Restart Helma + run: ssh staging-server restart diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml deleted file mode 100644 index 254d9892..00000000 --- a/.github/workflows/staging.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Staging - -on: - workflow_dispatch - -env: - SSH_AUTH_SOCK: /tmp/ssh-agent.sock - -jobs: - install: - runs-on: ubuntu-latest - - environment: - name: staging - url: https://antville-test.click - - steps: - - uses: actions/checkout@v4 - - - name: Set up Java - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - - - name: Set up Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Build with Gradle - run: ./gradlew installDist - - - name: Set up SSH agent - run: | - ssh-agent -a $SSH_AUTH_SOCK > /dev/null - ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" - mkdir -p ~/.ssh - echo '${{ vars.SSH_CONFIG }}' > ~/.ssh/config - echo '${{ vars.KNOWN_HOSTS }}' > ~/.ssh/known_hosts - - - name: Publish to staging server - run: | - rsync build/install/helma/ antville.dev:/ \ - --verbose --archive --delete --compress \ - --filter '+ launcher.jar' \ - --filter '+ lib' \ - --filter '+ *.jar' \ - --filter '- *' \ - - - name: Restart Helma - run: ssh antville.dev restart diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 0d95f065..c52f6863 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ - "vscjava.vscode-java-pack" + "vscjava.vscode-java-pack", + "vscjava.vscode-gradle" ] } diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 8310c621..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "java", - "name": "Current File", - "request": "launch", - "mainClass": "${file}" - }, - { - "type": "java", - "name": "ImageInfo", - "request": "launch", - "mainClass": "helma.image.ImageInfo", - "projectName": "helma_" - }, - { - "type": "java", - "name": "CommandlineRunner", - "request": "launch", - "mainClass": "helma.main.CommandlineRunner", - "projectName": "helma_" - }, - { - "type": "java", - "name": "Server", - "request": "launch", - "mainClass": "helma.main.Server", - "projectName": "helma_" - }, - { - "type": "java", - "name": "XmlConverter", - "request": "launch", - "mainClass": "helma.objectmodel.dom.XmlConverter", - "projectName": "helma_" - }, - { - "type": "java", - "name": "Crypt", - "request": "launch", - "mainClass": "helma.util.Crypt", - "projectName": "helma_" - }, - { - "type": "java", - "name": "HtmlEncoder", - "request": "launch", - "mainClass": "helma.util.HtmlEncoder", - "projectName": "helma_" - }, - { - "type": "java", - "name": "Logo", - "request": "launch", - "mainClass": "helma.util.Logo", - "projectName": "helma_" - }, - { - "type": "java", - "name": "MarkdownProcessor", - "request": "launch", - "mainClass": "helma.util.MarkdownProcessor", - "projectName": "helma_" - }, - { - "type": "java", - "name": "Commandline", - "request": "launch", - "mainClass": "helma.main.launcher.Commandline", - "projectName": "launcher" - }, - { - "type": "java", - "name": "Main", - "request": "launch", - "mainClass": "helma.main.launcher.Main", - "projectName": "launcher" - } - ] -} \ No newline at end of file diff --git a/README.md b/README.md index 4046dbc5..e93af8d1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## TL;DR -- Make sure you have Java 17 or higher installed +- Make sure you have Java 11 or higher installed - Download and unpack the [latest release](https://github.com/antville/helma/releases) - Invoke `./bin/helma`, resp. `./bin/helma.bat`, depending on your platform - Direct your web browser to @@ -21,9 +21,9 @@ Although Helma became a Grande Dame of server-side JavaScript already decades ag ## System Requirements -You need a Java virtual machine version 17 or higher to run Helma. +You need a Java virtual machine version 11 or higher to run Helma. -Please consult the documentation of your platform on how to obtain and install Java. +Please consult the documentation of your platform how to obtain and install Java. You also can directly download a [Java runtime or development kit](https://www.oracle.com/java/technologies/javase-downloads.html#javasejdk) from Oracle. @@ -33,10 +33,12 @@ Helma is built with [Gradle](https://gradle.org), the build task depends on the ### Additional Prerequisites -* [Rsync](https://rsync.samba.org) version ≥ 3.1.0 * [Node.js](https://nodejs.org) LTS version +* [Rsync](https://rsync.samba.org) version ≥ 3.1.0 -Clone this repository to your machine and start the build process with `./gradlew install`. The build script is going to ask you if you want to update the installation, enter `yes` or `no`. +Clone this repository to your machine and run Helma with `./gradlew run`. + +To update the installation from a build, run `./gradlew update` and enter `yes` at the prompt. > ⚠️ > Please be aware that this step is going to overwrite files in the installation directory – escpecially at a later time when there might be substantial changes. Should this happen by accident you find the previous installation in the `backups` directory. diff --git a/build.gradle b/build.gradle index c001992d..b1aa2021 100644 --- a/build.gradle +++ b/build.gradle @@ -17,17 +17,15 @@ def textFiles = ['**/*.hac', '**/.html', '**/*.js', '**/*.md', '**/*.properties' allprojects { apply plugin: 'java' - compileJava { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 repositories { mavenCentral() } } -version = new Date().format("yyyyMMdd") +version = new Date().format("yy.M.d") tasks.build.dependsOn javadoc, 'jsdoc', 'generateLicenseReport' tasks.compileJava.dependsOn 'processSource' @@ -58,7 +56,7 @@ configurations { } dependencies { - implementation 'com.google.code.gson:gson:2.10.1' + implementation 'com.google.code.gson:gson:2.11.0' implementation 'commons-codec:commons-codec:1.17.0' implementation 'org.apache.commons:commons-fileupload2-core:2.0.0-M2' implementation 'org.apache.commons:commons-fileupload2-jakarta:2.0.0-M1' @@ -79,6 +77,37 @@ def rhinoJar = configurations.library.files.find { jar -> jar.name.startsWith('rhino') } +run { + jvmArgs jettyLogLevel, suppressMacosDockIcon + classpath += fileTree(dir: 'lib/ext', include: '*.jar') +} + +application { + mainClass = 'helma.main.Server' + + applicationDistribution.from(projectDir) { + include 'modules/**' + include 'LICENSE.md' + include 'README.md' + include 'start.*' + } + + applicationDistribution.from(javadoc.destinationDir) { + include '**' + into 'docs/javadoc' + } + + applicationDistribution.from("${project.buildDir}/docs/jsdoc") { + include '**' + into 'docs/jsdoc' + } + + applicationDistribution.from("${project.buildDir}/reports/dependency-license") { + include '**' + into 'licenses' + } +} + startScripts { applicationName = 'helma' classpath = files('../launcher.jar') @@ -104,30 +133,6 @@ distributions { } } -application { - applicationDistribution.from(projectDir) { - include 'modules/**' - include 'LICENSE.md' - include 'README.md' - include 'start.*' - } - - applicationDistribution.from(javadoc.destinationDir) { - include '**' - into 'docs/javadoc' - } - - applicationDistribution.from("${project.buildDir}/docs/jsdoc") { - include '**' - into 'docs/jsdoc' - } - - applicationDistribution.from("${project.buildDir}/reports/dependency-license") { - include '**' - into 'licenses' - } -} - distTar { dependsOn ':generateLicenseReport', ':javadoc', ':jsdoc' @@ -148,19 +153,10 @@ distZip { installDist { dependsOn build - - if (!System.getenv('CI')) { - finalizedBy 'update' - } -} - -run { - classpath = files('launcher.jar') - jvmArgs jettyLogLevel, suppressMacosDockIcon } task processSource(type: Sync) { - def date = new Date().format("MMMM dd, yyyy") + def date = new Date().format("d MMMM yyyy") def gitOutput = new ByteArrayOutputStream() exec { @@ -184,6 +180,8 @@ task processSource(type: Sync) { } task update { + dependsOn installDist + def rsyncArgs = ['--archive', '--filter', '- backups'] def confirm = { @@ -293,3 +291,11 @@ task commandLine(type: JavaExec) { mainClass = 'helma.main.launcher.Commandline' args '-h', projectDir, function } + +tasks.register('debug', JavaExec) { + group = 'application' + main = 'helma.main.Server' + classpath = sourceSets.main.runtimeClasspath + jvmArgs = ['-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005'] + classpath += fileTree(dir: 'lib/ext', include: '*.jar') +}