From 1e8943f7fb769a3c3ba88bb70ffcf9e292c375e4 Mon Sep 17 00:00:00 2001 From: augustak Date: Thu, 3 Dec 2026 15:26:16 +0100 Subject: [PATCH] Releases are built and served by JitPack from their GitHub release tag OSSRH (oss.sonatype.org), which uploadArchives published to, was shut down in June 2025. JitPack builds a version from its tag the first time it is requested, running publishToMavenLocal as set up in jitpack.yml, and serves it as com.github.LucidtechAI:las-sdk-java:. The Publish workflow requests the release when it is published, so it is built from the tag right away and a failed build fails the workflow with JitPack's build log. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yml | 51 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + Makefile | 5 ++-- README.md | 51 +++++++++++++++++++++++++++++++++++ build.gradle | 47 +++++++++----------------------- jitpack.yml | 6 +++++ 6 files changed, 123 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 jitpack.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6593e07 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index e65d03a..1f7a799 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index a1798e1..9e9bbab 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,8 @@ build: test: ./gradlew --info test -publish: - ./gradlew clean test - ./gradlew clean uploadArchives +install: + ./gradlew publishToMavenLocal java-docs: ./gradlew clean javadocJar diff --git a/README.md b/README.md index 06a74c9..8431b34 100644 --- a/README.md +++ b/README.md @@ -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 + + + jitpack.io + https://jitpack.io + + + + + + com.github.LucidtechAI + las-sdk-java + v4.0.1 + + +``` + ## Usage ### Preconditions @@ -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. diff --git a/build.gradle b/build.gradle index 2c023a1..108d268 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,6 @@ plugins { id 'java' - id 'maven' - id 'signing' + id 'maven-publish' } group = 'ai.lucidtech' @@ -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' diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..a0885be --- /dev/null +++ b/jitpack.yml @@ -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