Test build and publish Cobramod to PyPI #97
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: Test build and publish Cobramod to PyPI | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 5 * * 1" | |
pull_request: | |
types: [ opened, synchronize, reopened, closed ] | |
branches: | |
- master | |
jobs: | |
lint-format-unittest: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
- name: Install dependencies | |
run: python -m pip install . | |
- name: Install tox | |
run: python -m pip install tox-gh>=1.2 | |
- name: Setup test suite | |
run: tox -vv --notest | |
- name: Run test suite | |
run: tox --skip-pkg-install | |
build-publish: | |
needs: [lint-format-unittest] | |
name: Build and publish the package to TestPyPI | |
if: github.event.pull_request.merged == true && github.event_name != 'schedule' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.10 | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install twine | |
- name: Build package | |
run: python setup.py sdist bdist_wheel | |
- name: Check the package | |
run: twine check dist/* | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | |
twine upload --non-interactive dist/* |