-
Notifications
You must be signed in to change notification settings - Fork 1
506 lines (492 loc) · 18.4 KB
/
release.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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
name: PyAuto Release
on:
workflow_dispatch:
inputs:
minor_version:
description: 'Minor version to release'
required: true
default: '1'
skip_scripts:
description: 'Skip scripts'
required: false
default: 'false'
skip_notebooks:
description: 'Skip notebooks'
required: false
default: 'false'
jobs:
version_number:
runs-on: ubuntu-latest
outputs:
version_number: ${{ steps.version_number.outputs.version_number }}
steps:
- name: Compute version number
run: |
export DATE_FORMATTED=`date +"%Y.%-m.%-d"`
MINOR_VERSION="${{ github.event.inputs.minor_version }}"
VERSION="${DATE_FORMATTED}.${MINOR_VERSION:-${{ github.run_number }}}"
RUN_ATTEMPT="${{ github.run_attempt }}"
if [ "$RUN_ATTEMPT" -gt "1" ]
then
VERSION="$VERSION.$RUN_ATTEMPT"
fi
export VERSION
echo "::set-output name=version_number::${VERSION}"
id: version_number
release_test_pypi:
runs-on: ubuntu-latest
needs: version_number
env:
TWINE_REPOSITORY: testpypi
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI }}
strategy:
matrix:
python-version: [3.11]
project:
- repository: rhayes777/PyAutoConf
ref: main
path: PyAutoConf
- repository: rhayes777/PyAutoFit
ref: main
path: PyAutoFit
- repository: Jammy2211/PyAutoArray
ref: main
path: PyAutoArray
- repository: Jammy2211/PyAutoGalaxy
ref: main
path: PyAutoGalaxy
- repository: Jammy2211/PyAutoLens
ref: main
path: PyAutoLens
- repository: Jammy2211/PyAutoCTI
ref: main
path: PyAutoCTI
steps:
- uses: actions/checkout@v2
with:
path: PyAutoBuild
- name: Checkout
uses: actions/checkout@v2
with:
repository: "${{ matrix.project.repository }}"
ref: "${{ matrix.project.ref }}"
path: "${{ matrix.project.path }}"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build
run: |
pushd "${{ matrix.project.path }}"
export VERSION="${{ needs.version_number.outputs.version_number }}"
sed -i "s/__version__ = [\.\"\'0-9]*/__version__ = \"$VERSION\"/g" */__init__.py
python3 -m pip install --upgrade build
python3 -m build
popd
- name: Upload to test PyPI
run: |
python3 -m pip install twine
pushd "${{ matrix.project.path }}"
python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
popd
- name: Wait for packages to upload to Pypi
shell: bash {0} # So that we do not exit if a command gives a bad exit code
run: |
export PACKAGES=("autoconf" "autoarray" "autofit" "autogalaxy" "autolens" "autocti")
export VERSION="${{ needs.version_number.outputs.version_number }}"
for PACKAGE in ${PACKAGES[@]}; do
python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple $PACKAGE==$VERSION
test_condition=$?
cnt=0
while [[ $test_condition != "0" ]]; do
echo "Failed to find package, retrying in 10 seconds.."
sleep 10
((cnt=cnt+1))
[[ $cnt == "100" ]] && echo "Timed out, tried 100 times" && break
python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple $PACKAGE==$VERSION
test_condition=$?
done
done
- name: Tests
run: |
pushd "${{ matrix.project.path }}"
if test -f "optional_requirements.txt"
then
pip install -r requirements.txt
pip install -r optional_requirements.txt
fi
pip install pytest
python3 -m pytest
find_scripts:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.script_matrix.outputs.matrix }}
steps:
- name: Checkout AutoFit
uses: actions/checkout@v2
with:
repository: Jammy2211/autofit_workspace
path: autofit
- name: Checkout AutoGalaxy
uses: actions/checkout@v2
with:
repository: Jammy2211/autogalaxy_workspace
path: autogalaxy
- name: Checkout AutoLens
uses: actions/checkout@v2
with:
repository: Jammy2211/autolens_workspace
path: autolens
- name: Checkout AutoCTI
uses: actions/checkout@v2
with:
repository: Jammy2211/autocti_workspace
path: autocti
- name: Checkout AutoFit Test
uses: actions/checkout@v2
with:
repository: Jammy2211/autofit_workspace_test
path: autofit_test
- name: Checkout AutoLens Test
uses: actions/checkout@v2
with:
repository: Jammy2211/autolens_workspace_test
path: autolens_test
- uses: actions/checkout@v2
with:
path: PyAutoBuild
- name: Make script matrix
id: script_matrix
run: |
matrix="$(./PyAutoBuild/autobuild/script_matrix.py autofit autogalaxy autolens autocti autofit_test autolens_test)"
echo "::set-output name=matrix::$matrix"
run_scripts:
runs-on: ubuntu-latest
needs:
- release_test_pypi
- version_number
- find_scripts
strategy:
fail-fast: false
matrix:
python-version: [3.11]
project:
${{ fromJSON(needs.find_scripts.outputs.matrix) }}
steps:
- name: Configure
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
id: configure
run: |
if [ ${{ matrix.project.name }} == "autofit" ]
then
echo "::set-output name=repository::rhayes777/PyAutoFit"
echo "::set-output name=workspace_repository::Jammy2211/autofit_workspace"
echo "::set-output name=project::autofit"
elif [ ${{ matrix.project.name }} == "autogalaxy" ]
then
echo "::set-output name=repository::Jammy2211/PyAutoGalaxy"
echo "::set-output name=workspace_repository::Jammy2211/autogalaxy_workspace"
echo "::set-output name=project::autogalaxy"
elif [ ${{ matrix.project.name }} == "autolens" ]
then
echo "::set-output name=repository::Jammy2211/PyAutoLens"
echo "::set-output name=workspace_repository::Jammy2211/autolens_workspace"
echo "::set-output name=project::autolens"
elif [ ${{ matrix.project.name }} == "autocti" ]
then
echo "::set-output name=repository::Jammy2211/PyAutoCTI"
echo "::set-output name=workspace_repository::Jammy2211/autocti_workspace"
echo "::set-output name=project::autocti"
elif [ ${{ matrix.project.name }} == "autofit_test" ]
then
echo "::set-output name=repository::rhayes777/PyAutoFit"
echo "::set-output name=workspace_repository::Jammy2211/autofit_workspace_test"
echo "::set-output name=project::autofit"
else
echo "::set-output name=repository::Jammy2211/PyAutoLens"
echo "::set-output name=workspace_repository::Jammy2211/autolens_workspace_test"
echo "::set-output name=project::autolens"
fi
- uses: actions/checkout@v2
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
with:
path: PyAutoBuild
- name: Checkout project
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
uses: actions/checkout@v2
with:
repository: "${{ steps.configure.outputs.repository }}"
path: project
- name: Checkout workspace
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
uses: actions/checkout@v2
with:
repository: ${{ steps.configure.outputs.workspace_repository }}
ref: main
path: workspace
- name: Set up Python ${{ matrix.python-version }}
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install optional requirements
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
run: |
if [ -f "project/optional_requirements.txt" ]
then
echo "Installing optional requirements"
python3 -m pip install -r "project/requirements.txt"
python3 -m pip install -r "project/optional_requirements.txt"
fi
- name: Install project
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
run: |
python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
- name: Run Python scripts
if: "${{ github.event.inputs.skip_scripts != 'true' }}"
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)/PyAutoBuild
export PATH=$PATH:$(pwd)/PyAutoBuild/autobuild
AUTOBUILD_PATH="$(pwd)/PyAutoBuild/autobuild"
if [[ ${{ matrix.project.name }} == *_test ]]
then
export PYAUTOFIT_TEST_MODE=0
else
export PYAUTOFIT_TEST_MODE=1
fi
pushd workspace
python3 "$AUTOBUILD_PATH/run_python.py" ${{ matrix.project.name }} "scripts/${{ matrix.project.directory }}"
run_notebooks:
runs-on: ubuntu-latest
needs:
- release_test_pypi
- version_number
- find_scripts
strategy:
fail-fast: false
matrix:
python-version: [3.11]
project:
${{ fromJSON(needs.find_scripts.outputs.matrix) }}
steps:
- name: Configure
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
id: configure
run: |
if [ ${{ matrix.project.name }} == "autofit" ]
then
echo "::set-output name=repository::rhayes777/PyAutoFit"
echo "::set-output name=workspace_repository::Jammy2211/autofit_workspace"
echo "::set-output name=project::autofit"
elif [ ${{ matrix.project.name }} == "autogalaxy" ]
then
echo "::set-output name=repository::Jammy2211/PyAutoGalaxy"
echo "::set-output name=workspace_repository::Jammy2211/autogalaxy_workspace"
echo "::set-output name=project::autogalaxy"
elif [ ${{ matrix.project.name }} == "autolens" ]
then
echo "::set-output name=repository::Jammy2211/PyAutoLens"
echo "::set-output name=workspace_repository::Jammy2211/autolens_workspace"
echo "::set-output name=project::autolens"
else
echo "::set-output name=repository::Jammy2211/PyAutoCTI"
echo "::set-output name=workspace_repository::Jammy2211/autocti_workspace"
echo "::set-output name=project::autocti"
fi
- uses: actions/checkout@v2
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
with:
path: PyAutoBuild
- name: Checkout project
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
uses: actions/checkout@v2
with:
repository: "${{ steps.configure.outputs.repository }}"
path: project
- name: Checkout workspace
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
uses: actions/checkout@v2
with:
repository: ${{ steps.configure.outputs.workspace_repository }}
ref: main
path: workspace
- name: Set up Python ${{ matrix.python-version }}
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install optional requirements
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
run: |
if [ -f "project/optional_requirements.txt" ]
then
echo "Installing optional requirements"
python3 -m pip install -r "project/requirements.txt"
python3 -m pip install -r "project/optional_requirements.txt"
fi
- name: Install project
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
run: |
python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
- name: Install Jupyter dependency
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
run: |
python3 -m pip install jupyter ipynb-py-convert
- name: Generate jupyter notebooks
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)/PyAutoBuild
AUTOBUILD_PATH="$(pwd)/PyAutoBuild/autobuild"
pushd "workspace"
python3 "$AUTOBUILD_PATH/generate.py" ${{ matrix.project.name }}
- name: Run jupyter notebooks
if: "${{ github.event.inputs.skip_notebooks != 'true' }}"
run: |
if [[ ${{ matrix.project.name }} == *_test ]]
then
export PYAUTOFIT_TEST_MODE=0
else
export PYAUTOFIT_TEST_MODE=1
fi
export PYTHONPATH=$PYTHONPATH:$(pwd)/PyAutoBuild
AUTOBUILD_PATH="$(pwd)/PyAutoBuild/autobuild"
pushd workspace
python3 "$AUTOBUILD_PATH/run.py" ${{ matrix.project.name }} "notebooks/${{ matrix.project.directory }}"
release:
runs-on: ubuntu-latest
env:
TWINE_REPOSITORY: pypi
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
needs:
- run_scripts
- run_notebooks
- release_test_pypi
- version_number
strategy:
matrix:
project:
- repository: rhayes777/PyAutoConf
ref: main
path: PyAutoConf
pat: PAT_RICH
- repository: rhayes777/PyAutoFit
ref: main
path: PyAutoFit
pat: PAT_RICH
- repository: Jammy2211/PyAutoArray
ref: main
path: PyAutoArray
pat: PAT_JAMES
- repository: Jammy2211/PyAutoGalaxy
ref: main
path: PyAutoGalaxy
pat: PAT_JAMES
- repository: Jammy2211/PyAutoLens
ref: main
path: PyAutoLens
pat: PAT_JAMES
- repository: Jammy2211/PyAutoCTI
ref: main
path: PyAutoCTI
pat: PAT_JAMES
steps:
- uses: actions/checkout@v2
with:
path: PyAutoBuild
- name: Checkout
run: |
git clone -b "${{ matrix.project.ref }}" "https://$PAT@github.com/${{ matrix.project.repository }}.git" "${{ matrix.project.path }}"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Configure Git
run: |
git config --global user.email "richard@rghsoftware.co.uk"
git config --global user.name "GitHub Actions bot"
- name: Update version
run: |
pushd "${{ matrix.project.path }}"
VERSION="${{ needs.version_number.outputs.version_number }}"
sed -i "s/__version__ = [\.\"\'0-9]*/__version__ = \"$VERSION\"/g" */__init__.py
git commit "-am 'Updated version in __init__ to $VERSION"
- name: Tag
run: |
pushd "${{ matrix.project.path }}"
VERSION="${{ needs.version_number.outputs.version_number }}"
git tag -m "Release $VERSION" -a "$VERSION"
PAT="${{ secrets[matrix.project.pat] }}"
git remote set-url --push origin "https://$PAT@github.com/${{ matrix.project.repository }}.git"
git push --tags
- name: Build
run: |
pushd "${{ matrix.project.path }}"
export VERSION="${{ needs.version_number.outputs.version_number }}"
python3 -m pip install --upgrade build
python3 -m build
- name: Upload to PyPI
run: |
python3 -m pip install twine
pushd "${{ matrix.project.path }}"
python3 -m twine upload dist/*
release_workspaces:
runs-on: ubuntu-latest
env:
TWINE_REPOSITORY: pypi
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
PAT: ${{ secrets.PAT_JAMES }}
needs:
- run_scripts
- run_notebooks
- release_test_pypi
- version_number
strategy:
matrix:
python-version: [3.11]
workspace:
- repository: Jammy2211/autofit_workspace
name: autofit -
- repository: Jammy2211/autogalaxy_workspace
name: autogalaxy
- repository: Jammy2211/autolens_workspace
name: autolens
- repository: Jammy2211/autocti_workspace
name: autocti
steps:
- uses: actions/checkout@v2
with:
path: PyAutoBuild
- name: Checkout
run: |
git clone -b main "https://$PAT@github.com/${{ matrix.workspace.repository }}.git" workspace
- name: Configure Git
run: |
git config --global user.email "richard@rghsoftware.co.uk"
git config --global user.name "GitHub Actions bot"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Jupyter dependency
run: |
pip install jupyter ipynb-py-convert PyYAML
- name: Update jupyter notebooks
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)/PyAutoBuild
AUTOBUILD_PATH="$(pwd)/PyAutoBuild/autobuild"
pushd workspace
python3 "$AUTOBUILD_PATH/generate.py" ${{ matrix.workspace.name }}
git add *.ipynb
git commit -m "Updated notebooks" || true
- name: Release
run: |
cd workspace
git checkout release
git merge main
VERSION="${{ needs.version_number.outputs.version_number }}"
git tag -m "Release $VERSION" -a "$VERSION"
git push
git push --tags