-
Notifications
You must be signed in to change notification settings - Fork 221
133 lines (128 loc) · 4.25 KB
/
publish_to_pypi.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
name: Build and publish to TestPyPI or PyPI
on: [push, pull_request]
jobs:
get_python_versions:
name: "Determine Python versions"
runs-on: ubuntu-latest
outputs:
min-python: ${{ steps.nep29.outputs.min-python }}
max-python: ${{ steps.nep29.outputs.max-python }}
steps:
- name: "calculate versions according to NEP29"
id: nep29
uses: mstimberg/github-calc-nep29@v0.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
build:
needs: [get_python_versions]
name: Build 🎡 on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macOS-latest ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Build wheels
uses: pypa/cibuildwheel@v2.12.1
with:
output-dir: dist
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=${{ needs.get_python_versions.outputs.min-python }}"
CIBW_ARCHS_WINDOWS: auto64
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_TEST_SKIP: '*_arm64 *_universal2:arm64'
CIBW_SKIP: 'pp*'
CIBW_TEST_COMMAND: python {project}/dev/continuous-integration/run_simple_test.py
CIBW_TEST_REQUIRES: pytest
- name: store distribution 📦
uses: actions/upload-artifact@v3
with:
name: packages
path: dist
build-linux:
needs: [get_python_versions]
name: Build ${{ matrix.arch }} 🎡 and source 📦 on Linux
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [ auto64, aarch64 ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Build source tarball
run: |
python -m pip install --upgrade pip build
python -m pip install "cython>=0.29" oldest-supported-numpy "setuptools>=61" "setuptools_scm[toml]>=6.2"
python -m build --sdist --config-setting=--formats=gztar --config-setting=--with-cython --config-setting=--fail-on-error
if: ${{ matrix.arch == 'auto64' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.12.1
with:
output-dir: dist
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=${{ needs.get_python_versions.outputs.min-python }}"
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_SKIP: 'pp* *-musllinux_aarch64'
CIBW_TEST_COMMAND: python {project}/dev/continuous-integration/run_simple_test.py
CIBW_TEST_REQUIRES: pytest
- name: store distribution 📦
uses: actions/upload-artifact@v3
with:
name: packages
path: dist
deploy_dev:
name: Publish development 📦 to TestPyPI
runs-on: ubuntu-latest
if: github.repository == 'brian-team/brian2' && github.ref == 'refs/heads/master'
environment: development_release
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
needs:
- build
- build-linux
steps:
- name: load distribution 📦
uses: actions/download-artifact@v3
with:
name: packages
path: dist/
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
deploy:
name: Publish release 📦 to PyPI
runs-on: ubuntu-latest
if: github.repository == 'brian-team/brian2' && startsWith(github.ref, 'refs/tags')
environment: release
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
needs:
- build
- build-linux
steps:
- name: load distribution 📦
uses: actions/download-artifact@v3
with:
name: packages
path: dist/
- name: Publish distribution release 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1