93 lines
2.2 KiB
YAML

name: Test and Publish
on:
release:
types: [published]
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov
- name: Run tests
run: pytest --cov=src/ttt_game --cov-report=xml tests
- name: Upload Coverage Report to Codecov.io
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build package
run: python -m build
- name: Archive production artifacts
uses: actions/upload-artifact@v2
with:
name: built-files
path: dist
publish-pypi:
needs: [test, build]
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
name: built-files
path: dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
publish-testing:
needs: [test, build]
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
name: built-files
path: dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/