repo comprimido 2
All checks were successful
Build tar/zip y Release por version / build-and-release (push) Successful in 16s
All checks were successful
Build tar/zip y Release por version / build-and-release (push) Successful in 16s
This commit is contained in:
parent
b8b6e87a89
commit
3086cc7523
1 changed files with 63 additions and 10 deletions
|
|
@ -1,29 +1,82 @@
|
||||||
name: Tar y Zip por version
|
name: Build tar/zip y Release por version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # se ejecuta al hacer push de tags tipo v1.0.0
|
- 'v*' # Se ejecuta al pushear tags como v1.0.0, v0.1.0, etc.
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
archive:
|
build-and-release:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Preparar entorno
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y jq
|
||||||
|
|
||||||
- name: Crear tar y zip de la version
|
- name: Crear tar y zip de la version
|
||||||
run: |
|
run: |
|
||||||
mkdir -p artifacts
|
mkdir -p release-dir
|
||||||
|
|
||||||
# Nombre de la tag que ha disparado el workflow (ej: v1.0.0)
|
|
||||||
TAG="${GITHUB_REF_NAME}"
|
TAG="${GITHUB_REF_NAME}"
|
||||||
echo "Version/tag actual: $TAG"
|
echo "Version/tag actual: $TAG"
|
||||||
|
|
||||||
# Tar.gz y zip solo con archivos del repo en esa tag
|
# Empaquetar SOLO archivos versionados en esa tag
|
||||||
git archive --format=tar.gz --output="artifacts/repo-${TAG}.tar.gz" "$TAG"
|
git archive --format=tar.gz --output="release-dir/repo-${TAG}.tar.gz" "$TAG"
|
||||||
git archive --format=zip --output="artifacts/repo-${TAG}.zip" "$TAG"
|
git archive --format=zip --output="release-dir/repo-${TAG}.zip" "$TAG"
|
||||||
|
|
||||||
echo "Articulos generados en artifacts/"
|
echo "Contenido de release-dir/"
|
||||||
ls -lh artifacts
|
ls -lh release-dir
|
||||||
|
|
||||||
|
- name: Crear release y subir assets
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
|
||||||
|
JSON_PAYLOAD=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"tag_name": "${TAG}",
|
||||||
|
"name": "Release ${TAG}",
|
||||||
|
"body": "Release automatico a partir de la tag ${TAG}",
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
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 -s -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