con token 4
All checks were successful
Build and Release / build-and-release (push) Successful in 7s

This commit is contained in:
Kristina 2026-05-16 17:39:54 +02:00
parent 7e1e41c789
commit f209927867

View file

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