-
Notifications
You must be signed in to change notification settings - Fork 148
325 lines (298 loc) · 11.5 KB
/
Copy pathrelease.yml
File metadata and controls
325 lines (298 loc) · 11.5 KB
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
name: NEURON Release
on:
workflow_dispatch:
inputs:
rel_branch:
description: 'Release branch/commit'
default: 'release/x.y'
required: true
rel_tag:
description: 'Release version (tag name)'
default: 'x.y.z'
required: true
python_versions:
description: "Comma-separated list of supported Python versions"
default: "3.9,3.10,3.11,3.12,3.13"
required: true
type: string
os:
description: "Comma-separated list of OSes (for wheels only)"
default: "macos-13,macos-14,ubuntu-22.04,ubuntu-22.04-arm"
required: true
type: string
upload:
description: "Whether to actually upload any files (releases, wheels, etc.)"
required: true
default: false
type: boolean
env:
GH_REPO: ${{ github.server_url }}/${{ github.repository }}
REL_TAG: ${{ github.event.inputs.rel_tag }}
REL_BRANCH: ${{ github.event.inputs.rel_branch }}
jobs:
get-latest-wheel-version:
name: Get the latest wheel version from PyPI
runs-on: ubuntu-latest
outputs:
latest_version: ${{ steps.latest-wheel-version.outputs.latest_version }}
steps:
- name: Get the latest wheel version from PyPI
id: latest-wheel-version
run: |
# taken from:
# https://safjan.com/how-to-check-latest-version-of-python-package/
echo "latest_version=$(curl -s https://pypi.org/pypi/neuron/json | jq -r '.info.version')" >> "$GITHUB_OUTPUT"
generate-wheel-matrix:
name: Generate platform and Python matrix for wheels
# wheels should be built once the full source package builds successfully
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
OS_INPUT="${{ github.event.inputs.os || 'macos-13,macos-14,ubuntu-22.04,ubuntu-22.04-arm' }}"
PY_INPUT="${{ github.event.inputs.python_versions || '3.9,3.10,3.11,3.12,3.13' }}"
OS_JSON=$(echo "$OS_INPUT" | jq -R 'split(",")')
PY_JSON=$(echo "$PY_INPUT" | jq -R 'split(",")')
echo "matrix=$(jq -c -n --argjson os "$OS_JSON" --argjson py "$PY_JSON" '{os: $os, python_version: $py}')" >> "$GITHUB_OUTPUT"
# we need to build wheels _before_ running modelDB CI, since it only works
# with wheels, and not the CMake installer
build-wheels:
name: Build and test wheel on ${{ matrix.os }} with Python ${{ matrix.python_version }}
needs:
- generate-wheel-matrix
- tag-n-release
uses: ./.github/workflows/wheels-template.yml
strategy:
matrix: ${{ fromJson(needs.generate-wheel-matrix.outputs.matrix) }}
with:
platform: ${{ matrix.os }}
python_version: ${{ matrix.python_version }}
optimize_rxd: true
commit: ${{ needs.tag-n-release.outputs.ref }} # Uses tag (if upload=true) or branch
version: ${{ github.event.inputs.rel_tag }}
build_type: 'release'
merge-wheels:
name: Merge wheel files to one artifact
runs-on: ubuntu-latest
needs:
- build-wheels
outputs:
artifacts-url: ${{ steps.merge-artifacts.outputs.artifacts-url }}
steps:
- name: Merge Artifacts
id: merge-artifacts
uses: actions/upload-artifact/merge@v4
with:
delete-merged: true
name: wheels
pattern: wheels-*
nrn-modeldb-ci:
name: Run modelDB CI relative to ${{ needs.get-latest-wheel-version.outputs.latest_version }}
needs:
- get-latest-wheel-version
- merge-wheels
uses: neuronsimulator/nrn-modeldb-ci/.github/workflows/nrn-modeldb-ci.yaml@master
with:
# v1 is the latest stable wheel, while v2 is the currently-built wheel.
# Note that v2 needs to at least contain an x86_64 Linux Python 3.9 wheel since that is the platform that modelDB CI uses
neuron_v1: neuron==${{ needs.get-latest-wheel-version.outputs.latest_version }}
neuron_v2: ${{ needs.merge-wheels.outputs.artifacts-url }}
nrn-full-src-package:
name: Create the full-src package
runs-on: ubuntu-latest
outputs:
topdir: ${{ steps.create-full-src.outputs.topdir }}
filename: ${{ steps.create-full-src.outputs.filename }}
steps:
- name: Checkout feature-rich code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
ref: ${{ github.event.inputs.rel_branch }}
- name: Create nrn-full-src-package artifact
id: create-full-src
run: |
filename="nrn-full-src-package-${{ env.REL_TAG }}.tar.gz"
echo "filename=$filename" >> "$GITHUB_OUTPUT"
topdir="nrn-${{ env.REL_TAG }}"
echo "topdir=${topdir}" >> "$GITHUB_OUTPUT"
# taken from:
# https://stackoverflow.com/a/67389978
git ls-files --recurse-submodules > nrn_files
# we also need the .git dir for now
find .git >> nrn_files
# cannot use --xform as it screws up the symbolic links. So
# do a normal tar, untar into topdir, and tar again.
mkdir -p tmp/$topdir
tar -c -T nrn_files | tar -x -C tmp/$topdir
(cd tmp && tar caf ../$filename $topdir)
rm -rf tmp
- name: Upload nrn-full-src-package artifact
uses: actions/upload-artifact@v4
id: upload-full-src
with:
name: nrn-full-src-package
path: ${{ steps.create-full-src.outputs.filename }}
test-full-src-package:
name: Build and test the full-src package
runs-on: ubuntu-latest
needs:
- nrn-full-src-package
steps:
- name: Install apt packages
run: |
sudo apt-get install -y bison flex libreadline-dev libfl-dev libmpich-dev
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version : '3.18'
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Download nrn-full-src-package artifact
uses: actions/download-artifact@v4
with:
name: nrn-full-src-package
- name: Build nrn-full-src-package
run: |
tar xf ${filename}
python -m venv ${venv_dir}
source ${venv_dir}/bin/activate
if [[ -f "${topdir}/ci/requirements.txt" ]]; then
python -m pip install -r ${topdir}/ci/uv_requirements.txt
uv pip install -r ${topdir}/ci/requirements.txt
else
python -m pip install -r ${topdir}/nrn_requirements.txt
fi
# we build a simple configuration to save on CI time
cmake -B build -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_MPI=OFF -DNMODL_ENABLE_PYTHON_BINDINGS=OFF -DNRN_ENABLE_CORENEURON=OFF -S ${topdir}/
cmake --build build --parallel $(nproc)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
topdir: ${{ needs.nrn-full-src-package.outputs.topdir }}
filename: ${{ needs.nrn-full-src-package.outputs.filename }}
venv_dir: venv_${{ steps.setup-python.outputs.python-version }}
nrn-build-ci:
name: Run build CI
needs:
- merge-wheels
uses: neuronsimulator/nrn-build-ci/.github/workflows/build-neuron-template.yml@main
with:
artifact_url: ${{ needs.merge-wheels.outputs.artifacts-url }}
neuron_branch: ${{ github.event.inputs.rel_branch }}
repo: 'neuronsimulator/nrn-build-ci'
pypi-publish:
name: Upload wheels to PyPI
if: github.event.inputs.upload == 'true'
needs:
- merge-wheels
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/neuron
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download wheels from artifact
uses: actions/download-artifact@v4
with:
name: wheels
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# actually creates a git tag and a release on GitHub
tag-n-release:
runs-on: ubuntu-latest
name: tag-n-release ${{ github.event.inputs.rel_tag }} (${{ github.event.inputs.rel_branch }})
outputs:
release_url: ${{ steps.create_release.outputs.upload_url }}
rel_tag: ${{ env.REL_TAG }}
ref: ${{ steps.build-ref.outputs.ref }} # Conditional ref for builds
steps:
- uses: actions/checkout@v4
name: Checkout branch ${{ env.REL_BRANCH }}
with:
ref: ${{ github.event.inputs.rel_branch }}
- name: Determine build ref # Sets ref to tag (if upload=true) or branch
id: build-ref
run: |
if [[ "${{ github.event.inputs.upload }}" == 'true' ]]; then
echo "ref=${{ env.REL_TAG }}" >> $GITHUB_OUTPUT
else
echo "ref=${{ github.event.inputs.rel_branch }}" >> $GITHUB_OUTPUT
fi
- name: Create and upload tag ${{ env.REL_TAG }}
# Moved the earlier `if` to here so the build items can succeed with upload false
if: github.event.inputs.upload == 'true'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag -a $REL_TAG -m "${REL_TAG}"
git push origin $REL_TAG
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{runner.workspace}}/nrn
- name: Create Release
if: github.event.inputs.upload == 'true' # Skip on dry runs
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ github.event.inputs.rel_tag }}
name: Release ${{ github.event.inputs.rel_tag }}
prerelease: true
upload-src-package:
name: Publish full-src package
runs-on: ubuntu-latest
if: github.event.inputs.upload == 'true'
needs:
- nrn-full-src-package
- tag-n-release
steps:
- name: Download nrn-full-src-package artifact
uses: actions/download-artifact@v4
with:
name: nrn-full-src-package
- name: Upload to GitHub release
run: |
gh release upload ${{ env.REL_TAG }} ${{ needs.nrn-full-src-package.outputs.filename }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-windows-installer:
name: Build Windows installer
needs:
- tag-n-release
uses: neuronsimulator/nrn/.github/workflows/windows.yml@master
with:
tag: ${{ needs.tag-n-release.outputs.ref }}
upload-windows-installer:
name: Publish Windows installer
if: github.event.inputs.upload == 'true'
needs:
- build-windows-installer
runs-on: ubuntu-latest
steps:
- name: Download Windows installer artifact
uses: actions/download-artifact@v4
with:
name: nrn-nightly-AMD64.exe
- name: Rename Windows installer
id: rename
run: |
# convert "3.9,3.10..." into "39-310-..."
py_version_string="$(echo "${{ github.event.inputs.python_versions }}" | sed 's/\.//g; s/,/-/g')"
win_installer_name="nrn-${{ env.REL_TAG }}.w64-mingw-py-${py_version_string}-setup.exe"
echo "win_installer_name=${win_installer_name}" >> "$GITHUB_OUTPUT"
cp nrn-nightly-AMD64.exe "${win_installer_name}"
ls -lha "${win_installer_name}"
- name: Publish Windows installer
run: |
gh release upload ${{ env.REL_TAG }} ${{ steps.rename.outputs.win_installer_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}