Initial commit #31
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: CI/CT/CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pytest | |
- name: Run unit tests | |
run: | | |
pytest tests | |
- name: Build PyPI package | |
if: success() | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Check if version exists on PyPI | |
id: pypi_version_check | |
run: | | |
pip install requests | |
PACKAGE_NAME="pyorganoid" | |
VERSION=$(python setup.py --version) | |
response=$(curl -s -o /dev/null -w "%{http_code}" https://pypi.org/project/$PACKAGE_NAME/$VERSION/) | |
if [ $response -eq 200 ]; then | |
echo "Version $VERSION already exists on PyPI." | |
echo "::set-output name=exists::true" | |
else | |
echo "Version $VERSION does not exist on PyPI." | |
echo "::set-output name=exists::false" | |
fi | |
- name: Publish to PyPI | |
if: steps.pypi_version_check.outputs.exists == 'false' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
pip install twine | |
twine upload dist/* --verbose | |
- name: Install Conda and dependencies | |
if: success() | |
uses: goanpeca/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
miniforge-variant: Mambaforge | |
python-version: 3.8 | |
- name: Install conda-build and anaconda-client | |
if: success() | |
run: | | |
conda install -y conda-build anaconda-client | |
conda init bash | |
source ~/.bashrc | |
- name: Build Conda package | |
if: success() | |
run: | | |
conda config --set anaconda_upload no | |
conda-build . --output-folder build_output | |
- name: Publish to Conda | |
if: success() | |
env: | |
ANACONDA_USER: ${{ secrets.CONDA_USERNAME }} | |
ANACONDA_PASSWORD: ${{ secrets.CONDA_PASSWORD }} | |
run: | | |
anaconda login --username $ANACONDA_USER --password $ANACONDA_PASSWORD | |
anaconda upload build_output/**/pyorganoid-*.tar.bz2 --force | |
- name: Build documentation | |
if: success() | |
run: | | |
cd docs | |
make clean | |
make html | |
- name: Deploy to GitHub Pages | |
if: success() | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: docs/build/html |