Merge pull request #614 from HEXRD/refactor-projections #1440
This file contains 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: conda-package | |
on: | |
push: | |
branches: [ master ] | |
tags: ["*"] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
package: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Linux", | |
os: ubuntu-latest | |
} | |
- { | |
name: "MacOSX", | |
os: macos-latest | |
} | |
- { | |
name: "Windows", | |
os: windows-2019 | |
} | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
python-version: 3.11 | |
activate-environment: hexrd | |
auto-activate-base: false | |
- name: Install build requirements | |
run: | | |
# Change default solver to be libmamba, so that it runs much faster | |
conda install -n base -c conda-forge conda-libmamba-solver | |
conda config --set solver libmamba | |
conda activate hexrd | |
conda install --override-channels -c conda-forge anaconda-client conda-build conda | |
# This is need to ensure ~/.profile or ~/.bashrc are used so the activate | |
# command works. | |
shell: bash -l {0} | |
- name: Build the package (host) | |
if: ${{ matrix.config.name != 'Linux' }} | |
run: | | |
conda activate hexrd | |
# For some reason, we need to set this in the environment as well. | |
# It seems conda build sometimes needs the solver in the environment | |
# and sometimes in the base environment. I don't know why. | |
conda install -c conda-forge conda-libmamba-solver | |
conda config --env --set solver libmamba | |
conda list | |
# Mac is having an issue with libarchive. We need to make sure that it | |
# comes from conda-forge. See here: https://github.com/conda/conda-libmamba-solver/issues/283 | |
conda update -c conda-forge libarchive | |
mkdir output | |
# Conda build is ignoring the .condarc for some reason, so we need to | |
# set this environment variable instead. | |
# Setting this variable via `env` did not seem to work for some reason. | |
export CONDA_SOLVER=libmamba | |
conda build --override-channels -c conda-forge --output-folder output/ conda.recipe/ | |
# This is need to ensure ~/.profile or ~/.bashrc are used so the activate | |
# command works. | |
shell: bash -l {0} | |
- name: Build the package (container) | |
if: ${{ matrix.config.name == 'Linux' }} | |
uses: docker://centos:7 | |
with: | |
entrypoint: /github/workspace/.github/workflows/container_build.sh | |
- name: Upload the package to anaconda channel (tag push to master) | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
run: | | |
conda activate hexrd | |
anaconda --token ${{ secrets.ANACONDA_TOKEN }} upload --force --user HEXRD output/**/*.tar.bz2 | |
# This is need to ensure ~/.profile or ~/.bashrc are used so the activate | |
# command works. | |
shell: bash -l {0} | |
- name: Upload the package to anaconda prerelease channel (upload push to master) | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
run: | | |
conda activate hexrd | |
anaconda --token ${{ secrets.ANACONDA_TOKEN }} upload --force --user HEXRD --label prerelease output/**/*.tar.bz2 | |
# This is need to ensure ~/.profile or ~/.bashrc are used so the activate | |
# command works. | |
shell: bash -l {0} | |
- name: Get version for the artifact names | |
run: echo "HEXRD_GIT_DESCRIBE=$(git describe --tag)" >> $GITHUB_ENV | |
- name: Upload the package to github | |
uses: actions/upload-artifact@v3 | |
with: | |
name: HEXRD-${{ matrix.config.name }}-${{ env.HEXRD_GIT_DESCRIBE }}.tar.bz2 | |
path: output/**/*.tar.bz2 |