Skip to content

Commit d42f59e

Browse files
committed
2 parents 544af38 + 69acdea commit d42f59e

File tree

1 file changed

+68
-21
lines changed

1 file changed

+68
-21
lines changed

.github/workflows/deploy.yml

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,90 @@
1-
name: Deploy to Maven Central
1+
name: Publicar a Maven Central
22

33
on:
4-
workflow_dispatch: # Permite ejecutar manualmente desde GitHub Actions
4+
workflow_dispatch:
5+
inputs:
6+
release_notes:
7+
description: 'Notas de la versión'
8+
required: false
9+
default: 'Nueva versión de la biblioteca FiscalAPI'
510

611
jobs:
7-
deploy:
12+
publish:
813
runs-on: ubuntu-latest
914
steps:
10-
- name: Checkout code
15+
- name: Checkout del código
1116
uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.ref_name }}
1219

13-
- name: Set up Java
20+
- name: Configurar Java
1421
uses: actions/setup-java@v3
1522
with:
23+
java-version: '8'
1624
distribution: 'temurin'
17-
java-version: '17'
18-
server-id: central
19-
server-username: MAVEN_USERNAME
20-
server-password: MAVEN_PASSWORD
21-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
22-
gpg-passphrase: MAVEN_GPG_PASSPHRASE
23-
24-
- name: Extract version from POM
25+
cache: maven
26+
27+
- name: Extraer versión del POM
2528
id: get_version
26-
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
29+
run: |
30+
VERSION=$(grep -m 1 "<version>" pom.xml | sed 's/<version>//g' | sed 's/<\/version>//g' | xargs)
31+
echo "Versión extraída del POM: $VERSION"
32+
echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
34+
- name: Configurar GPG
35+
run: |
36+
# Crear directorio para las claves GPG
37+
mkdir -p ~/.gnupg/
38+
chmod 700 ~/.gnupg/
39+
40+
# Importar claves GPG
41+
echo "${{ secrets.GPG_PUBLIC_KEY }}" | gpg --import
42+
echo "${{ secrets.GPG_SECRET_KEY }}" | gpg --import --no-tty --batch --yes
43+
44+
# Verificar que las claves se hayan importado correctamente
45+
gpg --list-secret-keys --keyid-format LONG
2746
28-
- name: Build and Publish
29-
run: mvn clean deploy -P release
47+
- name: Verificar settings.xml
48+
run: |
49+
if [ -f "settings.xml" ]; then
50+
echo "El archivo settings.xml existe."
51+
else
52+
echo "Error: No se encontró el archivo settings.xml"
53+
exit 1
54+
fi
55+
56+
- name: Desplegar a Maven Central
3057
env:
3158
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
3259
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
33-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
3460
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
61+
run: |
62+
mvn clean deploy -P release --settings settings.xml -DskipTests=true
3563
36-
- name: Create GitHub Release
64+
- name: Crear GitHub Release
65+
if: success()
3766
uses: softprops/action-gh-release@v1
3867
with:
39-
tag_name: v${{ env.VERSION }}
40-
name: Release v${{ env.VERSION }}
41-
body: "New release v${{ env.VERSION }} deployed to Maven Central."
68+
tag_name: v${{ steps.get_version.outputs.version }}
69+
name: FiscalAPI ${{ steps.get_version.outputs.version }}
70+
body: ${{ github.event.inputs.release_notes }}
4271
draft: false
4372
prerelease: false
73+
files: |
74+
target/fiscalapi-${{ steps.get_version.outputs.version }}.jar
75+
target/fiscalapi-${{ steps.get_version.outputs.version }}-javadoc.jar
76+
target/fiscalapi-${{ steps.get_version.outputs.version }}-sources.jar
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- name: Notificar resultado
81+
if: always()
82+
run: |
83+
VERSION="${{ steps.get_version.outputs.version }}"
84+
if [ "${{ job.status }}" == "success" ]; then
85+
echo "✅ Biblioteca publicada exitosamente en Maven Central"
86+
echo "La biblioteca debería estar disponible pronto en: https://central.sonatype.com/artifact/com.fiscalapi/fiscalapi/$VERSION"
87+
else
88+
echo "❌ Error al publicar la biblioteca"
89+
echo "Por favor, revisa los logs para más detalles."
90+
fi

0 commit comments

Comments
 (0)