Skip to content

Merge pull request #4 from sfetzel/main #32

Merge pull request #4 from sfetzel/main

Merge pull request #4 from sfetzel/main #32

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest numpy torch
pip install .
- name: Run tests
run: pytest
upload_to_pypi:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Check if version exists on PyPI
id: check_version
run: |
PACKAGE_NAME=$(python setup.py --name)
CURRENT_VERSION=$(python setup.py --version)
VERSION_EXISTS=$(pip index versions $PACKAGE_NAME | grep $CURRENT_VERSION || true)
if [ -z "$VERSION_EXISTS" ]; then
echo "Version does not exist on PyPI, proceeding with upload."
echo "::set-output name=exists::false"
else
echo "Version already exists on PyPI, skipping upload."
echo "::set-output name=exists::true"
fi
- name: Upload to PyPI
if: steps.check_version.outputs.exists == 'false'
run: python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}