Skip to content

Commit 474ef6c

Browse files
authored
Create test_and_deploy.yaml
1 parent 4565367 commit 474ef6c

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Test and PyPI upload
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
12+
pull_request:
13+
branches:
14+
- main
15+
workflow_dispatch:
16+
17+
jobs:
18+
test:
19+
name: ${{ matrix.platform }} py${{ matrix.python-version }}
20+
runs-on: ${{ matrix.platform }}
21+
strategy:
22+
matrix:
23+
platform: [ubuntu-latest, windows-latest, macos-latest]
24+
python-version: [3.9]
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
34+
# note: if you need dependencies from conda, considering using
35+
# setup-miniconda: https://github.com/conda-incubator/setup-miniconda
36+
# and
37+
# tox-conda: https://github.com/tox-dev/tox-conda
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
python -m pip install setuptools tox tox-gh-actions
42+
43+
# this runs the platform-specific tests declared in tox.ini
44+
- name: Test with tox
45+
uses: GabrielBB/xvfb-action@v1
46+
with:
47+
run: python -m tox
48+
env:
49+
PLATFORM: ${{ matrix.platform }}
50+
51+
- name: Coverage
52+
uses: codecov/codecov-action@v2
53+
54+
deploy:
55+
# this will run when you have tagged a commit, starting with "v*"
56+
# and requires that you have put your twine API key in your
57+
# github secrets (see readme for details)
58+
needs: [test]
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v2
62+
- name: Set up Python
63+
uses: actions/setup-python@v2
64+
with:
65+
python-version: "3.x"
66+
- name: Install dependencies
67+
run: |
68+
python -m pip install --upgrade pip
69+
pip install -U setuptools setuptools_scm wheel twine build
70+
- name: Build package
71+
run: |
72+
python -m build .
73+
- name: Publish package
74+
if: contains(github.ref, 'tags')
75+
env:
76+
TWINE_USERNAME: __token__
77+
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
78+
run: |
79+
git tag
80+
twine upload dist/*

0 commit comments

Comments
 (0)