-
Notifications
You must be signed in to change notification settings - Fork 6
160 lines (139 loc) · 5.39 KB
/
release.yaml
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
name: release
on:
release:
types: [published]
workflow_dispatch:
# NOTE: parts inspired by https://cibuildwheel.pypa.io/en/stable/setup/
jobs:
build:
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
- macos-13 # Intel runner
- macos-14 # Apple Silicon runner
- windows-latest
python-version:
- "8"
- "9"
- "10"
include:
- os: ubuntu-latest
platform: linux
- os: windows-latest
ls: dir
env:
FASTSIM_DISABLE_NETWORK_TESTS: 1
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: set up rust
if: matrix.os != 'ubuntu-latest'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup target add aarch64-apple-darwin
if: matrix.os == 'macos-14'
- name: run cargo tests
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: cd rust/ && cargo test
- name: set up python
uses: actions/setup-python@v4
with:
# NOTE: future versions of cibuildwheel need python 3.11+
python-version: "3.10"
- name: Upgrade to latest pip
run: python -m pip install --upgrade pip
- name: install Python dependencies
run: pip install -U setuptools wheel twine cibuildwheel pytest
- name: build source distribution
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '10'
run: |
pip install -U setuptools-rust
python -c "import setuptools; setuptools.setup()" sdist
- name: build ${{ matrix.platform || matrix.os }} binaries
uses: pypa/[email protected]
env:
CIBW_BUILD: "cp3${{ matrix.python-version }}-*"
CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64"
# CIBW_PLATFORM: ${{ matrix.platform || matrix.os }}
# TODO: why doesn't pytest work with cibuildwheel?
# CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests"
CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests"
# CIBW_ARCHS_MACOS: "universal2"
# see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2
CIBW_TEST_SKIP: "*_universal2:arm64"
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
CIBW_MANYLINUX_I686_IMAGE: "manylinux2014"
CIBW_BEFORE_BUILD: >
pip install -U setuptools-rust &&
rustup default stable &&
rustup show
CIBW_BEFORE_BUILD_LINUX: >
yum -y install openssl openssl-devel &&
pip install -U setuptools-rust &&
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y &&
rustup show
CIBW_BEFORE_BUILD_MACOS: >
rustup target add x86_64-apple-darwin
# - name: build windows 32bit binaries
# if: matrix.os == 'windows'
# run: cibuildwheel --output-dir dist
# env:
# CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32'
# CIBW_PLATFORM: windows
# CIBW_TEST_REQUIRES: 'pytest'
# CIBW_TEST_COMMAND: 'pytest {project}/tests -s'
# CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"'
# CIBW_BEFORE_BUILD: >
# pip install -U setuptools-rust &&
# rustup toolchain install nightly-i686-pc-windows-msvc &&
# rustup default nightly-i686-pc-windows-msvc &&
# rustup override set nightly-i686-pc-windows-msvc &&
# rustup show
- name: list wheelhouse files
run: ${{ matrix.ls || 'ls -lh' }} ./wheelhouse/
- uses: actions/upload-artifact@v4
with:
name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
release:
needs: build
name: release files to PyPI
runs-on: ubuntu-latest
# Protection Strategies -- use ONE of the following two lines:
if: false
# if: github.event_name == 'release' && github.event.action == 'published' # publish on via explicit publish
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # publish on tag starting w/ 'v'
steps:
- name: download files
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: artifact
- name: set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install twine
- run: twine check ./artifact/*
- name: Publish distribution to Test PyPI
run: twine upload -r testpypi ./artifact/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.FASTSIM_TEST_PYPI_TOKEN }}
- name: Upload files to PyPI
run: twine upload ./artifact/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.fastsim_pypi_token }}