Skip to content
Merged
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
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publicar en Maven Central

on:
push:
tags:
- 'v*'

concurrency:
group: release
cancel-in-progress: false

jobs:
publicar:
name: Publicar ${{ github.ref_name }}
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Traer el codigo
uses: actions/checkout@v4

- name: Preparar Java, Maven y la clave GPG
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Tomar la version del tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "El tag tiene que ser vX.Y.Z y es $GITHUB_REF_NAME"
exit 1
fi
mvn -B -q org.codehaus.mojo:versions-maven-plugin:2.22.0:set -DnewVersion="$VERSION" -DgenerateBackupPoms=false

- name: Probar, firmar y subir a Central
run: mvn -B -Prelease deploy
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
89 changes: 89 additions & 0 deletions docs/publicar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Publicar en Maven Central

Se publica desde GitHub Actions al crear un tag `vX.Y.Z`
(`.github/workflows/release.yml`). No se publica desde una máquina Windows: el plugin de
Sonatype arma el bundle con `\` como separador dentro del zip y Central espera `/`.

## Lo que se hace una sola vez

### 1. Namespace

`io.github.caerus-dev` está verificado en central.sonatype.com (03/10/2026), en la cuenta en
la que Thomas entró con **Google**. Cada forma de entrar es una cuenta distinta: el token
tiene que salir de esa.

### 2. Token de publicación

central.sonatype.com → usuario → **View Account** → **Generate User Token**. Da un usuario y
una clave que no son los de la cuenta.

### 3. Clave GPG

Central exige que cada archivo vaya firmado. Git for Windows trae `gpg`, así que alcanza con
Git Bash:

```bash
gpg --full-generate-key
```

RSA, 4096 bits, con vencimiento (2 años está bien), nombre `Caerus` y un mail del equipo.
Después:

```bash
gpg --list-secret-keys --keyid-format=long
```

El ID es lo que va después de `rsa4096/` en la línea `sec`. Publicarla para que Central pueda
comprobar las firmas:

```bash
gpg --keyserver keyserver.ubuntu.com --send-keys ID_DE_LA_CLAVE
gpg --keyserver keys.openpgp.org --send-keys ID_DE_LA_CLAVE
```

### 4. Secrets del repositorio

En `caerus-dev/caerus-sdk-java` → Settings → Secrets and variables → Actions, o con `gh`
(pide el valor sin mostrarlo):

| Secret | Valor |
|---|---|
| `CENTRAL_USERNAME` | El usuario del token |
| `CENTRAL_PASSWORD` | La clave del token |
| `GPG_PRIVATE_KEY` | `gpg --armor --export-secret-keys ID_DE_LA_CLAVE` |
| `GPG_PASSPHRASE` | La frase de la clave GPG |

```bash
gh secret set CENTRAL_USERNAME --repo caerus-dev/caerus-sdk-java
gh secret set CENTRAL_PASSWORD --repo caerus-dev/caerus-sdk-java
gh secret set GPG_PASSPHRASE --repo caerus-dev/caerus-sdk-java
gpg --armor --export-secret-keys ID_DE_LA_CLAVE | gh secret set GPG_PRIVATE_KEY --repo caerus-dev/caerus-sdk-java
```

La clave privada no se guarda en ningún archivo ni se pega en un chat.

## Cada versión

1. Que `main` tenga lo que se publica y el CI esté verde.
2. Crear y subir el tag:

```bash
git tag v0.1.0
git push origin v0.1.0
```

3. El workflow pone esa versión en el `pom.xml` (no se commitea), corre los tests, firma y
sube el bundle. Central lo valida.
4. En central.sonatype.com → **Deployments** aparece como **Validated**. Revisarlo y apretar
**Publish**. A partir de ahí no se puede borrar ni pisar esa versión.
5. Aparece en Maven Central en unos 30 minutos.

Si la validación falla, el deployment queda en el portal con el motivo y se puede descartar
con **Drop**; nada se publicó.

## Qué va en el bundle

El jar, el `.pom`, el jar de fuentes, el de javadoc (solo con los paquetes públicos; el
código no tiene Javadoc, así que es la lista de clases y firmas), las firmas `.asc` y los
checksums. Se puede armar localmente sin firmar ni subir para revisarlo con
`mvn -Prelease package -Dgpg.skip`.
85 changes: 85 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,26 @@
</license>
</licenses>

<developers>
<developer>
<id>caerus-dev</id>
<name>Caerus</name>
<organization>Caerus</organization>
<organizationUrl>https://github.com/caerus-dev</organizationUrl>
</developer>
</developers>

<scm>
<url>https://github.com/caerus-dev/caerus-sdk-java</url>
<connection>scm:git:https://github.com/caerus-dev/caerus-sdk-java.git</connection>
<developerConnection>scm:git:https://github.com/caerus-dev/caerus-sdk-java.git</developerConnection>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/caerus-dev/caerus-sdk-java/issues</url>
</issueManagement>

<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -237,6 +252,76 @@
</build>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.12.0</version>
<configuration>
<release>17</release>
<doclint>none</doclint>
<quiet>true</quiet>
<excludePackageNames>dev.caerus.sdk.internal:dev.caerus.sdk.internal.*</excludePackageNames>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.8</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.11.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>false</autoPublish>
<waitUntil>validated</waitUntil>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>live</id>
<properties>
Expand Down
Loading