-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (148 loc) · 5.07 KB
/
build_wheels_and_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
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: © 2023 Aalto University, © 2024 Lukas Prediger
name: Build_pypi_wheels
on:
push:
branches: [ "*stable" ]
tags: [ "*rc*"]
pull_request:
branches: [ "*stable" ]
jobs:
build_pypi_binary_wheels:
name: Build wheels on ${{ matrix.os }} for ${{ matrix.platform }} ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
platform: [manylinux, musllinux, macosx]
arch: [x86_64, arm64, aarch64, universal2]
exclude:
- os: macos-11
platform: manylinux
- os: macos-11
platform: musllinux
- os: macos-11
arch: aarch64
- os: ubuntu-20.04
platform: macosx
- os: ubuntu-20.04
arch: universal2
- os: ubuntu-20.04
arch: arm64
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up QEMU
if: runner.os == 'Linux' && matrix.arch == 'aarch64'
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build wheels CPU only
if: ${{ !(matrix.platform == 'manylinux' && matrix.arch == 'x86_64') }}
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_BUILD: "*-${{ matrix.platform }}*"
CIBW_BUILD_VERBOSITY: 2
CIBW_ENVIRONMENT_MACOS: JAX_CHACHA_PRNG_DISABLE_OPENMP=1
# CIBW_ENVIRONMENT: JAX_CHACHA_PRNG_BUILD="cpu"
- name: Build wheels CUDA 11
if: ${{ matrix.platform == 'manylinux' && matrix.arch == 'x86_64' }}
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_BUILD: "*-${{ matrix.platform }}*"
CIBW_BUILD_VERBOSITY: 2
CIBW_BEFORE_ALL_LINUX: >
curl -o installer.run -s https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run &&
/bin/sh ./installer.run --toolkit --silent
CIBW_ENVIRONMENT: PATH=/usr/local/cuda/bin:$PATH # JAX_CHACHA_PRNG_BUILD="cuda11.1"
CIBW_ENVIRONMENT_MACOS: JAX_CHACHA_PRNG_DISABLE_OPENMP=1
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
name: dist
build_pypi_source_dist:
name: Build source distribution package for PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'
- name: Setup build environment
run: pip install build
- name: Build sdist
run: python -m build --sdist
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.tar.gz
name: dist
upload_pypi_wheels:
name: Upload wheels to PyPI
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'stable') && github.event_name == 'push' }}
needs:
- build_pypi_binary_wheels
- build_pypi_source_dist
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: ./dist/
- uses: pypa/gh-action-pypi-publish@release/v1
name: Upload to PyPI
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
create_github_release:
name: Create GitHub Release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
needs:
- build_pypi_binary_wheels
- build_pypi_source_dist
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: dist
path: ./dist/
- name: Publish Pre-Release
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(python -c "import chacha.version; print(chacha.version.VERSION)")
TAG_NAME=${GITHUB_REF##refs/tags/}
echo "Version: ${VERSION}"
echo "Ref: ${GITHUB_REF}"
echo "Tag: ${TAG_NAME}"
assets=()
for asset in $(find ./dist/ -type f); do
echo "Adding asset: ${asset}"
assets+=("-a" "$asset")
done
hub release create -p "${assets[@]}" -m "$VERSION" -F ChangeLog.txt "$VERSION"
- name: Publish Release
if: contains(github.ref, 'stable')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(python -c "import chacha.version; print(chacha.version.VERSION)")
echo "Version: ${VERSION}"
echo "Ref: ${GITHUB_REF}"
echo "Commit: ${GITHUB_SHA}"
assets=()
for asset in $(find ./dist/ -type f); do
echo "Adding asset: ${asset}"
assets+=("-a" "$asset")
done
hub release create "${assets[@]}" -m "$VERSION" -F ChangeLog.txt -t "$GITHUB_SHA" "$VERSION"