Update ci.yml #7
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: Python Package | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| release: | |
| types: [created] | |
| jobs: | |
| test: | |
| name: Test on ${{ matrix.os }} - Python ${{ matrix.python-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ["3.9", "3.10", "3.11"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies only | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests | |
| - name: Test from source (without installing package) | |
| run: | | |
| python -m dpow.client --help || echo "Direct module test" | |
| python dpow/__main__.py | |
| - name: Install package in development mode | |
| run: | | |
| pip install -e . | |
| - name: Test installed package | |
| run: | | |
| python -m dpow | |
| publish: | |
| name: Build and Publish to PyPI | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.event.action == 'created' | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools wheel twine requests | |
| - name: Build package | |
| run: | | |
| python setup.py sdist bdist_wheel | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| twine upload dist/* | |
| verify-publish: | |
| name: Verify PyPI package on ${{ matrix.os }} | |
| needs: publish | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ["3.10"] | |
| steps: | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Wait for PyPI to update | |
| run: sleep 60 | |
| - name: Install from PyPI | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install dpow | |
| - name: Test installed package from PyPI | |
| run: | | |
| python -m dpow | |
| - name: Verify package can be imported | |
| run: | | |
| python -c "import dpow; from dpow import client, server; print('Package imported successfully')" |