Update release_conda.yml #67
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Conda | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| branches: [conda_cd] | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout repository and fetch tags | |
| uses: actions/checkout@v4 | |
| with: | |
| # CLAVE: Descarga el historial completo y las etiquetas | |
| fetch-depth: 0 | |
| # 1. Configurar Miniconda y Mamba | |
| - name: Setup Miniconda and Conda Tools | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| python-version: '3.10' | |
| channels: conda-forge,defaults | |
| auto-install-conda: true | |
| auto-update-conda: true | |
| mamba-version: "*" | |
| activate-environment: false | |
| # 2. INSTALACIÓN DE HERRAMIENTAS DE DESPLIEGUE | |
| - name: Install anaconda-client and conda-build | |
| shell: bash | |
| run: | | |
| mamba install anaconda-client conda-build -y | |
| # 3. Configurar Autenticación para Anaconda.org | |
| - name: Configure Anaconda Token | |
| shell: bash | |
| # Usamos el secreto para establecer la configuración global del cliente de Anaconda | |
| run: | | |
| conda run anaconda config --set upload_token ${{ secrets.ANACONDA_TOKEN }} | |
| # 4. Construir y Subir el Paquete (Subida Limpia) | |
| - name: Conda Build and Upload Package | |
| shell: bash | |
| # Quitamos la variable 'env: ANACONDA_UPLOAD_TOKEN' de este paso | |
| run: | | |
| CONDA_RECIPE_DIR=".github/conda" | |
| ANACONDA_CHANNEL="ctlearn-project" | |
| TEST_FLAG="--no-test" # Asumimos que quieres saltarte el test siempre | |
| # 1. Lógica robusta para obtener la última etiqueta | |
| # Fallback: git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0+dev" | |
| FULL_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0+dev") | |
| VERSION="${FULL_TAG#v}" | |
| VERSION="${VERSION#V}" | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| TEST_FLAG="" | |
| fi | |
| echo "Building package version: $VERSION" | |
| export PACKAGE_VERSION=$VERSION # Pasa la versión al meta.yaml | |
| # 2. --- FASE DE CONSTRUCCIÓN --- | |
| conda run conda build $CONDA_RECIPE_DIR $TEST_FLAG | |
| # 3. --- FASE DE SUBIDA --- | |
| # Obtenemos la ruta del paquete (usando --output) | |
| PACKAGE_PATH=$(conda run conda build $CONDA_RECIPE_DIR --output) | |
| # 4. Subimos el archivo | |
| if [[ "$VERSION" != "0.0.0+dev" ]]; then | |
| echo "Uploading $PACKAGE_PATH to $ANACONDA_CHANNEL channel..." | |
| # CLAVE: ¡Subida sin flags de token! | |
| # El cliente de Anaconda usará la configuración del Paso 3. | |
| conda run anaconda upload \ | |
| "$PACKAGE_PATH" \ | |
| --force \ | |
| --user $ANACONDA_CHANNEL | |
| else | |
| echo "Skipping upload: Version is $VERSION (development)." | |
| fi |