wip #18
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: CI | |
| on: | |
| push: # Run on pushes to main | |
| branches: [ main ] | |
| pull_request: # Run on PRs targeting main | |
| branches: [ main ] | |
| release: | |
| types: [ published ] # Run when a release is published in GitHub | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 | |
| - name: Lint with flake8 | |
| run: | | |
| flake8 . | |
| type-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install mypy | |
| pip install -r requirements.txt\ | |
| - name: Type check with mypy | |
| run: | | |
| mypy . | |
| publish-to-pypi: | |
| name: Publish Python distribution to PyPI | |
| # Run this job only when a release is published in GitHub | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| needs: [lint, type-check] # Ensure checks pass before publishing | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # No need to specify ref, checkout action automatically checks out the release tag | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' # Specify a fixed Python version | |
| - 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: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| # user: __token__ is the default and recommended, no need to specify | |