diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 391dcca..b820629 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,3 +22,29 @@ jobs: cache: gradle - name: Check formatting, lint, build and test run: ./gradlew --no-daemon clean build -PjavaVersion=${{ matrix.java }} + + publish: + if: startsWith(github.ref, 'refs/tags/') + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: "25" + cache: gradle + - name: Check release version + run: | + version=$(./gradlew --no-daemon -q properties --property version | sed -n 's/^version: //p') + if [ "$GITHUB_REF_NAME" != "$version" ]; then + echo "Tag $GITHUB_REF_NAME does not match project version $version" >&2 + exit 1 + fi + - name: Publish and release to Maven Central + run: ./gradlew --no-daemon publishAndReleaseToMavenCentral + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 692f077..7ab726b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ # Changelog -## 0.1.0 — Sin publicar +## 0.1.0 — 2026-10-12 +- Publicación en Maven Central como `py.com.ith:tu-ruc-client`, con JAR de + fuentes, Javadoc y firmas PGP. El `groupId` cambia de `org.ith` a `py.com.ith`, + el dominio de ITH; los paquetes Java `org.ith.*` no cambian. +- Licencia MIT. - Cambio incompatible: el cliente deja de registrar por defecto cada petición y respuesta completas (`HttpLoggingInterceptor.Level.BODY`). El nuevo `TuRuc.withLogLevel(Level)` activa el logging de OkHttp con el nivel indicado; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6954781..3d049cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,6 +42,26 @@ puedes añadir `-PjavaVersion=17` o `-PjavaVersion=21` a los comandos anteriores Las herramientas de calidad son dependencias del build y no se publican como dependencias del cliente. +## Probar desde otro proyecto + +Para probar cambios sin publicar, clona este repositorio junto al proyecto +consumidor y agrega a su `settings.gradle`: + +```groovy +includeBuild("../tu-ruc-java-client") +``` + +Gradle sustituye `py.com.ith:tu-ruc-client` por el checkout local. Con la +configuración por defecto necesitas JDK 25 instalado. + +Para revisar los artefactos que se publicarían, sin firmarlos: + +```bash +./gradlew publishToMavenLocal +``` + +Quedan en `~/.m2/repository/py/com/ith/tu-ruc-client/`. + ## Integración continua CI ejecuta `./gradlew clean build` con Java 17, 21 y 25 y falla si alguna @@ -55,4 +75,36 @@ transitivos entre la compilación del consumidor y la ejecución. La conversión JSON usa el módulo oficial `fastjson2-extension`, que incluye el [conversor para Retrofit](https://github.com/alibaba/fastjson2/blob/2.0.65/extension/src/main/java/com/alibaba/fastjson2/support/retrofit/Retrofit2ConverterFactory.java). -Registra los cambios de cada versión en [CHANGELOG.md](CHANGELOG.md). +## Publicación + +La biblioteca se publica en [Maven Central](https://central.sonatype.com/) con el +plugin [`com.vanniktech.maven.publish`](https://vanniktech.github.io/gradle-maven-publish-plugin/central/). +Maven Central rechaza artefactos sin firmar, por eso la publicación exige la +clave PGP. + +Para publicar: + +1. Sube `version` en `build.gradle` y registra los cambios en + [CHANGELOG.md](CHANGELOG.md). +2. Crea y sube un tag con la misma versión, sin `v`: + + ```bash + git tag -a 0.1.0 -m "Tu RUC Java Client 0.1.0" + git push origin 0.1.0 + ``` + +CI ejecuta las comprobaciones con Java 17, 21 y 25, verifica que el tag coincida +con la versión y publica en Maven Central. Una versión publicada no se puede +borrar ni reemplazar. + +El workflow usa estos secretos del repositorio: + +| Secreto | Contenido | +| ------------------------ | ------------------------------------------------------------ | +| `MAVEN_CENTRAL_USERNAME` | Usuario del token de Central Portal con acceso a `py.com.ith` | +| `MAVEN_CENTRAL_PASSWORD` | Contraseña de ese token | +| `SIGNING_KEY` | Clave privada PGP exportada en ASCII (`gpg --armor --export-secret-keys`) | +| `SIGNING_KEY_PASSWORD` | Frase de la clave PGP | + +La clave pública debe estar en un servidor de claves que Maven Central consulte, +como `keys.openpgp.org` o `keyserver.ubuntu.com`. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cb9619f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 ITH E.A.S. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 870c34f..5f2dfba 100644 --- a/README.md +++ b/README.md @@ -9,30 +9,25 @@ Java 17 o superior. ## Instalación -La biblioteca todavía no se publica en un repositorio Maven. Para usarla desde -otro proyecto Gradle, clona este repositorio junto a tu proyecto y agrega a su -`settings.gradle`: +La biblioteca se publica en Maven Central como `py.com.ith:tu-ruc-client`. -```groovy -includeBuild("../tu-ruc-java-client") -``` - -Y a su `build.gradle`: +Gradle: ```groovy -repositories { - mavenCentral() -} - dependencies { - implementation("org.ith:tu-ruc-client:0.1.0") + implementation("py.com.ith:tu-ruc-client:0.1.0") } ``` -Gradle compila la biblioteca y resuelve sus dependencias desde Maven Central. -Para compilarla así necesitas JDK 25 instalado, aunque el resultado funciona -desde Java 17. Si usas el JAR de `build/libs/`, agrega tú sus dependencias: -el JAR no las incluye. +Maven: + +```xml + + py.com.ith + tu-ruc-client + 0.1.0 + +``` ## Uso @@ -138,6 +133,10 @@ si tu proyecto lo usa, decláralo por tu cuenta. Las dependencias transitivas pasan a Retrofit 3.0.0 y OkHttp 5.5.0. +Las coordenadas Maven pasan de `org.ith:tu-ruc-client` a +`py.com.ith:tu-ruc-client`. Los paquetes Java no cambian: los imports siguen +siendo `org.ith.client` y `org.ith.model`. + El cliente ya no registra las peticiones y respuestas completas. Si dependías de esos logs, actívalos con `withLogLevel(HttpLoggingInterceptor.Level.BODY)`. @@ -145,6 +144,10 @@ esos logs, actívalos con `withLogLevel(HttpLoggingInterceptor.Level.BODY)`. Consulta [CHANGELOG.md](CHANGELOG.md) para conocer los cambios de cada versión. +## Licencia + +[MIT](LICENSE). + ## Contribuciones Para compilar, ejecutar las pruebas y conocer las comprobaciones de calidad, diff --git a/build.gradle b/build.gradle index f65be9e..5153d65 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,14 @@ +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar + plugins { id("java-library") id("pmd") id("com.diffplug.spotless") version "8.10.4" + id("com.vanniktech.maven.publish") version "0.37.0" } -group = "org.ith" +group = "py.com.ith" version = "0.1.0" java { @@ -45,6 +49,11 @@ tasks.test { useJUnitPlatform() } +tasks.withType(Javadoc).configureEach { + options.encoding = "UTF-8" + options.addBooleanOption("Xdoclint:all,-missing", true) +} + spotless { java { palantirJavaFormat("2.102.0") @@ -61,3 +70,45 @@ pmd { ruleSetFiles = files("config/pmd/ruleset.xml") consoleOutput = true } + +mavenPublishing { + publishToMavenCentral() + signAllPublications() + coordinates(project.group.toString(), "tu-ruc-client", project.version.toString()) + configure(new JavaLibrary(new JavadocJar.Javadoc(), true)) + + pom { + name = "Tu RUC Java Client" + description = "Cliente Java para consultar y buscar contribuyentes en la API de Tu RUC." + inceptionYear = "2023" + url = "https://github.com/ithdev/tu-ruc-java-client" + licenses { + license { + name = "MIT License" + url = "https://opensource.org/license/mit" + distribution = "repo" + } + } + developers { + developer { + id = "ithdev" + name = "ITH E.A.S." + url = "https://ith.com.py" + } + } + scm { + url = "https://github.com/ithdev/tu-ruc-java-client" + connection = "scm:git:https://github.com/ithdev/tu-ruc-java-client.git" + developerConnection = "scm:git:ssh://git@github.com/ithdev/tu-ruc-java-client.git" + } + } +} + +// Maven Central rechaza artefactos sin firmar; para publicar en Maven local no hace falta firmar. +signing { + required = { + gradle.taskGraph.allTasks.any { + it.name.contains("MavenCentral") + } + } +} diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 5b15902..0000000 --- a/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -gpr.user=ithdev -gpr.token=secret_token