repo comprimido
All checks were successful
Tar y Zip por version / archive (push) Successful in 5s

This commit is contained in:
Kristina 2026-05-17 23:51:46 +02:00
parent 22c5b5e502
commit b8b6e87a89

View file

@ -1,72 +1,29 @@
name: Build and Release name: Tar y Zip por version
on: on:
push: push:
tags: tags:
- 'v*' - 'v*' # se ejecuta al hacer push de tags tipo v1.0.0
jobs: jobs:
build-and-release: archive:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Ejecutar build - name: Crear tar y zip de la version
run: | run: |
mkdir -p release-dir mkdir -p artifacts
echo "# Documento convertido" > release-dir/documento.md
echo "" >> release-dir/documento.md
cat archivo.txt >> release-dir/documento.md
echo "Release $(date +%Y-%m-%d)" > release-dir/version.txt
echo "Build completado"
ls -lh release-dir/
- name: Crear release # Nombre de la tag que ha disparado el workflow (ej: v1.0.0)
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}" TAG="${GITHUB_REF_NAME}"
echo "Version/tag actual: $TAG"
JSON_PAYLOAD=$(cat <<EOF
{ # Tar.gz y zip solo con archivos del repo en esa tag
"tag_name": "${TAG}", git archive --format=tar.gz --output="artifacts/repo-${TAG}.tar.gz" "$TAG"
"name": "Release ${TAG}", git archive --format=zip --output="artifacts/repo-${TAG}.zip" "$TAG"
"body": "Release automatico",
"draft": false, echo "Articulos generados en artifacts/"
"prerelease": false ls -lh artifacts
}
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 -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"