generated from mumblepins/template-python-library
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (134 loc) · 4.44 KB
/
python-publish.yml
File metadata and controls
139 lines (134 loc) · 4.44 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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@v5.3.0
with:
concurrent_skipping: "same_content_newer"
do_not_skip: '["pull_request", "workflow_dispatch", "schedule", "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/restore@v3
id: cache-pip-restore
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-
- run: pip install --upgrade poetry
- uses: actions/cache/save@v3
id: cache-pip-save
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}
- uses: actions/cache/restore@v3
id: cache-poetry-restore
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
sudo apt-get update
sudo apt-get install -y binutils-aarch64-linux-gnu
- uses: actions/cache/save@v3
id: cache-poetry-save
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- 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 4 \
--dist worksteal \
--reruns 3 \
--verbose \
--cov=aws_lambda_python_packager \
--pyargs "aws_lambda_python_packager" \
--cov-report=html --cov-report=term --cov-report=xml
- uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
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/restore@v3
id: cache-pip-restore
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-
- run: pip install --upgrade --pre poetry
- uses: actions/cache/save@v3
id: cache-pip-save
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}
- uses: actions/cache/restore@v3
id: cache-poetry-restore
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
- uses: actions/cache/save@v3
id: cache-poetry-save
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- 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