Skip to content

Commit 478b1f6

Browse files
authored
Update release_conda.yml
1 parent 485fa19 commit 478b1f6

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

.github/workflows/release_conda.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
name: Release Conda
22

33
on:
4-
# Solo se ejecuta en 'release' para asegurar que siempre haya una etiqueta válida
4+
# Se ejecuta tanto en release como en push
55
release:
66
types: [published]
7-
# Mantengo estos activadores, pero la versión será '0.0.0-dev' o 'latest'
87
push:
98
branches: [conda_cd]
109
workflow_dispatch:
@@ -14,9 +13,12 @@ jobs:
1413
runs-on: ubuntu-22.04
1514

1615
steps:
17-
- name: Checkout repository
16+
- name: Checkout repository and fetch tags
1817
uses: actions/checkout@v4
19-
18+
with:
19+
# CLAVE: Descarga el historial completo y las etiquetas para 'git describe'
20+
fetch-depth: 0
21+
2022
# 1. Configurar Miniconda y Mamba
2123
- name: Setup Miniconda and Conda Tools
2224
uses: conda-incubator/setup-miniconda@v3
@@ -40,25 +42,47 @@ jobs:
4042
run: |
4143
conda run anaconda config --set upload_token ${{ secrets.ANACONDA_TOKEN }}
4244
43-
# 4. Construir y Subir el Paquete (Dinámicamente)
45+
# 4. Construir y Subir el Paquete (Usando la Última Etiqueta de Git)
4446
- name: Conda Build and Upload Package
4547
shell: bash
4648
run: |
4749
CONDA_RECIPE_DIR=".github/conda"
4850
ANACONDA_CHANNEL="ctlearn-project"
49-
FULL_TAG="${{ github.event.release.tag_name }}"
51+
TEST_FLAG="--no-test" # Asumimos que quieres saltarte el test siempre
52+
53+
# ------------------------------------------------------------------
54+
# CLAVE: Lógica robusta para obtener la última etiqueta
55+
# ------------------------------------------------------------------
56+
# Intentar obtener la última etiqueta de Git y eliminar el prefijo 'v'
57+
# '|| echo "0.0.0+dev"' proporciona un valor de respaldo si no hay etiquetas.
58+
FULL_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0+dev")
59+
60+
# Eliminar el prefijo 'v' o 'V'
5061
VERSION="${FULL_TAG#v}"
51-
VERSION="${VERSION#V}"
62+
VERSION="${VERSION#V}"
63+
64+
# Si estamos en un release, nos aseguramos de que el TEST_FLAG no se use
65+
# si el meta.yaml no requiere ser saltado.
66+
if [[ "${{ github.event_name }}" == "release" ]]; then
67+
TEST_FLAG=""
68+
fi
69+
5270
echo "Building package version: $VERSION"
5371
54-
# --- FASE DE CONSTRUCCIÓN ---
55-
# 1. Pasamos la versión como variable de entorno PACKAGE_VERSION
56-
conda run PACKAGE_VERSION=$VERSION conda build $CONDA_RECIPE_DIR --no-test
72+
# Exportamos la variable para que sea leída por meta.yaml
73+
export PACKAGE_VERSION=$VERSION
74+
75+
# 1. --- FASE DE CONSTRUCCIÓN ---
76+
conda run conda build $CONDA_RECIPE_DIR $TEST_FLAG
5777
5878
# 2. --- FASE DE SUBIDA ---
59-
# Obtenemos la ruta del paquete construido
60-
PACKAGE_PATH=$(conda run PACKAGE_VERSION=$VERSION conda build $CONDA_RECIPE_DIR --output --no-test)
79+
# Obtenemos la ruta (Necesitamos 'export' y 'conda run' de nuevo)
80+
PACKAGE_PATH=$(conda run conda build $CONDA_RECIPE_DIR --output)
6181
62-
# 3. Subimos el archivo
63-
echo "Uploading $PACKAGE_PATH to $ANACONDA_CHANNEL channel..."
64-
conda run anaconda upload "$PACKAGE_PATH" --force --user $ANACONDA_CHANNEL
82+
# 3. Subimos el archivo (Solo si no es una versión de desarrollo)
83+
if [[ "$VERSION" != "0.0.0+dev" ]]; then
84+
echo "Uploading $PACKAGE_PATH to $ANACONDA_CHANNEL channel..."
85+
conda run anaconda upload "$PACKAGE_PATH" --force --user $ANACONDA_CHANNEL
86+
else
87+
echo "Skipping upload: Version is $VERSION (development)."
88+
fi

0 commit comments

Comments
 (0)