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:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*' # se ejecuta al hacer push de tags tipo v1.0.0
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-release:
|
archive:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Ejecutar build
|
- name: Crear tar y zip de la version
|
||||||
run: |
|
run: |
|
||||||
mkdir -p release-dir
|
mkdir -p artifacts
|
||||||
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/
|
|
||||||
|
|
||||||
- name: Crear release
|
# Nombre de la tag que ha disparado el workflow (ej: v1.0.0)
|
||||||
env:
|
|
||||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
||||||
run: |
|
|
||||||
TAG="${GITHUB_REF_NAME}"
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
echo "Version/tag actual: $TAG"
|
||||||
|
|
||||||
JSON_PAYLOAD=$(cat <<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"
|
||||||
"tag_name": "${TAG}",
|
git archive --format=zip --output="artifacts/repo-${TAG}.zip" "$TAG"
|
||||||
"name": "Release ${TAG}",
|
|
||||||
"body": "Release automatico",
|
|
||||||
"draft": false,
|
|
||||||
"prerelease": false
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
echo "Creando release para tag: ${TAG}"
|
echo "Articulos generados en artifacts/"
|
||||||
|
ls -lh artifacts
|
||||||
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"
|
|
||||||
Loading…
Reference in a new issue