-
Notifications
You must be signed in to change notification settings - Fork 11
251 lines (249 loc) · 7.91 KB
/
pyhton.build_deploy.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
on:
push:
pull_request:
branches:
- master
jobs:
generate-wrapper:
runs-on: "ubuntu-22.04"
defaults:
run:
working-directory: ./python-wrapper
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad
with:
packages: gcc g++ swig
version: 1.0
- name: generate wrapper
run: ./generate_swig_wrapper.sh
shell: bash
- uses: actions/upload-artifact@v4
with:
name: python-sources
path: python-wrapper/sensirion_gas_index_algorithm/**
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: swig-sources
path: python-wrapper/swig/**
if-no-files-found: error
check_readme_rst_syntax:
runs-on: "ubuntu-22.04"
defaults:
run:
working-directory: ./python-wrapper
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: install rst linter
run: pip install restructuredtext-lint pygments
- name: run
run: rst-lint *.rst
build:
continue-on-error: true
strategy:
matrix:
py-version: ["3.8", "3.9"]
os: [ubuntu-22.04, windows-2019, macOS-12, macOS-15]
fail-fast: false
runs-on: "ubuntu-22.04"
needs: generate-wrapper
defaults:
run:
working-directory: ./python-wrapper
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: python-sources
path: python-wrapper/sensirion_gas_index_algorithm
- uses: actions/download-artifact@v4
with:
name: swig-sources
path: python-wrapper/swig
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py-version }}
- name: install package
run: |
pip3 install -e .[test]
pip3 install wheel
- name: static test
run: flake8
- name: unit test
run: pytest
- name: create wheel
run: python3 setup.py bdist_wheel
- uses: actions/upload-artifact@v4
with:
name: py_${{ matrix.py-version }}_${{ matrix.os}}_build
path: python-wrapper/dist/**
if-no-files-found: error
py3p8_linux_sdist:
runs-on: "ubuntu-22.04"
needs: generate-wrapper
defaults:
run:
working-directory: ./python-wrapper
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: python-sources
path: python-wrapper/sensirion_gas_index_algorithm
- uses: actions/download-artifact@v4
with:
name: swig-sources
path: python-wrapper/swig
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: create dist package
run: python3 setup.py sdist
- uses: actions/upload-artifact@v4
with:
name: py_source_dist
path: python-wrapper/dist/**
if-no-files-found: error
build_pages:
runs-on: "ubuntu-22.04"
needs: generate-wrapper
defaults:
run:
working-directory: ./python-wrapper
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: python-sources
path: python-wrapper/sensirion_gas_index_algorithm
- uses: actions/download-artifact@v4
with:
name: swig-sources
path: python-wrapper/swig
- uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
- name: Install the project dependencies
run: |
python setup.py install
python -m pip install -r docs/requirements.txt
- name: Build documentation
run: cd ./docs && make html
- name: Upload html
uses: actions/upload-pages-artifact@v3
with:
path: python-wrapper/docs/_build/html
deploy_pages:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: "ubuntu-22.04"
needs: build_pages
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
with:
token: ${{secrets.GITHUB_TOKEN}}
deploy_pypi:
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: "ubuntu-22.04"
permissions:
id-token: write
needs: ["py3p8_linux_sdist", "build"]
steps:
- name: check artifacts before anything else...
run: |
cd python-wrapper/dist
ls build-examples:
- name: download python source dist artifacts
uses: actions/download-artifact@v4
with:
path: python-wrapper/dist
merge-multiple: true
name: py_source_dist
- name: check artifacts after sdist download
run: |
cd python-wrapper/dist
ls -al
- name: download python build artifacts
uses: actions/download-artifact@v4
with:
path: python-wrapper/dist
merge-multiple: true
pattern: py_*_macOS*_build
- name: check artifacts
run: |
cd python-wrapper/dist
ls -al
#- name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
github-release:
name: Create GitHub Release and add signature for python packages
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- build
- py3p8_linux_sdist
- deploy_pypi
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./python-wrapper
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: download python source dist artifacts
uses: actions/download-artifact@v4
with:
path: python-wrapper/dist
merge-multiple: true
name: py_source_dist
- name: download python build artifacts
uses: actions/download-artifact@v4
with:
path: python-wrapper/dist
merge-multiple: false
pattern: py_*_build
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo ${{ github.ref_name }}
# if [[ "$(gh release view '${{ github.ref_name }}' 2>&1)" == "release not found" ]]; then
# gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes ""
# fi
- name: Upload artifacts to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload release artifacts before the signing, such that artifacts are still uploaded if signing fails
run: |
ls -al dist/**
# gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@f514d46b907ebcd5bedc05145c03b69c1edd8b46
with:
inputs: >-
./python-wrapper/dist/*.tar.gz
./python-wrapper/dist/*.whl
- name: Upload signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# upload sigstore-produced signatures and certificates from dist
run: |
ls -al dist/*.sigstore.json
# gh release upload '${{ github.ref_name }}' dist/*.sigstore.json --repo '${{ github.repository }}'