diff --git a/.github/workflows/deploy_to_internal.yml b/.github/workflows/deploy_to_internal.yml new file mode 100644 index 00000000000..3ec16b0ae03 --- /dev/null +++ b/.github/workflows/deploy_to_internal.yml @@ -0,0 +1,90 @@ +name: 'Deploy to dataverse-internal.iq.harvard.edu' + +on: + workflow_dispatch: + inputs: + buildlabel: + description: 'Custom label that will appear after the version number (the equivalent of the old "build number" entry).' + type: string + required: false + +permissions: + contents: read + +concurrency: + group: deploy-to-internal + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-java@v5 + with: + distribution: 'zulu' + java-version: '21' + + - name: Set build number + run: scripts/installer/custom-build-number ${{ github.event.inputs.buildlabel }} + + - name: Build application war + run: mvn package + + - name: Get war file name + working-directory: target + run: echo "war_file=$(ls *.war | head -1)">> $GITHUB_ENV + + - name: Upload war artifact + uses: actions/upload-artifact@v7 + with: + name: built-app + path: ./target/${{ env.war_file }} + + deploy-to-payara: + needs: build + if: ${{ github.repository_owner == 'IQSS' }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Download war artifact + uses: actions/download-artifact@v8 + with: + name: built-app + path: ./ + + - name: Get war file name + run: echo "war_file=$(ls *.war | head -1)">> $GITHUB_ENV + + - name: Copy war file to remote instance + uses: appleboy/scp-action@master + with: + host: ${{ secrets.INTERNAL_PAYARA_INSTANCE_HOST }} + username: ${{ secrets.INTERNAL_PAYARA_INSTANCE_USERNAME }} + key: ${{ secrets.INTERNAL_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} + source: './${{ env.war_file }}' + target: '/home/${{ secrets.INTERNAL_PAYARA_INSTANCE_USERNAME }}' + overwrite: true + + - name: Execute payara war deployment remotely + uses: appleboy/ssh-action@v1.2.5 + env: + INPUT_WAR_FILE: ${{ env.war_file }} + with: + host: ${{ secrets.INTERNAL_PAYARA_INSTANCE_HOST }} + username: ${{ secrets.INTERNAL_PAYARA_INSTANCE_USERNAME }} + key: ${{ secrets.INTERNAL_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} + envs: INPUT_WAR_FILE + script: | + APPLICATION_NAME=dataverse-backend + ASADMIN='/usr/local/payara7/bin/asadmin --user admin' + $ASADMIN undeploy $APPLICATION_NAME + #$ASADMIN stop-domain + #$ASADMIN start-domain + $ASADMIN deploy --name $APPLICATION_NAME $INPUT_WAR_FILE + #$ASADMIN stop-domain + #$ASADMIN start-domain diff --git a/.github/workflows/generate_war_file.yml b/.github/workflows/generate_war_file.yml new file mode 100644 index 00000000000..f7dcd945dfe --- /dev/null +++ b/.github/workflows/generate_war_file.yml @@ -0,0 +1,41 @@ +name: 'Generate dataverse war file' + +on: + workflow_dispatch: + inputs: + buildlabel: + description: 'Custom label that will appear after the version number (the equivalent of the old "build number" entry).' + type: string + required: false + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-java@v5 + with: + distribution: 'zulu' + java-version: '21' + + - name: Set build number + run: scripts/installer/custom-build-number ${{ github.event.inputs.buildlabel }} + + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v7.07 + + - name: Build application war + run: mvn package + + - name: Get war file name + working-directory: target + run: echo "war_file=$(ls *.war | head -1)">> $GITHUB_ENV + + - name: Upload war artifact + uses: actions/upload-artifact@v7 + with: + name: built-app + path: ./target/${{ env.war_file }} diff --git a/scripts/installer/custom-build-number-hook b/scripts/installer/custom-build-number-hook index 4e7b81950bf..f5c454a426d 100755 --- a/scripts/installer/custom-build-number-hook +++ b/scripts/installer/custom-build-number-hook @@ -1,7 +1,7 @@ #!/bin/sh # Git changes workdir to root of repo per git documentation BRANCH_COMMIT=$(git rev-parse --abbrev-ref HEAD)-$(git log --oneline | head -1 | awk '{print $1}') -echo "build.number=$BRANCH_COMMIT" > src/main/java/BuildNumber.properties +echo "build.number=build $BRANCH_COMMIT" > src/main/java/BuildNumber.properties # Based on https://stackoverflow.com/questions/25590267 # $6 = previous branch, $8 is next branch diff --git a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java index af2606969a9..a3596850b44 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java @@ -125,7 +125,7 @@ public String getVersion(boolean withBuildNumber) { } if (!buildNumber.equals("")) { - return appVersion + " build " + buildNumber; + return appVersion + " " + buildNumber; } } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/SystemConfigTest.java b/src/test/java/edu/harvard/iq/dataverse/util/SystemConfigTest.java index b39d269f8ed..3e8ada1f386 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/SystemConfigTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/SystemConfigTest.java @@ -93,10 +93,11 @@ void testGetVersionWithBuild() { // then assertTrue(result.startsWith("100.100"), "'" + result + "' not starting with 100.100"); - assertTrue(result.contains("build")); // Cannot test this here - there might be the bundle file present which is not under test control //assertTrue(result.endsWith("FOOBAR"), "'" + result + "' not ending with FOOBAR"); + // Not sure what to do about this. The above is correct, if there is a BuildNumber.properties + // file present on the developer's system, it will take precedence. - L.A. } @Test