Compare commits

...

1 commit
v2.1.2 ... main

Author SHA1 Message Date
Kristina
f209927867 con token 4
All checks were successful
Build and Release / build-and-release (push) Successful in 7s
2026-05-16 17:39:54 +02:00

View file

@ -1,49 +1,72 @@
- name: Crear release con debug name: Build and Release
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} on:
push:
tags:
- 'v*'
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Ejecutar build
run: | run: |
echo "=== Debug de token ===" mkdir -p release-dir
if [ -z "$RELEASE_TOKEN" ]; then echo "# Documento convertido" > release-dir/documento.md
echo "❌ ERROR: RELEASE_TOKEN está vacío" echo "" >> release-dir/documento.md
exit 1 cat archivo.txt >> release-dir/documento.md
else echo "Release $(date +%Y-%m-%d)" > release-dir/version.txt
echo "✅ Token presente (longitud: ${#RELEASE_TOKEN})" echo "Build completado"
fi ls -lh release-dir/
tag="${GITHUB_REF_NAME}" - name: Crear release
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
echo "=== Creando release ===" JSON_PAYLOAD=$(cat <<EOF
release_response=$(curl -s -w "\nHTTP:%{http_code}" -X POST \ {
-H "Authorization: token ${RELEASE_TOKEN}" \ "tag_name": "${TAG}",
"name": "Release ${TAG}",
"body": "Release automatico",
"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" \ -H "Content-Type: application/json" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \ -d "${JSON_PAYLOAD}" \
-d "{ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases")
\"tag_name\": \"${tag}\",
\"name\": \"Release ${tag}\",
\"body\": \"Release automático\",
\"draft\": false,
\"prerelease\": false
}")
echo "$release_response" echo "Respuesta: ${RESPONSE}"
http_code=$(echo "$release_response" | grep "HTTP:" | cut -d: -f2) RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id')
echo "Status HTTP: $http_code"
if [ "$http_code" = "201" ]; then if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
release_id=$(echo "$release_response" | grep -v "HTTP:" | jq -r '.id') echo "Error creando release"
echo "✅ Release ID: $release_id"
for file in release-dir/*; do
filename=$(basename "$file")
echo "Subiendo $filename..."
curl -X POST \
-H "Authorization: token ${RELEASE_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${filename}"
done
else
echo "❌ Error creando release"
exit 1 exit 1
fi 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"