diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index ba6a7b4..42142de 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,13 +1,17 @@ -name: Python package +name: Test & publish -on: [push] +on: + push: + pull_request: + release: + types: [published] jobs: build: name: Python ${{ matrix.python-version }} / ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: - max-parallel: 4 + max-parallel: 9 matrix: python-version: [3.6, 3.7, 3.8] os: [ubuntu-latest, windows-latest, macOS-latest] @@ -26,3 +30,25 @@ jobs: - name: Test with pytest run: | poetry run pytest --color=yes + + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'release' + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.8' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + - name: Build and publish + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + poetry publish --build -u $PYPI_USERNAME -p $PYPI_PASSWORD diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml deleted file mode 100644 index 156e898..0000000 --- a/.github/workflows/pythonpublish.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Upload Python Package - -on: - release: - types: [created] - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install poetry - - name: Build and publish - env: - PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - poetry publish --build -u $PYPI_USERNAME -p $PYPI_PASSWORD