-
Notifications
You must be signed in to change notification settings - Fork 4
260 lines (220 loc) · 7.67 KB
/
cd.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# Provide continuous delivery (CD).
#
# CD deliverables currently include:
# - source distributions (for PyPI);
# - (natively) built Python wheel distributions (for PyPI);
# - (natively) built Conda packages (for Anaconda).
#
name: continuous-delivery
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.post[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
paths:
- deploy/pkg/conda_recipe/**
- .github/workflows/cd.yml
workflow_dispatch:
inputs:
run_build_sdist:
description: 'Run job build_sdist'
type: boolean
default: false
required: false
run_build_bdist:
description: 'Run job build_bdist'
type: boolean
default: false
required: false
run_build_conda:
description: 'Run job build_conda'
type: boolean
default: false
required: false
version_tag:
description: 'Version tag for delivery'
type: string
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_sdist:
name: Build sdist tarball
runs-on: ubuntu-latest
timeout-minutes: 20
if: >
github.event_name != 'workflow_dispatch' ||
github.event.inputs.run_build_sdist == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install packaging requirements
run: python -m pip install --upgrade build twine
- name: Build source distribution
run: python -m build --sdist --outdir dist/ .
- name: Verify source distribution
run: python -m twine check --strict dist/*
- name: Save tarball to sdist
uses: actions/upload-artifact@v4
with:
name: sdist_tar_${{ github.ref_name }}
path: dist/*.tar.gz
- name: Save tarball to pypi_dist
uses: actions/upload-artifact@v4
with:
name: pypi_dist_${{ github.ref_name }}
path: dist/*.tar.gz
build_bdist:
name: Build bdist wheel
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-13]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
# Allow manual trigger from inputs.
if: >
github.event_name != 'workflow_dispatch' ||
github.event.inputs.run_build_bdist == 'true'
steps:
# HACK: GitHub macOS runner defaults to a broken release of Xcode.
# See https://github.com/actions/runner-images/issues/9273.
- name: Pin Xcode version (macOS)
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install packaging requirements
run: python -m pip install --upgrade twine
- name: Build built distribution
uses: pypa/cibuildwheel@v2.18.1
with:
package-dir: .
output-dir: dist/
config-file: pyproject.toml
env:
# Default to GCC compiler and OpenMP on macOS.
CIBW_ENVIRONMENT_MACOS: >-
PY_CXX=g++-13
PY_CXXFLAGS=-I$(brew --prefix)/include
PY_LDFLAGS=-L$(brew --prefix)/lib
# # Switch to LLVM compiler and OpenMP on macOS.
# CIBW_ENVIRONMENT_MACOS: >-
# PY_CXX=$(brew --prefix llvm@15)/bin/clang++
# PY_CXXFLAGS=-I$(brew --prefix)/include
# PY_LDFLAGS=-L$(brew --prefix)/lib
# PY_OMP=1
# PY_CXXFLAGS_OMP="-I$(brew --prefix libomp)/include -fopenmp"
# PY_LDFLAGS_OMP="-L$(brew --prefix libomp)/lib -lomp"
CIBW_BEFORE_BUILD_MACOS: >
echo "Prefix\n $(ls -LR $(brew --prefix)/opt/gcc* || true)"
echo "Bin\n $(ls -LR $(brew --prefix)/bin/g* || true)"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
delocate-listdeps {wheel} &&
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
- name: Verify built distribution
run: python -m twine check --strict dist/*
- name: Save wheel to bdist
uses: actions/upload-artifact@v4
with:
name: bdist_wheel_${{ matrix.os }}_${{ github.ref_name }}
path: dist/*.whl
- name: Save wheel to pypi_dist
uses: actions/upload-artifact@v4
with:
name: pypi_dist_${{ matrix.os }}_${{ github.ref_name }}
path: dist/*.whl
build_conda:
name: Build Conda package
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-13]
runs-on: ${{ matrix.os }}
timeout-minutes: 120
if: >
github.event_name != 'workflow_dispatch' ||
github.event.inputs.run_build_conda == 'true'
defaults:
run:
shell: bash -el {0}
steps:
# HACK: GitHub macOS runner defaults to a broken release of Xcode.
# See https://github.com/actions/runner-images/issues/9273.
- name: Pin Xcode version (macOS)
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up (Mini)conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: conda_bld
channels: conda-forge
channel-priority: strict
- name: Install packaging requirements
run: |
conda install -y conda-build conda-verify conda-package-handling
# `cph` not found otherwise.
conda_root=$(conda config --show root_prefix | sed 's/root_prefix: //')
conda_env=${conda_root}/envs/conda_bld
export PATH=$PATH:${conda_root}/bin:${conda_env}/bin
- name: Override version
if: github.event_name == 'workflow_dispatch'
uses: knicknic/os-specific-run@v1.0.4
env:
recipe_file: deploy/pkg/conda_recipe/meta.yaml
with:
linux: |
vers_tag=${{ github.event.inputs.version_tag }}
if [[ ! -z ${vers_tag} ]]; then
sed -i "s/# git_rev:.*/git_rev: ${vers_tag}/g" ${recipe_file}
fi
macos: |
vers_tag=${{ github.event.inputs.version_tag }}
if [[ ! -z ${vers_tag} ]]; then
sed -i '' "s/# git_rev:.*/git_rev: ${vers_tag}/g" ${recipe_file}
fi
- name: Build Conda package
env:
recipe_dir: deploy/pkg/conda_recipe
output_dir: dist/
variants: "{'python': ['3.8', '3.9', '3.10', '3.11', '3.12']}"
run: |
# Create output directory if non-existent.
if [[ ! -d ${output_dir} ]]; then mkdir -p ${output_dir}; fi
# Build.
conda build --strict-verify --no-anaconda-upload ${recipe_dir} \
--variants "${variants}" --output-folder ${output_dir}
# Transmute.
find ${output_dir} -name "*.tar.bz2" \
-exec cph transmute {} .conda --out-folder ${output_dir} \;
- name: Save build to conda_bld
uses: actions/upload-artifact@v4
with:
name: conda_bld_${{ matrix.os }}_${{ github.ref_name }}
path: dist/*
- name: Save build to conda_dist
uses: actions/upload-artifact@v4
with:
name: conda_dist_${{ matrix.os }}_${{ github.ref_name }}
path: |
dist/**/*.tar.bz2
dist/*.conda