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