From 1c22f7d42140c32ce5dc273e6ad18a39564eee93 Mon Sep 17 00:00:00 2001 From: ssun30 Date: Thu, 21 Nov 2024 18:40:03 -0500 Subject: [PATCH] Fixed Conda build by: >> Setting the condarc file to only use the conda-forge channel >> Use Miniforge3 instead of Miniconda3 with the libmamba solver --- .github/workflows/conda_build.yml | 38 +++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/conda_build.yml b/.github/workflows/conda_build.yml index 0aa2abe261..35ec3430ee 100644 --- a/.github/workflows/conda_build.yml +++ b/.github/workflows/conda_build.yml @@ -13,24 +13,48 @@ jobs: shell: bash -l {0} steps: - uses: actions/checkout@v4 + + # Step to create a custom condarc.yml before setting up conda + - name: Create custom conda config file + run: | + RUNNER_CWD=$(pwd) + echo "channels:" > $RUNNER_CWD/condarc.yml + echo " - conda-forge" >> $RUNNER_CWD/condarc.yml + echo "show_channel_urls: true" >> $RUNNER_CWD/condarc.yml + - name: Setup Conda uses: conda-incubator/setup-miniconda@v3 with: + miniforge-variant: Miniforge3 + miniforge-version: latest + use-mamba: true + condarc-file: condarc.yml auto-update-conda: false - conda-solver: libmamba auto-activate-base: true activate-environment: "" + - name: Install Build Tools - run: conda install python anaconda-client conda-build + run: mamba install python anaconda-client conda-build conda-verify + - name: Configure Auto-Upload if: github.ref == 'refs/heads/stable' run: | conda config --set anaconda_upload yes + - name: Build Binary run: | - # set a default value to the conda_token if needed (like from forks) - : "${CONDA_TOKEN:=${{ secrets.ANACONDA_TOKEN }}}" - : "${CONDA_TOKEN:=default_value}" + # Set the CONDA_TOKEN environment variable + if [ -z "${{ secrets.ANACONDA_TOKEN }}" ]; then + export CONDA_TOKEN="default_value" + else + export CONDA_TOKEN="${{ secrets.ANACONDA_TOKEN }}" + fi + echo "CONDA_TOKEN=$CONDA_TOKEN" >> $GITHUB_ENV - conda config --add channels conda-forge - conda-build --token "$CONDA_TOKEN" --user rmg .conda + + # Conditionally add the --token and --user flags for stable branches + if [[ "${GITHUB_REF}" == "refs/heads/stable" ]]; then + conda-build --token "$CONDA_TOKEN" --user rmg .conda + else + conda-build .conda + fi