119 lines (91 loc) · 2.95 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: "ci"
on:
push:
branches: ["master"]
tags: ["v*"]
pull_request:
branches: ["master"]
env:
DEV_PYTHON_VERSION: "3.8"
POETRY_VERSION: "1.0.9"
TOX_GH_ACTIONS_VERSION: "1.3.0"
TOX_VERSION: "3.16.1"
TWINE_VERSION: "3.1.1"
jobs:
dev:
name: "Verify package is installed well"
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
runs-on: "${{ matrix.os }}"
steps:
- uses: "actions/checkout@v2.3.1"
- name: "Install Python"
uses: "actions/setup-python@v2.0.1"
with:
python-version: "${{ env.DEV_PYTHON_VERSION }}"
- name: "Install poetry"
uses: "dschep/install-poetry-action@v1.3"
with:
version: "${{ env.POETRY_VERSION }}"
- name: "Install package"
run: "poetry install --no-dev"
- name: "Import package"
run: "poetry run python -c 'import aiohttp_tus'"
test:
name: "Python ${{ matrix.python-version }}"
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8"]
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2.3.1"
- name: "Install Python"
uses: "actions/setup-python@v2.0.1"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install poetry"
uses: "dschep/install-poetry-action@v1.3"
with:
version: "${{ env.POETRY_VERSION }}"
- name: "Install package"
run: |
poetry install
python -m pip install tox==${{ env.TOX_VERSION }} tox-gh-actions==${{ env.TOX_GH_ACTIONS_VERSION }}
- name: "Cache pre-commit"
if: "matrix.python-version == 'env.DEV_PYTHON_VERSION'"
uses: "actions/cache@v2.0.0"
with:
path: "~/.cache/pre-commit"
key: "pre-commit-${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}"
- name: "Run pre-commit"
if: "matrix.python-version == 'env.DEV_PYTHON_VERSION'"
uses: "pre-commit/action@v2.0.0"
- name: "Run tests"
run: "python -m tox"
package:
needs: "test"
name: "Build & deploy package"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2.3.1"
- name: "Install Python"
uses: "actions/setup-python@v2.0.1"
with:
python-version: "${{ env.DEV_PYTHON_VERSION }}"
- name: "Install poetry"
uses: "dschep/install-poetry-action@v1.3"
with:
version: "${{ env.POETRY_VERSION }}"
- name: "Build package"
run: "poetry build"
- name: "Check package"
run: |
python -m pip install twine==${{ env.TWINE_VERSION }}
python -m twine check dist/*
- name: "Publish package"
if: "github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')"
uses: "pypa/gh-action-pypi-publish@v1.3.1"
with:
user: "${{ secrets.PYPI_USERNAME }}"
password: "${{ secrets.PYPI_PASSWORD }}"