diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9316059..4e08fad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,13 +8,17 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: gradle/wrapper-validation-action@v1 + - name: Set up JDK 20 uses: actions/setup-java@v3 with: distribution: temurin java-version: 20 + - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Tests run: ./gradlew check diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f43c6c8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,52 @@ +name: Publish + +on: + workflow_dispatch: + inputs: + forceVersion: + description: 'Force version' + required: true + default: '' + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: gradle/wrapper-validation-action@v1 + + - name: Set up JDK 20 + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 20 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Release + if: github.ref == 'refs/heads/main' + id: release + run: | + ./gradlew release \ + -Prelease.customPassword=${{ github.token }} \ + -Prelease.customUsername=${{ github.actor }} \ + -Prelease.forceVersion=${{ github.event.inputs.forceVersion }} + echo "released_version=`./gradlew -q cV -Prelease.quiet`" >> $GITHUB_OUTPUT + + - name: Publish to Maven Central + run: ./gradlew build publish + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }} + + - name: Create GitHub Release + if: github.ref == 'refs/heads/main' + run: gh release create "${{ steps.release.outputs.released_version }}" --generate-notes + env: + GH_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md index a89a527..603204f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# simdjson-java +simdjson-java +============= +![Build Status](https://github.com/simdjson/simdjson-java/actions/workflows/ci.yml/badge.svg) +[![](https://maven-badges.herokuapp.com/maven-central/org.simdjson/simdjson-java/badge.svg)](https://central.sonatype.com/search?namespace=org.simdjson) +[![](https://img.shields.io/badge/License-Apache%202-blue.svg)](LICENSE) A Java version of [simdjson](https://github.com/simdjson/simdjson) - a JSON parser using SIMD instructions, based on the paper [Parsing Gigabytes of JSON per Second](https://arxiv.org/abs/1902.08318) @@ -16,7 +20,7 @@ This implementation is still missing several features available in simdsjon. For byte[] json = loadTwitterJson(); SimdJsonParser parser = new SimdJsonParser(); -JsonValue jsonValue = simdJsonParser.parse(json, json.length); +JsonValue jsonValue = parser.parse(json, json.length); Iterator tweets = jsonValue.get("statuses").arrayIterator(); while (tweets.hasNext()) { JsonValue tweet = tweets.next(); @@ -27,6 +31,28 @@ while (tweets.hasNext()) { } ``` +## Installation + +The library is available in the [Maven Central Repository](https://mvnrepository.com/artifact/org.simdjson/simdjson-java). +To include it in your project, add the following dependency to the `build.gradle` file: +```groovy +implementation("org.simdjson:simdjson-java:0.1.0") +``` + +or to the `pom.xml` file: +```xml + + org.simdjson + simdjson-java + 0.1.0 + +``` + +Please remember about specifying the desired version. + +Note that simdjson-java follows the [SemVer specification](https://semver.org/), which means, for example, that a major +version of zero indicates initial development, so the library's API should not be considered stable. + ## Benchmarks To run the JMH benchmarks, execute the following command: diff --git a/build.gradle b/build.gradle index edebdff..61501bd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,25 @@ import me.champeau.jmh.JmhBytecodeGeneratorTask import org.gradle.internal.os.OperatingSystem import org.ajoberstar.grgit.Grgit +import java.time.Duration plugins { id 'java' id 'scala' id 'me.champeau.jmh' version '0.7.1' id 'org.ajoberstar.grgit' version '5.2.0' + id 'pl.allegro.tech.build.axion-release' version '1.15.4' + id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' + id 'maven-publish' + id 'signing' } group = 'org.simdjson' -version = '0.0.1-SNAPSHOT' +version = scmVersion.version + +scmVersion { + versionCreator('versionWithBranch') +} repositories { mavenCentral() @@ -20,6 +29,8 @@ java { toolchain { languageVersion = JavaLanguageVersion.of(20) } + withJavadocJar() + withSourcesJar() } ext { @@ -105,6 +116,65 @@ jmh { } } +publishing { + publications { + mavenJava(MavenPublication) { + pom { + name = project.name + description = 'A Java version of simdjson, a high-performance JSON parser utilizing SIMD instructions.' + url = 'https://github.com/simdjson/simdjson-java' + issueManagement { + system = 'GitHub Issue Tracking' + url = 'https://github.com/simdjson/simdjson-java/issues' + } + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'piotrrzysko' + name = 'Piotr Rżysko' + email = 'piotr.rzysko@gmail.com' + } + } + scm { + url = 'https://github.com/simdjson/simdjson-java' + connection = 'scm:git@github.com:simdjson/simdjson-java.git' + developerConnection = 'scm:git@github.com:simdjson/simdjson-java.git' + } + } + } + } +} + +if (System.getenv('GPG_KEY_ID')) { + signing { + useInMemoryPgpKeys( + System.getenv('GPG_KEY_ID'), + System.getenv('GPG_PRIVATE_KEY'), + System.getenv('GPG_PRIVATE_KEY_PASSWORD') + ) + sign publishing.publications.mavenJava + } +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl = uri('https://s01.oss.sonatype.org/service/local/') + snapshotRepositoryUrl = uri('https://s01.oss.sonatype.org/content/repositories/snapshots/') + stagingProfileId = '3c0bbfe420699e' + username = System.getenv('SONATYPE_USERNAME') + password = System.getenv('SONATYPE_PASSWORD') + } + } + connectTimeout = Duration.ofMinutes(3) + clientTimeout = Duration.ofMinutes(3) +} + def getBooleanProperty(String name, boolean defaultValue) { Boolean.valueOf((project.findProperty(name) ?: defaultValue) as String) }