From c525df9a3ab551e548f0ed430d67b0920e8390b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Rami=CC=81rez?= Date: Wed, 30 Sep 2026 23:50:49 -0600 Subject: [PATCH] ci: CD pipeline that publishes releases to Maven Central Co-Authored-By: Claude Fable 5 --- .github/workflows/cd.yml | 97 ++++++++++++++++++++++++++++++++++++++++ docs/en/ci.md | 34 +++++++++++++- docs/es/ci.md | 34 +++++++++++++- docs/fr/ci.md | 34 +++++++++++++- docs/pt/ci.md | 34 +++++++++++++- 5 files changed, 229 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..3e08018 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,97 @@ +name: CD + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: cd-${{ github.ref }} + cancel-in-progress: false + +jobs: + test: + name: Tests and coverage gate + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v7 + + - name: Set up JDK 17 + uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: 17 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Run unit tests and the coverage gate + run: ./gradlew testDebugUnitTest :openpay-sdk:jacocoCoverageVerification + + publish: + name: Publish to Maven Central + runs-on: ubuntu-latest + needs: test + steps: + - name: Check out the repository + uses: actions/checkout@v7 + + - name: Verify the tag matches the library version + if: github.ref_type == 'tag' + run: | + tag_version="${GITHUB_REF_NAME#v}" + gradle_version="$(grep '^VERSION_NAME=' gradle.properties | cut -d= -f2)" + if [ "$tag_version" != "$gradle_version" ]; then + echo "::error::Tag $GITHUB_REF_NAME does not match VERSION_NAME=$gradle_version in gradle.properties" + exit 1 + fi + + - name: Set up JDK 17 + uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: 17 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Publish the signed artifacts to the Central Portal staging API + env: + MAVEN_REPOSITORY_URL: https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/ + MAVEN_REPOSITORY_USERNAME: ${{ secrets.MAVEN_REPOSITORY_USERNAME }} + MAVEN_REPOSITORY_PASSWORD: ${{ secrets.MAVEN_REPOSITORY_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew :openpay-sdk:publishReleasePublicationToRemoteRepository + + - name: Remind about the manual portal release step + run: | + { + echo "## Deployment staged" + echo "" + echo "The signed artifacts were uploaded to the Central Portal." + echo "Go to https://central.sonatype.com → Publish → Deployments," + echo "wait for validation to pass and press **Publish** to release" + echo "to Maven Central. Nothing is public until that button is pressed." + } >> "$GITHUB_STEP_SUMMARY" + + github-release: + name: Create the GitHub release + runs-on: ubuntu-latest + needs: publish + if: github.ref_type == 'tag' + permissions: + contents: write + steps: + - name: Check out the repository + uses: actions/checkout@v7 + + - name: Create the release with generated notes + env: + GH_TOKEN: ${{ github.token }} + run: gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes diff --git a/docs/en/ci.md b/docs/en/ci.md index c7da3d2..265961e 100644 --- a/docs/en/ci.md +++ b/docs/en/ci.md @@ -42,4 +42,36 @@ Every pull request receives a single comment titled **Unit test coverage** that ./gradlew connectedDebugAndroidTest # requires a device or emulator ``` -The HTML report is generated at `/build/reports/jacoco/jacocoTestReport/html/index.html`. \ No newline at end of file +The HTML report is generated at `/build/reports/jacoco/jacocoTestReport/html/index.html`. + +## Continuous deployment + +A second workflow (`.github/workflows/cd.yml`) releases the library to +Maven Central. It runs when a version tag (`v1.2.3`) is pushed — normally +the tag on the `master` merge commit of a release — and can also be +started manually from the Actions tab. + +```mermaid +flowchart LR + A[Push tag v*] --> B[Unit tests + coverage gate] + B --> C[Check tag == VERSION_NAME] + C --> D[Sign and upload to the Central Portal] + D --> E[Manual Publish in central.sonatype.com] + D --> F[GitHub release with generated notes] +``` + +1. **Tests first** — the release is blocked unless the unit tests and the + 80% coverage gate pass. +2. **Version guard** — the workflow fails if the tag does not match + `VERSION_NAME` in `gradle.properties`, so a mistagged release cannot + ship. +3. **Signed upload** — artifacts are PGP-signed and uploaded to the + Sonatype Central Portal staging area. Credentials and the signing key + come from the repository secrets (`MAVEN_REPOSITORY_USERNAME`, + `MAVEN_REPOSITORY_PASSWORD`, `SIGNING_KEY`, `SIGNING_PASSWORD`); they + never live in the repository. +4. **Manual confirmation** — nothing becomes public automatically: a + maintainer must press **Publish** on the validated deployment at + [central.sonatype.com](https://central.sonatype.com). The run summary + links the step. +5. A GitHub release with generated notes is created for the tag. \ No newline at end of file diff --git a/docs/es/ci.md b/docs/es/ci.md index 7e264d2..ed1265e 100644 --- a/docs/es/ci.md +++ b/docs/es/ci.md @@ -42,4 +42,36 @@ Cada pull request recibe un único comentario titulado **Unit test coverage** qu ./gradlew connectedDebugAndroidTest # requiere un dispositivo o emulador ``` -El reporte HTML se genera en `/build/reports/jacoco/jacocoTestReport/html/index.html`. \ No newline at end of file +El reporte HTML se genera en `/build/reports/jacoco/jacocoTestReport/html/index.html`. + +## Despliegue continuo + +Un segundo workflow (`.github/workflows/cd.yml`) libera la librería a +Maven Central. Se ejecuta cuando se hace push de un tag de versión +(`v1.2.3`) — normalmente el tag del commit de merge de un release en +`master` — y también puede iniciarse manualmente desde la pestaña Actions. + +```mermaid +flowchart LR + A[Push del tag v*] --> B[Pruebas unitarias + umbral de cobertura] + B --> C[Verificar tag == VERSION_NAME] + C --> D[Firmar y subir al Central Portal] + D --> E[Publish manual en central.sonatype.com] + D --> F[Release de GitHub con notas generadas] +``` + +1. **Primero las pruebas** — el release se bloquea si las pruebas + unitarias o el umbral de cobertura del 80% fallan. +2. **Guarda de versión** — el workflow falla si el tag no coincide con + `VERSION_NAME` en `gradle.properties`, así un release mal etiquetado no + puede salir. +3. **Subida firmada** — los artefactos se firman con PGP y se suben al + área de staging del Central Portal de Sonatype. Las credenciales y la + llave de firma vienen de los secretos del repositorio + (`MAVEN_REPOSITORY_USERNAME`, `MAVEN_REPOSITORY_PASSWORD`, + `SIGNING_KEY`, `SIGNING_PASSWORD`); nunca viven en el repositorio. +4. **Confirmación manual** — nada se hace público automáticamente: una + persona mantenedora debe presionar **Publish** sobre el despliegue + validado en [central.sonatype.com](https://central.sonatype.com). El + resumen de la ejecución enlaza el paso. +5. Se crea un release de GitHub con notas generadas para el tag. \ No newline at end of file diff --git a/docs/fr/ci.md b/docs/fr/ci.md index 78fe28e..cf63f47 100644 --- a/docs/fr/ci.md +++ b/docs/fr/ci.md @@ -42,4 +42,36 @@ Chaque pull request reçoit un seul commentaire intitulé **Unit test coverage** ./gradlew connectedDebugAndroidTest # nécessite un appareil ou un émulateur ``` -Le rapport HTML est généré dans `/build/reports/jacoco/jacocoTestReport/html/index.html`. \ No newline at end of file +Le rapport HTML est généré dans `/build/reports/jacoco/jacocoTestReport/html/index.html`. + +## Déploiement continu + +Un second workflow (`.github/workflows/cd.yml`) publie la bibliothèque sur +Maven Central. Il s'exécute quand un tag de version (`v1.2.3`) est poussé — +normalement le tag du commit de merge d'une release sur `master` — et peut +aussi être lancé manuellement depuis l'onglet Actions. + +```mermaid +flowchart LR + A[Push du tag v*] --> B[Tests unitaires + seuil de couverture] + B --> C[Vérifier tag == VERSION_NAME] + C --> D[Signer et téléverser vers le Central Portal] + D --> E[Publish manuel sur central.sonatype.com] + D --> F[Release GitHub avec notes générées] +``` + +1. **Les tests d'abord** — la release est bloquée si les tests unitaires + ou le seuil de couverture de 80 % échouent. +2. **Garde de version** — le workflow échoue si le tag ne correspond pas à + `VERSION_NAME` dans `gradle.properties` ; une release mal étiquetée ne + peut donc pas partir. +3. **Téléversement signé** — les artefacts sont signés en PGP et envoyés + vers la zone de staging du Central Portal de Sonatype. Les identifiants + et la clé de signature proviennent des secrets du dépôt + (`MAVEN_REPOSITORY_USERNAME`, `MAVEN_REPOSITORY_PASSWORD`, + `SIGNING_KEY`, `SIGNING_PASSWORD`) ; ils ne vivent jamais dans le dépôt. +4. **Confirmation manuelle** — rien ne devient public automatiquement : + une personne mainteneuse doit appuyer sur **Publish** sur le déploiement + validé dans [central.sonatype.com](https://central.sonatype.com). Le + résumé de l'exécution pointe vers cette étape. +5. Une release GitHub avec notes générées est créée pour le tag. \ No newline at end of file diff --git a/docs/pt/ci.md b/docs/pt/ci.md index ce146a9..2d69bfc 100644 --- a/docs/pt/ci.md +++ b/docs/pt/ci.md @@ -42,4 +42,36 @@ Cada pull request recebe um único comentário intitulado **Unit test coverage** ./gradlew connectedDebugAndroidTest # requer um dispositivo ou emulador ``` -O relatório HTML é gerado em `/build/reports/jacoco/jacocoTestReport/html/index.html`. \ No newline at end of file +O relatório HTML é gerado em `/build/reports/jacoco/jacocoTestReport/html/index.html`. + +## Deploy contínuo + +Um segundo workflow (`.github/workflows/cd.yml`) libera a biblioteca no +Maven Central. Ele roda quando um tag de versão (`v1.2.3`) é enviado — +normalmente o tag do commit de merge de um release em `master` — e também +pode ser iniciado manualmente na aba Actions. + +```mermaid +flowchart LR + A[Push do tag v*] --> B[Testes unitários + limite de cobertura] + B --> C[Verificar tag == VERSION_NAME] + C --> D[Assinar e enviar ao Central Portal] + D --> E[Publish manual em central.sonatype.com] + D --> F[Release do GitHub com notas geradas] +``` + +1. **Testes primeiro** — o release é bloqueado se os testes unitários ou o + limite de cobertura de 80% falharem. +2. **Guarda de versão** — o workflow falha se o tag não corresponder ao + `VERSION_NAME` em `gradle.properties`; um release com tag errado não + consegue sair. +3. **Envio assinado** — os artefatos são assinados com PGP e enviados à + área de staging do Central Portal da Sonatype. As credenciais e a chave + de assinatura vêm dos secrets do repositório + (`MAVEN_REPOSITORY_USERNAME`, `MAVEN_REPOSITORY_PASSWORD`, + `SIGNING_KEY`, `SIGNING_PASSWORD`); elas nunca vivem no repositório. +4. **Confirmação manual** — nada se torna público automaticamente: uma + pessoa mantenedora precisa pressionar **Publish** no deployment + validado em [central.sonatype.com](https://central.sonatype.com). O + resumo da execução aponta para essa etapa. +5. Um release do GitHub com notas geradas é criado para o tag. \ No newline at end of file