| 1 | name: "Test, Build, Publish" |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | push: |
| 6 | release: |
| 7 | types: |
| 8 | - published |
| 9 | pull_request: |
| 10 | |
| 11 | jobs: |
| 12 | test: |
| 13 | runs-on: ubuntu-latest |
| 14 | steps: |
| 15 | - uses: actions/checkout@v1 |
| 16 | - name: Set up Python 3.7 |
| 17 | uses: actions/setup-python@v1 |
| 18 | with: |
| 19 | python-version: 3.7 |
| 20 | - name: Install sound libraries |
| 21 | run: | |
| 22 | sudo apt-get install libsndfile1 libvorbis0a pulseaudio |
| 23 | pulseaudio -D --start |
| 24 | - name: Install xvfb |
| 25 | run: | |
| 26 | sudo apt-get install xvfb |
| 27 | - name: Run tests under xvfb |
| 28 | run: | |
| 29 | xvfb-run --auto-servernum python setup.py test |
| 30 | - name: Cleanup xvfb pidx |
| 31 | uses: bcomnes/cleanup-xvfb@v1 |
| 32 | - uses: actions/upload-artifact@master |
| 33 | if: ${{ failure() }} |
| 34 | with: |
| 35 | name: failed-image |
| 36 | path: test/failed-image |
| 37 | |
| 38 | buildpackage: |
| 39 | needs: [test] |
| 40 | runs-on: ubuntu-latest |
| 41 | steps: |
| 42 | - uses: actions/checkout@v1 |
| 43 | - uses: actions/setup-python@v2 |
| 44 | with: |
| 45 | python-version: 3.8 |
| 46 | |
| 47 | - name: Install wheel and SDist requirements |
| 48 | run: python -m pip install "setuptools>=42.0" wheel twine |
| 49 | |
| 50 | - name: Build SDist |
| 51 | run: python setup.py sdist bdist_wheel |
| 52 | |
| 53 | - uses: actions/upload-artifact@v2 |
| 54 | with: |
| 55 | path: | |
| 56 | dist/*.tar.gz |
| 57 | dist/*.whl |
| 58 | |
| 59 | publish: |
| 60 | needs: [buildpackage] |
| 61 | runs-on: ubuntu-latest |
| 62 | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 63 | |
| 64 | steps: |
| 65 | - uses: actions/download-artifact@v2 |
| 66 | with: |
| 67 | name: artifact |
| 68 | path: dist |
| 69 | |
| 70 | - uses: pypa/gh-action-pypi-publish@master |
| 71 | with: |
| 72 | user: __token__ |
| 73 | password: ${{ secrets.pypi_password }} |