Update release_conda.yml #66
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: | |
| # Se ejecuta tanto en release como en push | |
| 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 para 'git describe' | |
| 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 | |
| run: | | |
| conda run anaconda config --set upload_token ${{ secrets.ANACONDA_TOKEN }} | |
| # 4. Construir y Subir el Paquete (Token Directo) | |
| - name: Conda Build and Upload Package | |
| shell: bash | |
| # Definimos el token aquí para poder usarlo en el script | |
| env: | |
| ANACONDA_UPLOAD_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | |
| 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 | |
| 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 | |
| # 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: Forzar el token usando --token $ANACONDA_UPLOAD_TOKEN | |
| conda run anaconda upload \ | |
| "$PACKAGE_PATH" \ | |
| --force \ | |
| --user $ANACONDA_CHANNEL \ | |
| -t $ANACONDA_UPLOAD_TOKEN | |
| else | |
| echo "Skipping upload: Version is $VERSION (development)." | |
| fi |