-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (107 loc) · 3.38 KB
/
python-publish.yml
File metadata and controls
113 lines (107 loc) · 3.38 KB
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
name: Python Publish
on: [push, pull_request]
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4.0.0
with:
concurrent_skipping: "same_content_newer"
do_not_skip: '["pull_request", "workflow_dispatch", "schedule", "create", "release"]'
test:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' || contains(github.ref, 'refs/tags/v')}}
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.8"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache-pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}
- run: pip install --upgrade poetry
- uses: actions/cache@v3
id: cache-poetry
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-poetry-
${{ runner.os }}-
- name: install dependencies
run: |
poetry install --sync
- name: run pre-commit
uses: pre-commit/action@v2.0.3
# run: poetry run pre-commit run --all-files
- name: run tests
run: |
poetry run pytest "tests/" \
-n auto \
--verbose \
--cov=template_python_library \
--pyargs "template_python_library" \
--cov-report=html --cov-report=term --cov-report=xml
- uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
env_vars: OS,PYTHON
deploy:
needs:
- pre_job
- test
if: ${{ needs.pre_job.outputs.should_skip != 'true' || contains(github.ref, 'refs/tags/v') }}
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
id: cache-pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-
- run: pip install --upgrade --pre poetry
- uses: actions/cache@v3
id: cache-poetry
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-poetry-
${{ runner.os }}-
- name: install dependencies
run: |
poetry install --sync
- name: build
run: |
poetry build
echo $GITHUB_REF
- name: publish
if: contains(github.ref, 'refs/tags/v')
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish || poetry publish