Update README.md #52
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: Install and Test Package | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: [created] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
#macoos-13 is x86_64 (Intel-based), macos-14 is ARM64 | |
os: [ubuntu-latest, macos-13, macos-14] | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up Miniconda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
miniconda-version: "latest" | |
auto-activate-base: true | |
- name: Install mamba for faster environment setup | |
run: conda install -n base -c conda-forge mamba | |
- name: Cache Conda Environment | |
id: cache-conda | |
uses: actions/cache@v3 | |
with: | |
path: /Users/runner/miniconda3/envs/ql | |
key: ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ hashFiles('environment.yml') }} | |
restore-keys: | | |
${{ runner.os }}-conda-${{ matrix.python-version }}- | |
- name: Remove existing Conda environment if cache not hit | |
if: steps.cache-conda.outputs.cache-hit != 'true' | |
run: conda env remove -n ql || echo "Environment does not exist" | |
- name: Create Conda environment using mamba | |
if: steps.cache-conda.outputs.cache-hit != 'true' | |
run: mamba env create -f environment.yml | |
- name: Install pip dependencies | |
shell: bash -l {0} | |
run: | | |
conda activate ql | |
pip install -r requirements.txt | |
- name: Install the package in editable mode | |
shell: bash -l {0} | |
run: | | |
conda activate ql | |
pip install -e . | |
- name: Test with pytest | |
shell: bash -l {0} | |
run: | | |
conda activate ql | |
pytest | |
# Install twine for PyPI publishing | |
- name: Install twine | |
shell: bash -l {0} | |
run: | | |
conda activate ql | |
pip install twine | |
# Publish step for PyPI | |
- name: Publish to PyPI | |
if: github.event_name == 'release' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' | |
shell: bash -l {0} | |
env: | |
TWINE_USERNAME: "__TOKEN__" | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
conda activate ql | |
python setup.py sdist bdist_wheel | |
twine upload dist/* |