Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish

on:
release:
types: [ published ]

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Check that the release tag is the version
run: |
version=$(sed -n 's/^version=//p' gradle.properties)
if [ "$GITHUB_REF_NAME" != "v$version" ]; then
echo "::error::Release tag $GITHUB_REF_NAME should be v$version, the version in gradle.properties"
exit 1
fi

# JitPack builds a version the first time it is requested, and the request returns once the build is done. It is
# requested here so that the release is built from its tag now, and a failed build shows up on the release
# instead of for the first user. A request that times out or fails on JitPack's side is repeated.
- name: Build the release on JitPack
run: |
dir=https://jitpack.io/com/github/LucidtechAI/las-sdk-java/$GITHUB_REF_NAME
for _ in $(seq 10); do
code=$(curl -sS -m 600 -o /dev/null -w '%{http_code}' "$dir/las-sdk-java-$GITHUB_REF_NAME.pom" || true)
if [ "$code" = 200 ]; then
echo "Built com.github.LucidtechAI:las-sdk-java:$GITHUB_REF_NAME, see $dir/build.log"
exit 0
fi
status=$(curl -sS "https://jitpack.io/api/builds/com.github.LucidtechAI/las-sdk-java/$GITHUB_REF_NAME" |
python3 -c 'import json, sys; print(json.load(sys.stdin)["status"])' || true)
if [ "$status" = Error ]; then
curl -sS "$dir/build.log" || true
echo "::error::JitPack failed to build $GITHUB_REF_NAME, see the build log above"
exit 1
fi
echo "The POM request returned ${code:-nothing} and the build status is ${status:-unknown}, trying again"
sleep 30
done
echo "::error::JitPack did not build $GITHUB_REF_NAME, see https://jitpack.io/#LucidtechAI/las-sdk-java"
exit 1
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Updated org.apache.httpcomponents:httpclient to 4.5.14 (CVE-2020-13956)
- Replaced org.apache.commons:commons-io 1.3.2 with commons-io:commons-io 2.22.0 (CVE-2021-29425)
- Updated junit to 4.13.2 in tests (CVE-2020-15250)
- Published on JitPack as com.github.LucidtechAI:las-sdk-java instead of on Maven Central, see the README

## Version 4.0.0 - 2021-10-22

Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ build:
test:
./gradlew --info test

publish:
./gradlew clean test
./gradlew clean uploadArchives
install:
./gradlew publishToMavenLocal

java-docs:
./gradlew clean javadocJar
Expand Down
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,46 @@

[Link to docs](https://docs.lucidtech.ai/java/v1/index.html)

## Installation

Releases from 4.0.1 on are served by [JitPack](https://jitpack.io/#LucidtechAI/las-sdk-java). Earlier versions are on
Maven Central as `ai.lucidtech:las-sdk-java`.

With Gradle:

```gradle
repositories {
mavenCentral()
maven {
url 'https://jitpack.io'
content { includeGroup 'com.github.LucidtechAI' }
}
}

dependencies {
implementation 'com.github.LucidtechAI:las-sdk-java:v4.0.1'
}
```

With Maven:

```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.github.LucidtechAI</groupId>
<artifactId>las-sdk-java</artifactId>
<version>v4.0.1</version>
</dependency>
</dependencies>
```

## Usage

### Preconditions
Expand Down Expand Up @@ -95,3 +135,14 @@ $ pmd -d . -R ruleset.xml
```sh
$ make publish
```

## Publishing

1. Merge a pull request that updates `version` in gradle.properties and the changelog.
2. Publish a GitHub release whose tag is the version prefixed with `v`, such as `v4.0.1`.

The [Publish workflow](.github/workflows/publish.yml) then checks that the tag is the version and has JitPack build
the release from the tag, as set up in [jitpack.yml](jitpack.yml). If the build fails, the workflow prints JitPack's
build log, and the fix is released as a new version. JitPack keeps what it built for a tag, and freezes it after 7 days.

`make install` installs the library in your local Maven repository, as JitPack does.
47 changes: 12 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'java'
id 'maven'
id 'signing'
id 'maven-publish'
}

group = 'ai.lucidtech'
Expand All @@ -27,42 +26,20 @@ test {
}
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
java {
withJavadocJar()
withSourcesJar()
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives javadocJar, sourcesJar
}

signing {
required { !version.endsWith('SNAPSHOT') && gradle.taskGraph.hasTask('uploadArchives') }
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
}
// JitPack builds a release from its tag and serves what publishToMavenLocal installs, see jitpack.yml
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = archivesBaseName
from components.java

pom.project {
name = "${project.group}:${project.name}"
pom {
name = "${project.group}:${archivesBaseName}"
packaging = 'jar'
description = 'Java SDK for Lucidtech AI Services'
url = 'https://lucidtech.ai'
Expand Down
6 changes: 6 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# JitPack builds a version the first time it is requested, which the Publish workflow does for each GitHub release
jdk:
- openjdk8
# The tests need the mock API in Docker, so they run in CI on every pull request instead
install:
- ./gradlew publishToMavenLocal
Loading