-
Notifications
You must be signed in to change notification settings - Fork 20
163 lines (156 loc) · 5.07 KB
/
build-publish.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
# This workflow is used to build all the wheels and source distributions for
# the project and, on tags and releases, upload them. It is enabled on every
# commit to ensure that the wheels can be built on all platforms, but releases
# are only triggered in two situations:
#
# 1. When a tag is created, the workflow will upload the package to
# test.pypi.org.
# 2. When a release is made, the workflow will upload the package to pypi.org.
#
# It is done this way until PyPI has draft reviews, to allow for a two-stage
# upload with a chance for manual intervention before the final publication.
name: Build and release
on:
push:
release:
types: [created]
jobs:
build_sdist:
runs-on: 'ubuntu-22.04'
name: Build sdist
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install 'tox>=4.0'
- name: Build sdist
run: tox -e build -- -s
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
build_manylinux_wheels:
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
platform:
- 'manylinux1_x86_64'
- 'manylinux1_i686'
- 'manylinux2014_aarch64'
name: Build a ${{ matrix.platform }} for ${{ matrix.python_tag }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
if: ${{ matrix.platform == 'manylinux2014_aarch64' }}
name: Set up QEMU
- name: Install docker image
run: |
DOCKER_IMAGE="quay.io/pypa/${{ matrix.platform }}"
echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> $GITHUB_ENV
docker pull $DOCKER_IMAGE
- name: Build wheels
env:
PYTHON_TAGS: "cp36-cp36m cp37-cp37m cp38-cp38"
PRE_CMD: ${{ matrix.platform == 'manylinux1_i686' && 'linux32' || '' }}
run: |
echo "$name"
docker run --rm \
-e PLAT=${{ matrix.platform }} \
-e PYTHON_TAGS="$PYTHON_TAGS" \
-v `pwd`:/io "$DOCKER_IMAGE" \
$PRE_CMD \
/io/scripts/build_manylinux_wheels.sh
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
build_wheel:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python_version: [ '3.7', '3.8' ]
arch: [ 'x86', 'x64' ]
os:
- 'windows-2022'
- 'macos-11'
include:
- { python_version: "3.6", os: "windows-2019", arch: "x86" }
- { python_version: "3.6", os: "windows-2019", arch: "x64" }
- { python_version: "3.6", os: "macos-10.15", arch: "x64" }
exclude:
- os: 'macos-11'
arch: 'x86'
name: 'Build wheel: ${{ matrix.os }} ${{ matrix.python_version }} (${{ matrix.arch }})'
steps:
- uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.3.1
if: startsWith(matrix.os, 'windows-')
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
architecture: ${{ matrix.arch }}
- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U 'tox>=3.18'
- name: Create tox environment
run: tox -e build --notest
- name: Build wheel
env:
CL: ${{ startsWith(matrix.os, 'windows-') && '/WX' || '' }}
run: |
tox -e build -- -w
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
deploy:
runs-on: 'ubuntu-22.04'
needs: [build_sdist, build_wheel, build_manylinux_wheels]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: actions/download-artifact@v4.1.7
with:
name: dist
path: dist
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install 'tox>=4.0'
- name: Check that version and tag matches
if: >-
startsWith(github.ref, 'refs/tags')
run: tox -e check-version-tag
- name: Run twine check
run: tox -e build-check
- name: Publish package
if: >-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) ||
(github.event_name == 'release')
env:
TWINE_USERNAME: "__token__"
run: |
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
export TWINE_REPOSITORY_URL="https://test.pypi.org/legacy/"
export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}"
elif [[ "$GITHUB_EVENT_NAME" == "release" ]]; then
export TWINE_REPOSITORY="pypi"
export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}"
else
echo "Unknown event name: ${GITHUB_EVENT_NAME}"
exit 1
fi
tox -e release