[pre-commit.ci] pre-commit autoupdate #55
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: package builds | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
paths-ignore: | |
- CHANGELOG.md | |
- doc/** | |
- '!.github/workflows/build.yml' | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
jobs: | |
conda: | |
defaults: | |
run: | |
shell: bash -l {0} | |
if: | | |
(github.event.pull_request.draft == false) || | |
(github.event_name == 'workflow_dispatch') || | |
(github.ref == 'refs/heads/master') || | |
startsWith(github.ref, 'refs/tags/') || | |
(github.event_name == 'release') | |
name: conda build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags and branches | |
- name: Setup Conda Environment | |
uses: mamba-org/[email protected] | |
with: | |
environment-file: ./devtools/conda.recipe/build_env.yml | |
envrionment-name: build_env | |
init-shell: >- | |
bash | |
powershell | |
cache-downloads: true | |
- name: activate build env | |
run: micromamba activate build_env | |
- name: conda info | |
run: conda info | |
- name: conda list | |
run: conda list | |
- name: set pkg version | |
run: echo "SETUPTOOLS_SCM_PRETEND_VERSION=$(python -m setuptools_scm)" >> $GITHUB_ENV | |
- name: Build from local conda recipe | |
run: conda mambabuild -c conda-forge . | |
pypi: | |
if: | | |
(github.event.pull_request.draft == false) || | |
(github.event_name == 'workflow_dispatch') || | |
startsWith(github.ref, 'refs/tags/') || | |
(github.event_name == 'release') | |
name: pypi build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags and branches | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Cache pip | |
uses: actions/cache@v3 | |
env: | |
# Increase this value to reset cache if ./pyproject.toml has not changed | |
CACHE_NUMBER: 0 | |
with: | |
path: ~/.cache/pip | |
key: ubuntu-latest-pip-${{ env.CACHE_NUMBER }}-${{ hashFiles('pyproject.toml') }} | |
- name: pip installs | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools setuptools_scm wheel twine build | |
- name: build package + create src archive (stored in dist folder) | |
run: | | |
python -m build | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: ./dist/ | |
- name: get sdist file | |
run: echo "SDIST_FILE=$(find ./dist/*.tar.gz | head -n 1)" >> $GITHUB_ENV | |
- name: pip dist install | |
run: | | |
pip install ${{ env.SDIST_FILE }}[all,test] | |
- name: run pytest | |
run: | | |
pytest | |
- name: set pypi test repo defaults | |
run: | | |
echo "pypi_repo=testpypi" >> $GITHUB_ENV | |
echo "pypi_token=${{ secrets.TESTPYPI_UPLOAD }}" >> $GITHUB_ENV | |
- name: set pypi main repo for release | |
if: github.event_name == 'release' | |
run: | | |
echo "pypi_repo=pypi" >> $GITHUB_ENV | |
echo "pypi_token=${{ secrets.PYPI_UPLOAD }}" >> $GITHUB_ENV | |
- name: pypi release | |
if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'release') | |
run: | | |
python -m twine upload --repository $pypi_repo dist/* -u __token__ -p $pypi_token |