-
-
Notifications
You must be signed in to change notification settings - Fork 53
173 lines (149 loc) · 4.97 KB
/
build.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
name: build
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
env:
# the supported Python versions for pre-built wheels
CIBW_BUILD_VERSIONS: "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*"
jobs:
pre-commit-hooks:
name: run pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run pre-commit hook
uses: pre-commit/action@v3.0.1
test:
runs-on: ubuntu-latest
strategy:
# By default, GitHub will maximize the number of jobs run in parallel
# depending on the available runners on GitHub-hosted virtual machines.
# max-parallel: 8
fail-fast: false
matrix:
# all officially supported Python versions should be tested
# NOTE: need to match the versions in pyproject.toml > tox.ini
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
env:
TOXENV: ${{ matrix.tox-env }}
TOX_SKIP_MISSING_INTERPRETERS: False
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip version
run: pip install -U pip
- name: Install test dependencies
run: pip install tox tox-gh-actions poetry==1.4.0
- name: Run tox
run: tox
make-wheels:
name: Make ${{ matrix.os }} ${{ matrix.cibw_arch }} wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest"]
cibw_arch: ["native"]
fail-fast: false
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: Install poetry
run: pip install poetry
- name: "Build wheels"
uses: pypa/cibuildwheel@v2.22.0
with:
output-dir: dist
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_1
CIBW_BUILD: ${{ env.CIBW_BUILD_VERSIONS }}
CIBW_SKIP: "cp36-* cp37-*"
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_BUILD_FRONTEND: pip
CIBW_BEFORE_ALL_LINUX_MANYLINUX2014: yum install -y libffi-devel clang make
CIBW_BEFORE_ALL_LINUX_MUSLLINUX_1_1: apk add --no-cache libffi-dev clang make
CIBW_BUILD_VERBOSITY: 1
- name: "Upload wheel as artifact"
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}-${{ matrix.cibw_arch }}-wheel
path: "./**/dist/*.whl"
make-sdist:
name: Make source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pip install poetry
- run: poetry build -f sdist
- uses: actions/upload-artifact@v4
with:
name: artifact-source-dist
path: "./**/dist/*.tar.gz"
publish:
runs-on: ubuntu-latest
# Note: only run, when test publishing worked
needs: [test, make-wheels, make-sdist]
if: endsWith(github.ref, '/master')
permissions:
id-token: write
contents: write
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Upgrade pip version
run: pip install --upgrade pip
- name: Install poetry
run: pip install poetry
- name: Fetch version
id: fetch_version
run: echo "version_nr=$(poetry version -s)" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Copy artifacts to dist/ folder
run: |
find . -name 'artifact-*' -exec unzip '{}' \;
mkdir -p dist/
find . -name '*.tar.gz' -exec mv '{}' dist/ \;
find . -name '*.whl' -exec mv '{}' dist/ \;
ls -lR dist/
- name: Test PyPI Publishing
# TODO separate step to test publishing before merging to main
# NOTE: PRs from forks fail due to: "missing or insufficient OIDC token permissions,
# the ACTIONS_ID_TOKEN_REQUEST_TOKEN environment variable was unset"
# -> test publishing cannot be triggered in PRs?!
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_DEPLOYMENT_API_KEY }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Create GitHub Release
id: create_gh_release
uses: ncipollo/release-action@v1
env:
VERSION: ${{ steps.fetch_version.outputs.version_nr }}
with:
tag: ${{env.VERSION}}
name: Release ${{env.VERSION}}
draft: false
prerelease: false
skipIfReleaseExists: true
- name: PyPI Publishing
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_DEPLOYMENT_API_KEY }}
skip-existing: true