-
Notifications
You must be signed in to change notification settings - Fork 3
173 lines (150 loc) · 5.31 KB
/
build-deploy-wheels.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, test and upload to PyPI
on:
push:
branches:
- master
- '[0-9]+.[0-9]+.X'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+b[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+a[0-9]+'
pull_request:
types: [opened, reopened]
jobs:
build_wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
pyver: [cp39, cp310, cp311, cp312]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build wheels
uses: pypa/cibuildwheel@v2.20.0
env:
CIBW_BUILD: ${{matrix.pyver}}-*
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_x86_64 *-musllinux_i686"
CIBW_BEFORE_TEST: pip install -r {package}/requirements-test.txt
CIBW_TEST_COMMAND: python -m pytest {package}/tests --benchmark-skip
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.12"
- name: Install requirements
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build sdist
run: |
python -m build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
# Check that a tag is annotated with a Release messages.
check_tag:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
outputs:
is_release: ${{ steps.is_release.outputs.is_release }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check that the tag is annotated with Release
id: is_release
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
TAG_MESSAGE=$(git tag -l --format='%(contents)' "$TAG_NAME" | head -n1)
if [[ $TAG_MESSAGE == [Rr]elease* ]]; then
echo "Tag $TAG_NAME is annotated for release ($TAG_MESSAGE)"
echo "is_release=true" >> "$GITHUB_OUTPUT"
else
echo "Tag $TAG_NAME is not annotated for release ($TAG_MESSAGE)"
echo "is_release=false" >> "$GITHUB_OUTPUT"
fi
# Check if we should build the documentation for the current branch or tag
docs_version:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && ( github.ref_name == 'master' || startsWith(github.event.ref, 'refs/tags/v') ) }}
outputs:
version: ${{ steps.docs_version.outputs.version }}
build_docs: ${{ steps.docs_version.outputs.build_docs }}
steps:
- name: Extract the branch name
id: docs_version
run: |
REF_NAME="${{ github.ref_name }}"
VERSION_PATTERN="v([0-9]+\\.[0-9]+)\\.[0-9]+([a|b][0-9]+)?" # Matches major.minor from a version tag
# We build documentation for current master
if [[ "$REF_NAME" == "master" ]]; then
echo "Documentation is built for master"
echo "version=master" >> "$GITHUB_OUTPUT"
echo "build_docs=true" >> "$GITHUB_OUTPUT"
# And for tagged versions
elif [[ "$REF_NAME" =~ $VERSION_PATTERN ]]; then
VERSION="${BASH_REMATCH[1]}"
echo "Documentation is built for $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "build_docs=true" >> "$GITHUB_OUTPUT"
else
echo "Documentation is not build."
echo "build_docs=false" >> "$GITHUB_OUTPUT"
fi
build_docs:
needs: [docs_version, build_sdist, build_wheels]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && needs.docs_version.outputs.build_docs == 'true' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.12"
- name: Install requirements
run: |
sudo apt-get install graphviz pandoc
python -m pip install --upgrade pip
python -m pip install -r docs/requirements.txt
- name: Install current version
run: |
pip install --force-reinstall .
pip install -r requirements-dev.txt
- name: Build docmentation
run: |
mkdir html
python -I -m sphinx docs html
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./html
destination_dir: ${{ needs.docs_version.outputs.version }}
upload_pypi:
needs: [build_wheels, build_sdist, build_docs]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}