-
Notifications
You must be signed in to change notification settings - Fork 34
279 lines (246 loc) · 10.2 KB
/
prepare_release.yml
File metadata and controls
279 lines (246 loc) · 10.2 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
# Run MATLAB tests across multiple MATLAB versions and create a draft release
name: Prepare release
on:
workflow_dispatch:
inputs:
version:
description: 'Version number in major.minor.patch format, i.e 2.8.0'
required: true
type: string
jobs:
validate_version:
runs-on: ubuntu-latest
steps:
- name: Check version format
run: |
version="${{ github.event.inputs.version }}"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Input for 'version' ('$version') is not in the expected major.minor.patch format."
exit 1
fi
echo "Version '$version' is valid."
run_tests:
name: Run MATLAB tests (${{ matrix.matlab-version }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [validate_version]
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-15-intel]
# Note: When updating MATLAB versions, also update:
# - .github/workflows/configurations/matlab_release_matrix_strategy.yml
# - The badge text in the 'Generate tested with badge' step below
include:
- matlab-version: R2021a
python-version: '3.9'
skip-pynwb-tests: '1'
skip-nwbinspector-test: '1'
- matlab-version: R2021b
python-version: '3.9'
skip-pynwb-tests: '1'
skip-nwbinspector-test: '1'
- matlab-version: R2022a
python-version: '3.9'
skip-pynwb-tests: '1'
skip-nwbinspector-test: '1'
- matlab-version: R2022b
python-version: '3.9'
skip-pynwb-tests: '1'
skip-nwbinspector-test: '1'
- matlab-version: R2023a
python-version: '3.10'
skip-pynwb-tests: '0'
skip-nwbinspector-test: '0'
- matlab-version: R2023b
python-version: '3.10'
skip-pynwb-tests: '0'
skip-nwbinspector-test: '0'
- matlab-version: R2024a
python-version: '3.11'
skip-pynwb-tests: '0'
skip-nwbinspector-test: '0'
- matlab-version: R2024b
python-version: '3.11'
skip-pynwb-tests: '0'
skip-nwbinspector-test: '0'
- matlab-version: R2025a
python-version: '3.12'
skip-pynwb-tests: '0'
skip-nwbinspector-test: '0'
- matlab-version: R2025b
python-version: '3.13'
skip-pynwb-tests: '0'
skip-nwbinspector-test: '0'
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Install python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
shell: bash
run: |
python -m pip install -U pip
pip install -r +tests/requirements.txt
# Install pynwb and nwbinspector only for Python 3.10+ (both dropped Python 3.9 support)
if [[ "${{ matrix.skip-pynwb-tests }}" == "0" ]]; then
pip install "git+https://github.com/NeurodataWithoutBorders/pynwb.git@dev"
fi
if [[ "${{ matrix.skip-nwbinspector-test }}" == "0" ]]; then
pip install "git+https://github.com/NeurodataWithoutBorders/nwbinspector.git@dev"
fi
python -m pip list
- name: Configure python env (macOS, ubuntu)
if: runner.os != 'Windows'
run: |
echo "HDF5_PLUGIN_PATH=$(python -c "import hdf5plugin; print(hdf5plugin.PLUGINS_PATH)")" >> "$GITHUB_ENV"
- name: Configure python env (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$pluginPath = python -c "import hdf5plugin; print(hdf5plugin.PLUGINS_PATH)"
Add-Content -Path $env:GITHUB_ENV -Value "HDF5_PLUGIN_PATH=$pluginPath"
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v3
with:
release: ${{ matrix.matlab-version }}
- name: Run tests
uses: matlab-actions/run-command@v3
env:
HDF5_PLUGIN_PATH: ${{ env.HDF5_PLUGIN_PATH }}
with:
command: |
setenv("SKIP_PYNWB_TESTS", ...
num2str(${{ matrix.skip-pynwb-tests }}))
setenv("SKIP_NWBINSPECTOR_TEST", ...
num2str(${{ matrix.skip-nwbinspector-test }}))
pyenv("ExecutionMode", "OutOfProcess");
results = assertSuccess(nwbtest('ReportOutputFolder', '.'));
assert(~isempty(results), 'No tests ran');
- name: Upload JUnit results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.os }}-${{ matrix.matlab-version }}
path: testResults.xml
publish_junit:
name: Publish JUnit test results
runs-on: ubuntu-latest
if: always()
needs: [run_tests]
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Retrieve result files
uses: actions/download-artifact@v7
with:
pattern: test-results-*
merge-multiple: false
- name: Publish test results
uses: mikepenz/action-junit-report@v6
with:
report_paths: '*/testResults.xml'
update_version:
name: Create new draft relase for given version
runs-on: ubuntu-latest
needs: [run_tests]
steps:
- name: Checkout repository using deploy key
uses: actions/checkout@v6
with:
ref: refs/heads/main
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Update Contents.m file
run: |
# Read the template file
template=$(cat .github/workflows/templates/contents_header_template.txt)
# Get current date in DD-MMM-YYYY format
date_string=$(date +"%d-%b-%Y")
# Get current year
year_number=$(date +"%Y")
# Replace placeholders in template
header="${template/\{\{version_number\}\}/${{ github.event.inputs.version }}}"
header="${header/\{\{date_string\}\}/$date_string}"
header="${header/\{\{year_number\}\}/$year_number}"
# Extract the content after the header from the current Contents.m file
content=$(awk '/^% -{10,}/{flag=1;next} flag{print}' Contents.m)
# Combine new header with existing content
echo "$header" > Contents.m
echo "$content" >> Contents.m
- name: Commit updated Contents.m file
continue-on-error: true
run: |
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
git add Contents.m
git commit -m "Update version number in Contents.m"
git fetch
git push
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12' # Pinned to 3.12 because of pybadges dependencies
- name: Generate tested with badge
# Note: Update this list when MATLAB versions change in the matrix above
run: |
pip install --upgrade setuptools
pip install pybadges
mkdir -p .github/badges/v${{ inputs.version }}
python -c "
from pybadges import badge
with open('.github/badges/v${{ inputs.version }}/tested_with.svg', 'w') as f:
f.write(badge(
left_text='tested with',
right_text='R2021a | R2021b | R2022a | R2022b | R2023a | R2023b | R2024a | R2024b | R2025a | R2025b',
right_color='green'
))
"
- name: Generate NWB schema version badge
run: |
python .github/workflows/scripts/create_nwb_schema_version_badge.py ${{ inputs.version }}
- name: Tag repository with version tag
if: always()
run: |
git fetch
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
# Create the tag with a message
git tag -a "v${{ inputs.version }}" -m "Release v${{ inputs.version }}"
# Push the new tag to the remote repository
git push origin "v${{ inputs.version }}"
# Commit the SVG for the MATLAB releases test badge to gh-badges branch
- name: Checkout gh-badges branch
uses: actions/checkout@v6
with:
ref: gh-badges
path: gh-badges
- name: Push to gh-badges
run: |
mkdir -p gh-badges/.github/badges/v${{ inputs.version }}
mkdir -p gh-badges/.github/badges/latest
cp .github/badges/v${{ inputs.version }}/tested_with.svg gh-badges/.github/badges/v${{ inputs.version }}/tested_with.svg
cp .github/badges/v${{ inputs.version }}/supported_nwb_schema.svg gh-badges/.github/badges/v${{ inputs.version }}/supported_nwb_schema.svg
cp .github/badges/latest/supported_nwb_schema.svg gh-badges/.github/badges/latest/supported_nwb_schema.svg
cd gh-badges
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
# Only proceed with commit and push if changes are detected
if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then
git add .github/badges/*
git commit -m "Update badges for release v${{ inputs.version }}"
git push -f
else
echo "Nothing to commit"
fi
# Create the release
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
draft: true
tag: ${{ inputs.version }}
generateReleaseNotes: true
body: |


