Skip to content

Commit 062b67d

Browse files
committed
Add GitHub Actions workflow for automated release creation
1 parent 7aaf130 commit 062b67d

1 file changed

Lines changed: 157 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- '[0-9]+.[0-9]+.[0-9]+'
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
name: Create Release
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Get tag version
24+
id: get_version
25+
run: |
26+
VERSION=${GITHUB_REF#refs/tags/}
27+
VERSION=${VERSION#v}
28+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
29+
echo "Creating release for version: $VERSION"
30+
31+
- name: Validate version format
32+
run: |
33+
VERSION=${{ steps.get_version.outputs.VERSION }}
34+
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+
echo "❌ Error: Tag version must follow semantic versioning (e.g., 0.3.2)"
36+
exit 1
37+
fi
38+
echo "✅ Version format is valid: $VERSION"
39+
40+
- name: Create release directory
41+
run: |
42+
mkdir -p release/integration-alegra-woo
43+
echo "✅ Release directory created"
44+
45+
- name: Copy plugin files
46+
run: |
47+
echo "📦 Copying plugin files..."
48+
49+
# Copiar archivos y directorios principales
50+
cp -r assets release/integration-alegra-woo/
51+
cp -r includes release/integration-alegra-woo/
52+
cp -r lib release/integration-alegra-woo/
53+
54+
# Copiar vendor solo si existe
55+
if [ -d vendor ]; then
56+
cp -r vendor release/integration-alegra-woo/
57+
fi
58+
59+
# Copiar archivos raíz
60+
cp integration-alegra-woo.php release/integration-alegra-woo/
61+
cp readme.txt release/integration-alegra-woo/
62+
63+
echo "✅ Files copied successfully"
64+
65+
- name: Verify plugin structure
66+
run: |
67+
echo "📋 Verifying plugin structure..."
68+
ls -la release/integration-alegra-woo/
69+
70+
# Verificar que existe el archivo principal del plugin
71+
if [ ! -f release/integration-alegra-woo/integration-alegra-woo.php ]; then
72+
echo "❌ Error: Main plugin file not found!"
73+
exit 1
74+
fi
75+
76+
echo "✅ Plugin structure verified"
77+
78+
- name: Create ZIP file
79+
run: |
80+
cd release
81+
zip -r ../integration-alegra-woo.zip integration-alegra-woo/ -x "*.git*" "*.DS_Store"
82+
cd ..
83+
84+
# Verificar que el ZIP se creó correctamente
85+
if [ ! -f integration-alegra-woo.zip ]; then
86+
echo "❌ Error: ZIP file was not created!"
87+
exit 1
88+
fi
89+
90+
# Mostrar tamaño del archivo
91+
ZIP_SIZE=$(du -h integration-alegra-woo.zip | cut -f1)
92+
echo "✅ ZIP created successfully (Size: $ZIP_SIZE)"
93+
94+
- name: Generate changelog from commits
95+
id: changelog
96+
run: |
97+
echo "📝 Generating changelog..."
98+
99+
# Obtener el tag anterior
100+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
101+
102+
if [ -z "$PREV_TAG" ]; then
103+
echo "CHANGELOG=Primera release del plugin" >> $GITHUB_OUTPUT
104+
else
105+
# Generar changelog desde el último tag
106+
CHANGELOG=$(git log $PREV_TAG..HEAD --pretty=format:"- %s" --no-merges)
107+
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
108+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
109+
echo "EOF" >> $GITHUB_OUTPUT
110+
fi
111+
112+
- name: Create Release
113+
uses: softprops/action-gh-release@v1
114+
with:
115+
name: Release ${{ steps.get_version.outputs.VERSION }}
116+
body: |
117+
## 🎉 Integration Alegra WooCommerce v${{ steps.get_version.outputs.VERSION }}
118+
119+
### 📦 Instalación
120+
121+
1. Descarga el archivo `integration-alegra-woo.zip` adjunto abajo
122+
2. Ve a **WordPress** → **Plugins** → **Añadir nuevo** → **Subir plugin**
123+
3. Selecciona el archivo ZIP y haz clic en **"Instalar ahora"**
124+
4. Activa el plugin y configura tus credenciales de Alegra
125+
126+
### 📋 Cambios en esta versión
127+
128+
${{ steps.changelog.outputs.CHANGELOG }}
129+
130+
### ℹ️ Requisitos
131+
132+
- WordPress 6.0 o superior
133+
- WooCommerce 9.6 o superior
134+
- PHP 8.1 o superior
135+
- Plugin: Departamentos y Ciudades de Colombia para WooCommerce
136+
137+
### 📚 Documentación
138+
139+
Para ver el changelog completo y documentación detallada, consulta el archivo `readme.txt` incluido en el plugin.
140+
141+
### 🔗 Enlaces
142+
143+
- [Sitio web del desarrollador](https://saulmoralespa.com)
144+
- [Soporte](https://saulmoralespa.com)
145+
- [LinkedIn](https://www.linkedin.com/in/saulmoralespa/)
146+
147+
---
148+
149+
**Nota**: Este es un plugin para integración con Alegra Colombia. Asegúrate de tener una cuenta activa en Alegra y tus credenciales API antes de instalar.
150+
files: |
151+
integration-alegra-woo.zip
152+
draft: false
153+
prerelease: false
154+
generate_release_notes: false
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+

0 commit comments

Comments
 (0)