back to 2 ncro workers #371
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: Python Package using Conda | |
| on: [push] | |
| jobs: | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| max-parallel: 5 | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Add conda to system path | |
| run: | | |
| # $CONDA is an environment variable pointing to the root of the miniconda directory | |
| echo $CONDA/bin >> $GITHUB_PATH | |
| - name: Conda build package and upload to anaconda.org | |
| env: | |
| ANACONDA_CHANNEL_UPLOAD_TOKEN: ${{ secrets.ANACONDA_CHANNEL_UPLOAD_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| conda create -n test_dms_datastore -y conda-build conda-verify numpy anaconda-client | |
| source $CONDA/etc/profile.d/conda.sh | |
| conda activate test_dms_datastore | |
| pip install setuptools_scm | |
| git fetch --force --tags | |
| echo "Describe: $(git describe --tags --dirty --always || true)" | |
| RAW_VERSION="$(python -m setuptools_scm | tr -d '\r\n')" | |
| PKG_VERSION="$(echo "$RAW_VERSION" | sed -E 's/\+g([0-9a-f]+)/.g\1/; s/-g([0-9a-f]+)/.g\1/')" | |
| if [ -z "$PKG_VERSION" ] || [ "$PKG_VERSION" = "0.0.0" ] || [ "$PKG_VERSION" = "None" ]; then | |
| echo "ERROR: Bad PKG_VERSION='$PKG_VERSION' (RAW_VERSION='$RAW_VERSION')" | |
| exit 1 | |
| fi | |
| printf "PKG_VERSION: %s\nSCM_VERSION: %s\n" "$PKG_VERSION" "$RAW_VERSION" > conda.recipe/variant.yaml | |
| echo "=== variant.yaml ===" | |
| cat conda.recipe/variant.yaml | |
| # Publish only on tags (still build/test on branch pushes) | |
| if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then | |
| echo "Tag push (${GITHUB_REF_NAME}); enabling upload." | |
| conda config --set anaconda_upload yes | |
| conda build -m conda.recipe/variant.yaml -c cadwr-dms -c conda-forge \ | |
| --user cadwr-dms --token "$ANACONDA_CHANNEL_UPLOAD_TOKEN" conda.recipe | |
| else | |
| echo "Branch push (${GITHUB_REF_NAME}); building without upload." | |
| conda config --set anaconda_upload no | |
| conda build -m conda.recipe/variant.yaml -c cadwr-dms -c conda-forge conda.recipe | |
| fi | |
| conda deactivate | |
| conda remove -n test_dms_datastore --all -y |