-
Notifications
You must be signed in to change notification settings - Fork 19
182 lines (178 loc) · 6.24 KB
/
main.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
name: Build, test, release
on:
push:
branches:
- '*'
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+.dev[0-9]+'
env:
PY_VERSIONS_STR: >-
["3.8", "3.9", "3.10", "3.11"]
VERSIONS_LINUX_STR: >-
["manylinux2014", "manylinux_2_24"]
VERSIONS_MACOS_STR: >-
["macos-11", "macos-12"]
VERSIONS_WINDOWS_STR: >-
["windows-2019"]
jobs:
pass-env:
runs-on: ubuntu-latest
outputs:
py-versions-str: ${{ steps.set-env.outputs.py-versions-str }}
versions-linux-str: ${{ steps.set-env.outputs.versions-linux-str }}
versions-macos-str: ${{ steps.set-env.outputs.versions-macos-str }}
versions-windows-str: ${{ steps.set-env.outputs.versions-windows-str }}
is-from-tag-str: ${{ steps.set-env.outputs.is-from-tag-str }}
is-for-release-str: ${{ steps.set-env.outputs.is-for-release-str }}
steps:
- id: set-env
run: |
echo "::set-output name=py-versions-str::${{ toJSON(env.PY_VERSIONS_STR) }}"
echo "::set-output name=versions-linux-str::${{ toJSON(env.VERSIONS_LINUX_STR) }}"
echo "::set-output name=versions-macos-str::${{ toJSON(env.VERSIONS_MACOS_STR) }}"
echo "::set-output name=versions-windows-str::${{ toJSON(env.VERSIONS_WINDOWS_STR) }}"
echo "::set-output name=is-from-tag-str::${{ toJSON(github.ref_type == 'tag') }}"
echo "::set-output name=is-for-release-str::${{ toJSON(!contains(github.ref_name, 'dev')) }}"
build-linux:
needs: pass-env
strategy:
fail-fast: false
matrix:
image-name: ${{ fromJSON(needs.pass-env.outputs.versions-linux-str) }}
image-arch:
- x86_64
py-version: ${{ fromJSON(needs.pass-env.outputs.py-versions-str) }}
runs-on: ubuntu-latest
container:
image: quay.io/pypa/${{ matrix.image-name }}_${{ matrix.image-arch }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/setup-poetry
with:
key-base: ${{ matrix.image-name }}_${{ matrix.image-arch }}-py${{ matrix.py-version }}
use-pipx: true
use-specific-python-version: true
specific-python-version: ${{ matrix.py-version }}
- run: make test
- uses: ./.github/actions/upload-artifacts
with:
make-binary: true
repair-manylinux: true
manylinux-target: ${{ matrix.image-name}}_${{ matrix.image-arch }}
if: ${{ fromJSON(needs.pass-env.outputs.is-from-tag-str) }}
build-macos:
needs: pass-env
strategy:
fail-fast: false
matrix:
arch: ${{ fromJSON(needs.pass-env.outputs.versions-macos-str) }}
py-version: ${{ fromJSON(needs.pass-env.outputs.py-versions-str) }}
runs-on: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.py-version }}
- uses: ./.github/actions/setup-poetry
with:
key-base: ${{ matrix.arch }}-py${{ matrix.py-version }}
use-pipx: false
use-specific-python-version: false
- run: make test
- uses: ./.github/actions/upload-artifacts
with:
make-binary: true
if: ${{ fromJSON(needs.pass-env.outputs.is-from-tag-str) }}
build-windows:
needs: pass-env
strategy:
fail-fast: false
matrix:
arch: ${{ fromJSON(needs.pass-env.outputs.versions-windows-str) }}
py-version: ${{ fromJSON(needs.pass-env.outputs.py-versions-str) }}
runs-on: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/setup-mingw
with:
key-base: ${{ matrix.arch }}-py${{ matrix.py-version }}
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.py-version }}
- uses: ./.github/actions/setup-poetry
with:
key-base: ${{ matrix.arch }}-py${{ matrix.py-version }}
use-pipx: false
use-specific-python-version: false
- run: make test
- uses: ./.github/actions/upload-artifacts
with:
make-binary: true
if: ${{ fromJSON(needs.pass-env.outputs.is-from-tag-str) }}
package-source:
needs:
- pass-env
- build-linux
- build-macos
- build-windows
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.pass-env.outputs.is-from-tag-str) }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v3
with:
python-version: ${{ fromJSON(needs.pass-env.outputs.py-versions-str)[0] }}
- uses: ./.github/actions/setup-poetry
with:
key-base: source_linux-py${{ fromJSON(needs.pass-env.outputs.py-versions-str)[0] }}
use-pipx: false
use-specific-python-version: false
- uses: ./.github/actions/upload-artifacts
with:
make-binary: false
upload-pypi:
needs:
- pass-env
- build-linux
- build-macos
- build-windows
- package-source
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.pass-env.outputs.is-from-tag-str) }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v3
with:
python-version: ${{ fromJSON(needs.pass-env.outputs.py-versions-str)[0] }}
- uses: actions/download-artifact@v2
with:
path: dist
- uses: ./.github/actions/setup-poetry
with:
key-base: source_linux-py${{ fromJSON(needs.pass-env.outputs.py-versions-str)[0] }}
use-pipx: false
use-specific-python-version: false
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: dist/artifact/
if: ${{ fromJSON(needs.pass-env.outputs.is-for-release-str) }}
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TESTPYPI_API_TOKEN }}
packages_dir: dist/artifact/
repository_url: https://test.pypi.org/legacy/
if: ${{ !fromJSON(needs.pass-env.outputs.is-for-release-str) }}