prueba-releases/.gitea/workflows/ci.yaml
Kristina 3086cc7523
All checks were successful
Build tar/zip y Release por version / build-and-release (push) Successful in 16s
repo comprimido 2
2026-05-18 00:02:14 +02:00

82 lines
No EOL
2.4 KiB
YAML

name: Build tar/zip y Release por version
on:
push:
tags:
- 'v*' # Se ejecuta al pushear tags como v1.0.0, v0.1.0, etc.
jobs:
build-and-release:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Preparar entorno
run: |
apt-get update
apt-get install -y jq
- name: Crear tar y zip de la version
run: |
mkdir -p release-dir
TAG="${GITHUB_REF_NAME}"
echo "Version/tag actual: $TAG"
# Empaquetar SOLO archivos versionados en esa tag
git archive --format=tar.gz --output="release-dir/repo-${TAG}.tar.gz" "$TAG"
git archive --format=zip --output="release-dir/repo-${TAG}.zip" "$TAG"
echo "Contenido de release-dir/"
ls -lh release-dir
- name: Crear release y subir assets
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
JSON_PAYLOAD=$(cat <<EOF
{
"tag_name": "${TAG}",
"name": "Release ${TAG}",
"body": "Release automatico a partir de la tag ${TAG}",
"draft": false,
"prerelease": false
}
EOF
)
echo "Creando release para tag: ${TAG}"
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "${JSON_PAYLOAD}" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases")
echo "Respuesta: ${RESPONSE}"
RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id')
if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
echo "Error creando release"
exit 1
fi
echo "Release creado con ID: ${RELEASE_ID}"
for FILE in release-dir/*; do
FILENAME=$(basename "${FILE}")
echo "Subiendo ${FILENAME}..."
curl -s -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"${FILE}" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
done
echo "Release completado correctamente"