diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 3fb7d9c9858..00000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,85 +0,0 @@ -version: 2 - -jobs: - prepareinstall4j: - docker: - - image: circleci/openjdk:11.0.3-jdk-stretch - steps: - - checkout - - restore_cache: - keys: - - install4j-{{ checksum "scripts/prepare-install4j.sh" }} - - run: scripts/prepare-install4j.sh - - save_cache: - key: install4j-{{ checksum "scripts/prepare-install4j.sh" }} - paths: - - "~/.install4j8" - filters: - tags: - only: /.*/ - - buildDev: - docker: - - image: circleci/openjdk:11.0.4-jdk-stretch - steps: - - checkout - - restore_cache: - key: install4j-{{ checksum "scripts/prepare-install4j.sh" }} - - run: scripts/prepare-install4j.sh - - run: install4j8/bin/install4jc --verbose --license=$INSTALL4J8_KEY - - restore_cache: - key: gradle - - run: git submodule sync - - run: git submodule update --init - - run: ./gradlew -Pdev=true -Pinstall4jDir="install4j8" release --stacktrace - - run: ./gradlew jlink - - run: mv build/image jabref - - run: tar cvzf JabRef-linux-${CIRCLE_BRANCH}-latest.tar.gz jabref - - run: mv JabRef-linux-${CIRCLE_BRANCH}-latest.tar.gz build/releases/ - - save_cache: - key: gradle - paths: - - "~/.gradle" - - store_artifacts: - path: build/releases - destination: build - - run: scripts/upload-to-builds.jabref.org.sh - - buildRelease: - docker: - - image: circleci/openjdk:11.0.4-jdk-stretch - steps: - - checkout - - restore_cache: - key: install4j-{{ checksum "scripts/prepare-install4j.sh" }} - - run: scripts/prepare-install4j.sh - - run: install4j8/bin/install4jc --verbose --license=$INSTALL4J8_KEY - - restore_cache: - key: gradle - - run: git submodule sync - - run: git submodule update --init - - run: ./gradlew -Pinstall4jDir="install4j8" release --stacktrace - - store_artifacts: - path: build/releases - destination: release - - run: scripts/upload-to-builds.jabref.org.sh - filters: - tags: - only: /.*/ - -workflows: - version: 2 - build: - jobs: - - prepareinstall4j - - buildDev: - requires: - - prepareinstall4j - - buildRelease: - requires: - - prepareinstall4j - filters: - branches: - ignore: /.*/ - tags: - only: /.*/ diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 00000000000..d641cf9fee0 --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,87 @@ +name: Deployment + +on: [push] + +jobs: + deploy: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + include: + - os: ubuntu-latest + displayName: linux + jpackageDownload: https://download.java.net/java/early_access/jpackage/1/openjdk-14-jpackage+1-35_linux-x64_bin.tar.gz + jdk14Path: /jdk-14 + archivePortable: tar -czf build/distribution/JabRef-portable_linux.tar.gz -C build/distribution JabRef && rm -R build/distribution/JabRef + - os: windows-latest + displayName: windows + jpackageDownload: https://download.java.net/java/early_access/jpackage/1/openjdk-14-jpackage+1-35_windows-x64_bin.zip + jdk14Path: /jdk-14 + archivePortable: 7z a -r build/distribution/JabRef-portable_windows.zip build/distribution/JabRef/ && rm -R build/distribution/JabRef + - os: macOS-latest + displayName: macOS + jpackageDownload: https://download.java.net/java/early_access/jpackage/1/openjdk-14-jpackage+1-35_osx-x64_bin.tar.gz + jdk14Path: /jdk-14.jdk/Contents/Home + archivePortable: tar -czf build/distribution/JabRef-portable_macos.tar.gz -C build/distribution JabRef.app && rm -R build/distribution/JabRef.app + + runs-on: ${{ matrix.os }} + name: Deploy on ${{ matrix.displayName }} + + steps: + - name: Checkout source + uses: actions/checkout@v1 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11.0.4 + - name: Download jpackage + # We need to download jpackage from https://jdk.java.net/jpackage/ + run: | + import tarfile + import zipfile + import sys + if sys.version_info[0] >= 3: + from urllib.request import urlretrieve + else: + from urllib import urlretrieve + + url = "${{ matrix.jpackageDownload }}" + tmpfile, headers = urlretrieve(url) + if (url.endswith("tar.gz")): + tar = tarfile.open(tmpfile) + tar.extractall() + tar.close() + elif (url.endswith("zip")): + zip = zipfile.ZipFile(tmpfile) + zip.extractall() + zip.close() + shell: python + - name: Build runtime image + run: ./gradlew -Pdev=true jlinkZip + - name: Build installer + run: | + export BADASS_JLINK_JPACKAGE_HOME="${GITHUB_WORKSPACE}${{ matrix.jdk14Path }}" + ./gradlew -Pdev=true jpackage + shell: bash + - name: Add installer as artifact + uses: actions/upload-artifact@master + with: + name: JabRef-${{ matrix.displayName }} + path: build/distribution + - name: Package application image + run: ${{ matrix.archivePortable }} + shell: bash + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - name: Upload to builds.jabref.org + uses: garygrossgarten/github-action-scp@release + with: + local: build/distribution + remote: www/${{ steps.extract_branch.outputs.branch }} + host: builds.jabref.org + username: builds_jabref_org + privateKey: ${{ secrets.buildJabRefPrivateKey }} + port: 9922 diff --git a/build.gradle b/build.gradle index bf9507ebcf7..2af73c6f657 100644 --- a/build.gradle +++ b/build.gradle @@ -12,15 +12,12 @@ buildscript { repositories { mavenLocal() jcenter() - maven { url 'https://oss.sonatype.org/content/groups/public' } } } plugins { id 'application' id 'com.gradle.build-scan' version '2.4.2' - id 'com.install4j.gradle' version '8.0.1' - id 'com.github.johnrengelman.shadow' version '5.1.0' id "com.simonharrer.modernizer" version '1.8.0-1' id 'me.champeau.gradle.jmh' version '0.4.8' //id 'net.ltgt.errorprone' version '0.8.1' @@ -40,7 +37,6 @@ apply plugin: 'java' apply plugin: 'application' apply plugin: 'project-report' apply plugin: 'jacoco' -apply plugin: 'install4j' apply plugin: 'me.champeau.gradle.jmh' apply plugin: 'checkstyle' apply plugin: JabRefAntlrPlugin @@ -50,9 +46,7 @@ apply plugin: LocalizationPlugin apply from: 'eclipse.gradle' group = "org.jabref" -version = "5.0-dev" -project.ext.threeDotVersion = "5.0.0.1" -project.ext.install4jDir = hasProperty("install4jDir") ? getProperty("install4jDir") : (OperatingSystem.current().isWindows() ? 'C:/Program Files/install4j8' : 'install4j8') +version = "5.0.0" sourceCompatibility = 11 targetCompatibility = 11 mainClassName = "$moduleName/org.jabref.JabRefLauncher" @@ -65,7 +59,6 @@ patchModules.config = [ "test3=sourcecode_2.12-0.1.4.jar" ] - // These are the Java version requirements we will check on each start of JabRef ext.minRequiredJavaVersion = "1.8.0_171" ext.allowJava9 = true @@ -283,7 +276,7 @@ processResources { filteringCharset = 'UTF-8' filesMatching("build.properties") { - expand(version: project.version, + expand(version: createVersionString(), "year": String.valueOf(Calendar.getInstance().get(Calendar.YEAR)), "authors": new File('AUTHORS').readLines().findAll { !it.startsWith("#") }.join(", "), "developers": new File('DEVELOPERS').readLines().findAll { !it.startsWith("#") }.join(", "), @@ -513,49 +506,6 @@ modernizer { } // Release tasks -shadowJar { - transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer) - classifier 'fat' - zip64 true -} - -/* - * Changes project.version to VERSION--snapshot--DATE--GIT_HASH - */ -if (hasProperty('dev')) { - String command = "git log --pretty=format:%cd--%h -n 1 --date=short" - String commitInfo = "" - if (OperatingSystem.current().isWindows()) { - commitInfo = "cmd /c $command".execute().in.text - } else { - commitInfo = command.execute().in.text - } - - // determine branch - command = "git symbolic-ref -q --short HEAD" - String branchName = "" - if (OperatingSystem.current().isWindows()) { - branchName = "cmd /c $command".execute().in.text - } else { - branchName = command.execute().in.text - } - // A newline is returned. Remove it. (trim()) - // In the context of github, the branch name could be something like "pull/277" - // "/" is an illegal character. To be safe, all illegal filename characters are replaced by "_" - // http://stackoverflow.com/a/15075907/873282 describes the used pattern. - branchName = branchName.trim().replaceAll("[^a-zA-Z0-9.-]", "_") - - // hack string - // first the date (%cd), then the branch name, and finally the commit id (%h) - String infoString = commitInfo.substring(0, 10) + "--" + branchName + "--" + commitInfo.substring(12) - - project.version += "--snapshot--" + infoString -} - -install4j { - installDir = file(project.ext.install4jDir) -} - task generateFinalJabRefPS1File(type: Copy) { from('buildres') { include 'JabRef.ps1' @@ -564,56 +514,10 @@ task generateFinalJabRefPS1File(type: Copy) { filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [jabRefJarFileName: jar.archiveName]) } -// has to be defined AFTER 'dev' things to have the correct project.version -task media(type: com.install4j.gradle.Install4jTask, dependsOn: ["releaseJar", "generateFinalJabRefPS1File"]) { - projectFile = file('jabref.install4j') - release = project.version - winKeystorePassword = System.getenv('CERTIFICATE_PW') - macKeystorePassword = System.getenv('CERTIFICATE_PW') - variables = [ - versionFourDots: project.ext.threeDotVersion, - buildFileName : jar.archiveName, - version : project.version - ] - - doLast { - copy { - from "build/install4j" - into "build/releases" - } - } -} - - -task release(dependsOn: ["media", "releaseJar"]) { - group = 'JabRef - Release' - description 'Creates a release for all target platforms.' -} - -task releaseJar(dependsOn: "shadowJar") { - group = 'JabRef - Release' - description "Creates a Jar release." - doLast { - copy { - from("$buildDir/libs/JabRef-${project.version}-fat.jar") - into("$buildDir/releases") - rename { String fileName -> - fileName.replace('-fat', '') - } - } - // set executable with read permissions (first true) and for all (false) - file("$buildDir/releases/JabRef-${project.version}.jar").setExecutable(true, false) - } -} - -task snapJar(dependsOn: "releaseJar", type: Delete) { - delete fileTree(dir: "$buildDir/releases/", exclude: "JabRef-${project.version}.jar") -} - jlink { options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'] launcher { - name = 'JabRefMain' + name = 'JabRef' } addOptions("--bind-services") @@ -663,10 +567,44 @@ jlink { provides 'com.microsoft.applicationinsights.core.dependencies.io.grpc.ManagedChannelProvider' with 'com.microsoft.applicationinsights.core.dependencies.io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider' } - // This is experimental thing; could replace install4j jpackage { - // Download from https://jdk.java.net/jpackage/ and change path accordingly - jpackageHome = 'H:\\Downloading\\openjdk-13-jpackage+49_windows-x64_bin\\jdk-13' + // In order for this to work, you need to dowload jpackage from https://jdk.java.net/jpackage/ + // and put the path to the jdk-14 folder in the environment variable BADASS_JLINK_JPACKAGE_HOME + outputDir = "distribution" + + if (OperatingSystem.current().isWindows()) { + // This requires WiX to be installed: https://github.com/wixtoolset/wix3/releases + installerType = "msi" + imageOptions = [ + '--icon', "${projectDir}/src/main/resources/icons/jabref.ico", + ] + installerOptions = [ + '--vendor', 'JabRef', + '--app-version', "${project.version}", + '--win-dir-chooser', + '--win-shortcut' + ] + } + + if (OperatingSystem.current().isLinux()) { + imageOptions = [ + '--icon', "${projectDir}/src/main/resources/icons/JabRef-icon-64.png", + ] + installerOptions = [ + '--vendor', 'JabRef', + '--app-version', "${project.version}" + ] + } + + if (OperatingSystem.current().isMacOsX()) { + imageOptions = [ + '--icon', "${projectDir}/src/main/resources/icons/jabref.icns", + ] + installerOptions = [ + '--vendor', 'JabRef', + '--app-version', "${project.version}" + ] + } } } @@ -702,3 +640,35 @@ task bundleLibreOffice(type: Jar) { destinationDir = file('lib') archiveName = 'libreoffice.jar' } + +// Returns the value of project.version in production and a string of the format VERSION-dev--DATE--BRANCH--GIT_HASH for development versions +def createVersionString() { + if (hasProperty('dev')) { + String command = "git log --pretty=format:%cd--%h -n 1 --date=short" + String commitInfo + if (OperatingSystem.current().isWindows()) { + commitInfo = "cmd /c $command".execute().in.text + } else { + commitInfo = command.execute().in.text + } + + // determine branch + command = "git symbolic-ref -q --short HEAD" + String branchName + if (OperatingSystem.current().isWindows()) { + branchName = "cmd /c $command".execute().in.text + } else { + branchName = command.execute().in.text + } + // A newline is returned. Remove it. (trim()) + // In the context of github, the branch name could be something like "pull/277" + // "/" is an illegal character. To be safe, all illegal filename characters are replaced by "_" + // http://stackoverflow.com/a/15075907/873282 describes the used pattern. + branchName = branchName.trim().replaceAll("[^a-zA-Z0-9.-]", "_") + + // first the date (%cd), then the branch name, and finally the commit id (%h) + return project.version + "-dev--" + commitInfo.substring(0, 10) + "--" + branchName + "--" + commitInfo.substring(12) + } else { + return project.version + } +} diff --git a/scripts/upload-to-builds.jabref.org.sh b/scripts/upload-to-builds.jabref.org.sh deleted file mode 100755 index 5e49c2c577c..00000000000 --- a/scripts/upload-to-builds.jabref.org.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# We assume that there is a single build in build/releases -# We take out the branch name from the first matching file and then upload everything - -# just to be sure -branch="snapshot" - -# simple solution to treat first file matching a pattern -# hint by http://unix.stackexchange.com/a/156207/18033 -for buildfile in build/releases/*--snapshot--*; do - # the last "--" part is the branch name - branch=`echo $buildfile | sed "sX.*--\(.*\)--.*X\1X"` - break; -done - -for buildfile in build/releases/*--snapshot--*.jar; do - # remove build/releases/ from the filename - jarname=`echo $buildfile | sed "sXbuild/releases/XX"` - break; -done - -# now the branch name is in the variable "branch" - -command="cd www/\n" - -# if there was a branch determined, create that directory -# the for returns the literal string "build/releases/*--snapshot--*" if no file was found -# then, "snapshot" is extracted -if [ "snapshot" != "$branch" ] ; then - # change into dir and delete old snapshots - command="${command}mkdir $branch\ncd $branch\nrm *.dmg\nrm *.jar\nrm *.exe\n" -fi - -# only upload JabRef*, not md5sums, updates.xml, etc. -command="${command}mput build/releases/JabRef*\n" - -# create symlink ...--latest.jar to latest version -command="${command}symlink ${jarname} /www/${branch}/JabRef--${branch}--latest.jar\n" - -command="${command}exit\n" - -# now $command is complete - -# add host key of build-upload.jabref.org to SSH known hosts -cat <> ~/.ssh/known_hosts -|1|/E0gFRKMKG83OQVcwqFPIy3mnE4=|tLYRVZQ/3nCkBTZ9NtBVxx3si+Y= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNjYLP9C+PhQrpKfYsdgr8dDB/50S3BnaXAYQOVC5o3H0SqKisWw8iTkij/u8H20Rmsf/ABduOLPOBubfPFlE34= -|1|dEeue80RCldo/x5XyhbGIkS72d8=|09t8muprLf6YoXsc3r3kxicBykI= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNjYLP9C+PhQrpKfYsdgr8dDB/50S3BnaXAYQOVC5o3H0SqKisWw8iTkij/u8H20Rmsf/ABduOLPOBubfPFlE34= -EOF - -echo -e "$command" | sftp -P 9922 builds_jabref_org@build-upload.jabref.org