This commit is contained in:
parent
22c5b5e502
commit
b8b6e87a89
1 changed files with 16 additions and 59 deletions
|
|
@ -1,72 +1,29 @@
|
|||
name: Build and Release
|
||||
name: Tar y Zip por version
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- 'v*' # se ejecuta al hacer push de tags tipo v1.0.0
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
archive:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Ejecutar build
|
||||
- name: Crear tar y zip de la version
|
||||
run: |
|
||||
mkdir -p release-dir
|
||||
echo "# Documento convertido" > release-dir/documento.md
|
||||
echo "" >> release-dir/documento.md
|
||||
cat archivo.txt >> release-dir/documento.md
|
||||
echo "Release $(date +%Y-%m-%d)" > release-dir/version.txt
|
||||
echo "Build completado"
|
||||
ls -lh release-dir/
|
||||
mkdir -p artifacts
|
||||
|
||||
- name: Crear release
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
run: |
|
||||
# Nombre de la tag que ha disparado el workflow (ej: v1.0.0)
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
echo "Version/tag actual: $TAG"
|
||||
|
||||
JSON_PAYLOAD=$(cat <<EOF
|
||||
{
|
||||
"tag_name": "${TAG}",
|
||||
"name": "Release ${TAG}",
|
||||
"body": "Release automatico",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
EOF
|
||||
)
|
||||
# Tar.gz y zip solo con archivos del repo en esa tag
|
||||
git archive --format=tar.gz --output="artifacts/repo-${TAG}.tar.gz" "$TAG"
|
||||
git archive --format=zip --output="artifacts/repo-${TAG}.zip" "$TAG"
|
||||
|
||||
echo "Creando release para tag: ${TAG}"
|
||||
|
||||
RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "${JSON_PAYLOAD}" \
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases")
|
||||
|
||||
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"
|
||||
echo "Articulos generados en artifacts/"
|
||||
ls -lh artifacts
|
||||
Loading…
Reference in a new issue