con token 3
This commit is contained in:
parent
43c152ac0b
commit
7e1e41c789
1 changed files with 49 additions and 52 deletions
|
|
@ -1,52 +1,49 @@
|
||||||
name: Build and Release
|
- name: Crear release con debug
|
||||||
|
env:
|
||||||
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
echo "=== Debug de token ==="
|
||||||
|
if [ -z "$RELEASE_TOKEN" ]; then
|
||||||
|
echo "❌ ERROR: RELEASE_TOKEN está vacío"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "✅ Token presente (longitud: ${#RELEASE_TOKEN})"
|
||||||
|
fi
|
||||||
|
|
||||||
on:
|
tag="${GITHUB_REF_NAME}"
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
echo "=== Creando release ==="
|
||||||
build-and-release:
|
release_response=$(curl -s -w "\nHTTP:%{http_code}" -X POST \
|
||||||
runs-on: ubuntu-latest
|
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||||
steps:
|
-H "Content-Type: application/json" \
|
||||||
- name: Checkout
|
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \
|
||||||
uses: actions/checkout@v4
|
-d "{
|
||||||
|
\"tag_name\": \"${tag}\",
|
||||||
|
\"name\": \"Release ${tag}\",
|
||||||
|
\"body\": \"Release automático\",
|
||||||
|
\"draft\": false,
|
||||||
|
\"prerelease\": false
|
||||||
|
}")
|
||||||
|
|
||||||
- name: Ejecutar script de build
|
echo "$release_response"
|
||||||
run: bash build.sh
|
|
||||||
|
|
||||||
- name: Crear release con los archivos generados
|
http_code=$(echo "$release_response" | grep "HTTP:" | cut -d: -f2)
|
||||||
env:
|
echo "Status HTTP: $http_code"
|
||||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
||||||
run: |
|
|
||||||
tag="${GITHUB_REF_NAME}"
|
|
||||||
|
|
||||||
# Crear el release
|
if [ "$http_code" = "201" ]; then
|
||||||
release_response=$(curl -s -X POST \
|
release_id=$(echo "$release_response" | grep -v "HTTP:" | jq -r '.id')
|
||||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
echo "✅ Release ID: $release_id"
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\": \"${tag}\",
|
|
||||||
\"name\": \"Release ${tag}\",
|
|
||||||
\"body\": \"Release automático generado por build.sh\",
|
|
||||||
\"draft\": false,
|
|
||||||
\"prerelease\": false
|
|
||||||
}")
|
|
||||||
|
|
||||||
echo "$release_response"
|
for file in release-dir/*; do
|
||||||
release_id=$(echo "$release_response" | jq -r '.id')
|
filename=$(basename "$file")
|
||||||
echo "Release creado con ID: $release_id"
|
echo "Subiendo $filename..."
|
||||||
|
curl -X POST \
|
||||||
# Subir todos los archivos que generó el script
|
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||||
for file in release-dir/*; do
|
-H "Content-Type: application/octet-stream" \
|
||||||
filename=$(basename "$file")
|
--data-binary @"$file" \
|
||||||
echo "Subiendo $filename al release..."
|
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${filename}"
|
||||||
curl -X POST \
|
done
|
||||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
else
|
||||||
-H "Content-Type: application/octet-stream" \
|
echo "❌ Error creando release"
|
||||||
--data-binary @"$file" \
|
exit 1
|
||||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${filename}"
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
echo "Release completado con todos los archivos"
|
|
||||||
Loading…
Reference in a new issue