Files
mini/publish_gitea.sh

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
if [ -z "$1" ]; then
echo "Uso: $0 <PARAMETRO>"
exit 1
fi
GITEA_TOKEN="eb44d9c0142f5038c61c5afd17f5a41177bfaedc"
if [ -z "$GITEA_TOKEN" ]; then
echo "ERROR: Debes exportar GITEA_TOKEN"
exit 1
fi
PARAM=$1
API="https://gitea.sustancia.synology.me/api/v1"
REPO="JailDoctor/mini"
echo "=== Creando release ${PARAM} en Gitea ==="
RELEASE_ID=$(curl -s -X POST "${API}/repos/${REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${PARAM}\",
\"name\": \"Release ${PARAM}\",
\"draft\": false,
\"prerelease\": false
}" | jq -r '.id')
if [ "$RELEASE_ID" = "null" ]; then
echo "ERROR: No se pudo crear el release"
exit 1
fi
echo "Release creado con ID: $RELEASE_ID"
echo "=== Subiendo artefactos ==="
for f in mini_${PARAM}_linux_release.tar.gz \
mini_${PARAM}_linux_debug.tar.gz \
mini_${PARAM}_windows_release.zip \
mini_${PARAM}_windows_debug.zip
do
echo "Subiendo $f..."
curl -s -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@${f}" \
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets" > /dev/null
done
echo "=== Publicación completada ==="