-
Notifications
You must be signed in to change notification settings - Fork 0
834 lines (750 loc) · 30.8 KB
/
release-impl.yml
File metadata and controls
834 lines (750 loc) · 30.8 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
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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
name: ⚙️ Release
on:
workflow_call:
inputs:
pre_release_branch:
required: true
type: string
description: >
Template parameter.
Name of branch with pre-release code.
release_branch:
required: true
type: string
description: >
Template parameter.
Name of branch with releases.
app_name:
required: true
type: string
description: >
Template parameter.
Human-readable application name.
executable_name:
required: true
type: string
description: >
Template parameter.
Root name of executable.
pyinstaller_dir:
type: string
description: >
Template parameter.
Name of directory containing pyinstaller configuration, hooks and support files.
default: pyinstaller
version_file:
required: true
type: string
description: >
Template parameter.
Path to Python file containing application version data.
benchmark_make_workflow:
required: true
type: string
description: >
Template parameter.
Path to application workflow used for benchmarking purposes.
pypi-url:
required: true
type: string
description: >
Template parameter.
URL to PyPI to use when uploading a release.
website_source_org:
required: true
type: string
description: >
Template parameter.
Name of organisation owning the website to publish docs to.
website_source_repo:
required: true
type: string
description: >
Template parameter.
Name of repository to publish the website docs to.
repository:
required: true
type: string
description: >
Template parameter.
Name of organisation/repository containing the code being released.
docs_url_prefix:
required: true
type: string
description: >
Template parameter.
Prefix to apply to documentation URL.
gh-run-attempt:
required: true
type: string
description: >
Attribute: `github.run_attempt`
Which attempt at running the workflow is this?
pr-merged:
required: true
type: string
description: >
Attribute: `github.event.pull_request.merged`
Is this running as the result of a PR being merged?
pr-title:
required: true
type: string
description: >
Attribute: `github.event.pull_request.title`
What is the title of the PR that was merged?
pr-base-ref:
required: true
type: string
description: >
Attribute: `github.event.pull_request.base.ref`
Where was the PR merged into?
pr-head-ref:
required: true
type: string
description: >
Attribute: `github.event.pull_request.head.ref`
Where was the PR merged from?
python-version:
description: >
Version of Python to use.
Note that the version in Rocky Linux is locked by the Docker image.
type: string
required: false
default: "3.13"
poetry-version:
description: >
Version of Poetry to use.
Note that the version in Rocky Linux is locked by the Docker image.
type: string
required: false
default: "2.1.3"
secrets:
general-token:
description: >
General github token without special permissions.
required: true
commit-token:
description: >
Token for committing to the main repository.
required: true
pypi-token:
description: >
Token for publishing to PyPI.
required: true
website-token:
description: >
Token for publishing the website.
required: true
outputs:
new-version:
description: >
The new version created.
value: ${{ jobs.bump-version.outputs.new_tag }}
changelog-url:
description: >
URL to the generated CHANGELOG.
value: ${{ jobs.bump-version.outputs.changelog }}
pypi-published:
description: >
Whether the release was successfully published to PyPI.
value: ${{ jobs.release-github-PyPI.outputs.publish-state == 'success' }}
website-published:
description: >
Whether the release was successfully published to the website.
value: ${{ jobs.update-website.outputs.publish-state == 'success' }}
jobs:
bump-version:
# skip if trying to re-run; PR is closed without merging; '[skip release]' is in the PR title; or if merging any branch other than pre_release_branch into release_branch
if: inputs.gh-run-attempt == '1' && inputs.pr-merged == 'true' && !contains(inputs.pr-title, '[skip release]') && (inputs.pr-base-ref == inputs.pre_release_branch || (inputs.pr-base-ref == inputs.release_branch && inputs.pr-head-ref == inputs.pre_release_branch))
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.new_tag.outputs.tag }}
version: ${{ steps.new_tag.outputs.version }}
changelog: ${{ steps.upload-changelog.outputs.artifact-url }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0 # get all history and tags
ref: ${{ inputs.pr-base-ref }}
token: ${{ secrets.commit-token }}
- name: Configure git
uses: hpcflow/github-support/configure-git@0.4
- name: Set up python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Get git-chglog executable
run: |
wget https://github.com/git-chglog/git-chglog/releases/download/v0.15.0/git-chglog_0.15.0_linux_amd64.tar.gz
tar --extract --file git-chglog_0.15.0_linux_amd64.tar.gz git-chglog
- name: Install commitizen
run: pip install commitizen
- name: Manipulate tags (stable release)
if: inputs.pr-base-ref == inputs.release_branch
id: pre_tag
# delete all pre-release tags, set current version to the latest stable release,
run: |
CUR_PRE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "CUR_PRE_TAG is: $CUR_PRE_TAG"
echo "tag=$CUR_PRE_TAG" >> $GITHUB_OUTPUT
git tag -l | awk '/^(v[0-9]+\.[0-9]+\.[0-9]+(a|b|rc).*)$/ {print $1}' | xargs git tag -d
- name: Get current tag
id: cur_tag
run: |
CUR_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "CUR_TAG is: $CUR_TAG"
echo "tag=$CUR_TAG" >> $GITHUB_OUTPUT
- name: Commitizen bump (pre-release) # Bump version strings (pre-release) and add a new tag; commit
if: inputs.pr-base-ref == inputs.pre_release_branch
run: cz bump --prerelease alpha
- name: Commitizen bump # First update version number to latest stable release, then bump to new stable release, add a new tag and commit
if: inputs.pr-base-ref == inputs.release_branch
run: |
python3 -c "
from commitizen.bump import update_version_in_files
update_version_in_files(
current_version='$pre_tag'.lstrip('v'),
new_version='$cur_tag'.lstrip('v'),
files=['pyproject.toml', '${{ inputs.version_file }}'],
)"
cz bump
env:
pre_tag: ${{ steps.pre_tag.outputs.tag }}
cur_tag: ${{ steps.cur_tag.outputs.tag }}
- name: Get new tag
id: new_tag
run: |
NEW_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "NEW_TAG is: $NEW_TAG"
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
echo "version=${NEW_TAG:1}" >> $GITHUB_OUTPUT
- name: Generate CHANGELOG (stable release)
if: inputs.pr-base-ref == inputs.release_branch
run: |
./git-chglog --output CHANGELOG.md
git add CHANGELOG.md
- name: Generate CHANGELOG-dev (pre-release)
if: inputs.pr-base-ref == inputs.pre_release_branch
run: |
./git-chglog --output CHANGELOG-dev.md
git add CHANGELOG-dev.md
- name: Push new CHANGELOG
run: |
git tag -d $new_tag
git commit --amend --no-edit
git tag $new_tag
git push && git push origin $new_tag
env:
new_tag: ${{ steps.new_tag.outputs.tag }}
- name: Rebase into develop branch if exists (stable release)
if: inputs.pr-base-ref == inputs.release_branch
run: |
exists_in_remote=$(git ls-remote --heads origin refs/heads/${{ inputs.pre_release_branch }})
echo "exists_in_remote: $exists_in_remote"
if [[ -n $exists_in_remote ]]; then
export SKIP=end-of-file-fixer
git checkout ${{ inputs.pre_release_branch }}
git pull
git rebase ${{ inputs.release_branch }}
git push -u origin ${{ inputs.pre_release_branch }}
else
echo "No ${{ inputs.pre_release_branch }} branch to merge into."
fi
- name: Generate incremental CHANGELOG for GitHub release body (stable release)
if: inputs.pr-base-ref == inputs.release_branch
run: |
./git-chglog --template .chglog/RELEASE.tpl.md --output CHANGELOG_increment.md $cur_tag..
cat CHANGELOG_increment.md
env:
cur_tag: ${{ steps.cur_tag.outputs.tag }}
new_tag: ${{ steps.new_tag.outputs.tag }}
- name: Generate incremental CHANGELOG for GitHub release body (pre-release)
if: inputs.pr-base-ref == inputs.pre_release_branch
run: |
./git-chglog --template .chglog/RELEASE.tpl.md --output CHANGELOG_increment.md $new_tag
cat CHANGELOG_increment.md
env:
new_tag: ${{ steps.new_tag.outputs.tag }}
- name: Store the incremental CHANGELOG
uses: actions/upload-artifact@v6
id: upload-changelog
with:
name: CHANGELOG_increment
path: CHANGELOG_increment.md
cache-app-data:
# skip if '[skip release]' is in the PR title; or if merging any branch other than pre_release_branch into release_branch
if: "!contains(inputs.pr-title, '[skip release]') && (inputs.pr-base-ref == inputs.pre_release_branch || (inputs.pr-base-ref == inputs.release_branch && inputs.pr-head-ref == inputs.pre_release_branch))"
permissions:
# No write permission
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Set up python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Set up poetry
uses: hpcflow/github-support/setup-poetry@0.4
with:
version: ${{ inputs.poetry-version }}
- name: Cache dependencies
uses: hpcflow/github-support/init-cache@0.4
with:
name: test
version: ${{ inputs.python-version }}
- name: Install dependencies
run: |
poetry install --without dev,pyinstaller
- name: Cache all app data and programs
run: |
poetry run ${{ inputs.executable_name }} manage cache-all
- name: Upload all cached app data/programs
id: upload-cached-app-data
uses: actions/upload-artifact@v6
with:
name: ${{ inputs.executable_name }}-app-data-cache
path: ~/.cache/${{ inputs.executable_name }}
build-executables:
needs: [bump-version, cache-app-data]
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
include:
- os: windows-latest
executable_ext: .exe
executable_os: win
- os: macos-latest
executable_ext: ""
executable_os: macOS
runs-on: ${{ matrix.os }}
env:
BUILT_EXE_BASE_NAME: ${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}
BUILT_EXE_PATH_DIR: ${{ inputs.pyinstaller_dir }}/dist/onedir/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-${{ matrix.executable_os }}-dir/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-${{ matrix.executable_os }}-dir${{ matrix.executable_ext }}
BUILT_EXE_PATH_DIR_ZIPPED: ${{ inputs.pyinstaller_dir }}/dist/onedir/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-${{ matrix.executable_os }}-dir.zip
BUILT_EXE_PATH_FILE: ${{ inputs.pyinstaller_dir }}/dist/onefile/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-${{ matrix.executable_os }}${{ matrix.executable_ext }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.pr-base-ref }} # otherwise we get the ref when the workflow started (missing above commit)
- name: Set up python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Cache dependencies
uses: hpcflow/github-support/init-cache@0.4
with:
name: build
version: ${{ inputs.python-version }}
- name: Download prepared cached app data
uses: actions/download-artifact@v7
with:
name: ${{ inputs.executable_name }}-app-data-cache
path: ${{ inputs.executable_name }}-app-data-cache
- name: Set up poetry
uses: hpcflow/github-support/setup-poetry@0.4
with:
version: ${{ inputs.poetry-version }}
- name: Install dependencies
run: poetry install --without dev
- name: Install cached app data
env:
PYTHONUTF8: 1
run: |
poetry run ${{ inputs.executable_name }} data install-cache ${{ inputs.executable_name }}-app-data-cache/data
poetry run ${{ inputs.executable_name }} data --list
poetry run ${{ inputs.executable_name }} program install-cache ${{ inputs.executable_name }}-app-data-cache/programs
poetry run ${{ inputs.executable_name }} program --list
- name: Build with pyinstaller (non-Windows, file)
if: runner.os != 'Windows'
working-directory: ${{ inputs.pyinstaller_dir }}
run: ./make.sh $TARGET INFO 'onefile'
env:
TARGET: ${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}
- name: Build with pyinstaller (non-Windows, folder)
if: runner.os != 'Windows'
working-directory: ${{ inputs.pyinstaller_dir }}
run: ./make.sh $TARGET INFO 'onedir'
env:
TARGET: ${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}-dir
- name: Build with pyinstaller (Windows, file)
if: runner.os == 'Windows'
working-directory: ${{ inputs.pyinstaller_dir }}
run: ./make.ps1 -ExeName $Env:TARGET -LogLevel INFO -BuildType 'onefile'
env:
TARGET: ${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}
- name: Build with pyinstaller (Windows, folder)
if: runner.os == 'Windows'
working-directory: ${{ inputs.pyinstaller_dir }}
run: ./make.ps1 -ExeName $Env:TARGET -LogLevel INFO -BuildType 'onedir'
env:
TARGET: ${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}-dir
- name: Version check (file)
uses: hpcflow/github-support/compare@0.4
with:
expected: "${{ inputs.app_name }}, version ${{ needs.bump-version.outputs.version }}"
command: ${{ env.BUILT_EXE_PATH_FILE }} --version
- name: Version check (folder)
uses: hpcflow/github-support/compare@0.4
with:
expected: "${{ inputs.app_name }}, version ${{ needs.bump-version.outputs.version }}"
command: ${{ env.BUILT_EXE_PATH_DIR }} --version
- name: Run test suite on the frozen app (folder)
env:
GH_TOKEN: ${{ secrets.general-token }}
run: |
${{ env.BUILT_EXE_PATH_DIR }} test
- name: Compress folder (windows, folder)
if: runner.os == 'Windows'
working-directory: ${{ inputs.pyinstaller_dir }}
run: ./compress.ps1 -ExeName '${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}-dir' -BuildType 'onedir'
- name: Compress folder (non-windows, folder)
if: runner.os != 'Windows'
working-directory: ${{ inputs.pyinstaller_dir }}
run: ./compress.sh $TARGET 'onedir'
env:
TARGET: ${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}-dir
- name: Upload executable artifact (file)
uses: actions/upload-artifact@v6
with:
name: ${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}${{ matrix.executable_ext }}
path: ${{ env.BUILT_EXE_PATH_FILE }}
- name: Upload executable artifact (compressed folder)
uses: actions/upload-artifact@v6
with:
name: ${{ env.BUILT_EXE_BASE_NAME }}-${{ matrix.executable_os }}-dir.zip
path: ${{ env.BUILT_EXE_PATH_DIR_ZIPPED }}
build-executables-linux:
runs-on: ubuntu-latest
needs: [bump-version, cache-app-data]
env:
BUILT_EXE_PATH_DIR: ${{ inputs.pyinstaller_dir }}/dist/onedir/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-linux-dir/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-linux-dir
BUILT_EXE_PATH_DIR_ZIPPED: ${{ inputs.pyinstaller_dir }}/dist/onedir/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-linux-dir.zip
BUILT_EXE_PATH_FILE: ${{ inputs.pyinstaller_dir }}/dist/onefile/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-linux
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.pr-base-ref }} # otherwise we get the ref when the workflow started (missing above commit)
- name: Cache dependencies
uses: hpcflow/github-support/init-cache@0.4
with:
name: build
version: ${{ inputs.python-version }}
- name: Download prepared cached app data
uses: actions/download-artifact@v7
with:
name: ${{ inputs.executable_name }}-app-data-cache
path: ${{ inputs.executable_name }}-app-data-cache
- name: Build executables within Docker
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/hpcflow/rockylinux8-python:latest
options: -v ${{ github.workspace }}:/home --env GH_TOKEN=${{ secrets.general-token }}
run: |
# set up poetry
cd /home
poetry config virtualenvs.in-project true
poetry install --without dev
vers_expected="${{ inputs.app_name }}, version ${{ needs.bump-version.outputs.version }}"
# build with pyinstaller for Rocky Linux (file)
cd ${{ inputs.pyinstaller_dir }}
./make.sh ${{ env.BUILT_EXE_BASE_NAME }}-linux INFO onefile
cd ..
# version check (file)
vers=$(${{ env.BUILT_EXE_PATH_FILE }} --version)
echo $vers
echo $vers_expected
[ "$vers" = "$vers_expected" ]
# install cache data
${{ env.BUILT_EXE_PATH_FILE }} data install-cache ${{ inputs.executable_name }}-app-data-cache/data
${{ env.BUILT_EXE_PATH_FILE }} data --list
${{ env.BUILT_EXE_PATH_FILE }} program install-cache ${{ inputs.executable_name }}-app-data-cache/programs
${{ env.BUILT_EXE_PATH_FILE }} program --list
# run test suite on the frozen app (file)
${{ env.BUILT_EXE_PATH_FILE }} test
# build with pyinstaller for Rocky Linux (folder)
cd ${{ inputs.pyinstaller_dir }}
./make.sh ${{ env.BUILT_EXE_BASE_NAME }}-linux-dir INFO onedir
cd ..
# version check (folder)
vers=$(${{ env.BUILT_EXE_PATH_DIR }} --version)
echo $vers
echo $vers_expected
[ "$vers" = "$vers_expected" ]
# run test suite on the frozen app (folder)
${{ env.BUILT_EXE_PATH_DIR }} test
# Compress folder (folder)
cd ${{ inputs.pyinstaller_dir }}
./compress.sh ${{ env.BUILT_EXE_BASE_NAME }}-linux-dir 'onedir'
cd ..
- name: Upload executable artifact (file)
uses: actions/upload-artifact@v6
with:
name: ${{ env.BUILT_EXE_BASE_NAME }}-linux
path: ${{ env.BUILT_EXE_PATH_FILE }}
- name: Upload executable artifact (compressed folder)
uses: actions/upload-artifact@v6
with:
name: ${{ env.BUILT_EXE_BASE_NAME }}-linux-dir.zip
path: ${{ inputs.pyinstaller_dir }}/dist/onedir/${{ env.BUILT_EXE_BASE_NAME }}-linux-dir.zip
make-workflow-benchmark:
needs: bump-version
strategy:
fail-fast: false
matrix:
python-version:
- ${{ inputs.python-version }}
os:
- ubuntu-latest
- macos-latest
- windows-latest
num_elements:
- 1
- 100
- 10000
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
- name: Set up python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Set up poetry
uses: hpcflow/github-support/setup-poetry@0.4
with:
version: ${{ inputs.poetry-version }}
- name: Cache dependencies
uses: hpcflow/github-support/init-cache@0.4
with:
name: benchmark
version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
poetry install --without dev,pyinstaller
- name: Run app make workflow command
run: |
poetry run ${{ inputs.executable_name }} --timeit-file benchmark_make_workflow_${{ matrix.num_elements }}_elements-${{ runner.os }}-py-${{ matrix.python-version }}.txt make ${{ inputs.benchmark_make_workflow }} --var N ${{ matrix.num_elements }}
- name: Store benchmark data
uses: actions/upload-artifact@v6
with:
name: benchmark_make_workflow_${{ matrix.num_elements }}_elements-${{ runner.os }}-py-${{ matrix.python-version }}.txt
path: benchmark_make_workflow_${{ matrix.num_elements }}_elements-${{ runner.os }}-py-${{ matrix.python-version }}.txt
retention-days: 1
make-workflow-benchmark-upload:
needs: make-workflow-benchmark
runs-on: ubuntu-latest
outputs:
benchmark-url: ${{ steps.upload.outputs.artifact-url }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
- name: Make benchmark directory
run: |
mkdir benchmarks
- name: Load benchmark data
uses: actions/download-artifact@v7
with:
merge-multiple: true
path: benchmarks
- name: zip benchmark results
run: |
zip -r ./benchmarks.zip benchmarks
- name: Store compound benchmark data
uses: actions/upload-artifact@v6
with:
name: benchmarks.zip
path: benchmarks.zip
id: upload
release-github-PyPI:
needs:
- bump-version
- build-executables
- build-executables-linux
- make-workflow-benchmark-upload
runs-on: ubuntu-latest
outputs:
binary_download_links: ${{ steps.get_binary_download_links.outputs.binary_download_links }}
release-state: ${{ steps.release.outcome }}
publish-state: ${{ steps.publish.outcome }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.pr-base-ref }} # otherwise we get the ref when the workflow started (missing above commit)
- name: Set up python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Cache dependencies
uses: hpcflow/github-support/init-cache@0.4
with:
name: release
version: ${{ inputs.python-version }}
- name: Set up poetry
uses: hpcflow/github-support/setup-poetry@0.4
with:
version: ${{ inputs.poetry-version }}
- name: Install dependencies
run: poetry install --without dev,pyinstaller
- name: Build (for PyPI)
run: poetry build
- name: Make release artifact directory
run: mkdir release-artifacts
- name: Download release artifacts
uses: actions/download-artifact@v7
with:
path: release-artifacts
- name: Display structure of downloaded files
run: ls -R
- name: Release
id: release
uses: softprops/action-gh-release@v2
with:
body_path: release-artifacts/CHANGELOG_increment/CHANGELOG_increment.md
tag_name: ${{ needs.bump-version.outputs.new_tag }}
files: |
**/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-win.exe
**/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-macOS
**/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-linux
**/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-win-dir.zip
**/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-macOS-dir.zip
**/${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-linux-dir.zip
**/benchmarks.zip
prerelease: ${{ inputs.pr-base-ref == inputs.pre_release_branch }}
- name: Release info
id: get_binary_download_links
run: |
binaryYaml=$(python3 -c "
out_yaml = ''
exe_base = '${{ inputs.executable_name }}-${{ needs.bump-version.outputs.new_tag }}-'
url_base = 'https://github.com/${{ inputs.repository }}/releases/download/${{ needs.bump-version.outputs.new_tag }}/'
for i in ['win.exe', 'macOS', 'linux', 'win-dir.zip', 'macOS-dir.zip', 'linux-dir.zip']:
exe_name = f'{exe_base}{i}'
out_yaml += f'{exe_name}: {url_base}{exe_name}\n'
print(out_yaml)
")
# Save multiline output
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "binary_download_links<<$EOF" >> $GITHUB_OUTPUT
echo "$binaryYaml" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Publish (to ${{ inputs.pypi-url }})
id: publish
run: |
poetry config repositories.pypi ${{ inputs.pypi-url }}
poetry config pypi-token.pypi ${{ secrets.pypi-token }}
poetry publish --repository pypi
build-documentation:
needs: release-github-PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0 # get all history and tags
ref: ${{ inputs.pr-base-ref }} # otherwise we get the ref when the workflow started (missing above commit)
token: ${{ secrets.commit-token }}
- name: Configure git
uses: hpcflow/github-support/configure-git@0.4
- name: Set up python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Write binary links YAML file and push
run: |
echo -e "${{ needs.release-github-PyPI.outputs.binary_download_links }}" > docs/source/released_binaries.yml
git add .
git commit -m "build: update binary download links file [skip ci]"
git push
- name: Rebase into develop branch if exists (stable release)
if: inputs.pr-base-ref == inputs.release_branch
run: |
exists_in_remote=$(git ls-remote --heads origin refs/heads/${{ inputs.pre_release_branch }})
echo "exists_in_remote: $exists_in_remote"
if [[ -n $exists_in_remote ]]; then
export SKIP=end-of-file-fixer
git checkout ${{ inputs.pre_release_branch }}
git pull
git rebase ${{ inputs.release_branch }}
git push -u origin ${{ inputs.pre_release_branch }}
else
echo "No ${{ inputs.pre_release_branch }} branch to merge into."
fi
- name: Cache dependencies
uses: hpcflow/github-support/init-cache@0.4
with:
name: release-doc
version: ${{ inputs.python-version }}
- name: Set up poetry
uses: hpcflow/github-support/setup-poetry@0.4
with:
version: ${{ inputs.poetry-version }}
- name: Install dependencies
run: poetry install --without test,pyinstaller
- name: Build documentation with Sphinx
run: |
poetry run make clean
poetry run make html
working-directory: docs
- name: Upload documentation artifact
uses: actions/upload-artifact@v6
with:
name: docs_html
path: docs/build/html
update-website:
needs: [bump-version, release-github-PyPI, build-documentation]
runs-on: ubuntu-latest
outputs:
publish-state: ${{ steps.publish.outcome }}
steps:
- name: Set up python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Checkout
uses: actions/checkout@v6
with:
repository: ${{ inputs.website_source_org }}/${{ inputs.website_source_repo }}
token: ${{ secrets.website-token }}
- name: Configure git
uses: hpcflow/github-support/configure-git@0.4
- name: Download documentation artifact
uses: actions/download-artifact@v7
with:
name: docs_html
path: docs/${{ needs.bump-version.outputs.new_tag }}
- name: Update stable docs symlink
if: inputs.pr-base-ref == inputs.release_branch
run: |
ln -sfn ${{ needs.bump-version.outputs.new_tag }} docs/stable
- name: Update pre-release docs symlink
if: inputs.pr-base-ref == inputs.pre_release_branch
run: |
ln -sfn ${{ needs.bump-version.outputs.new_tag }} docs/dev
- run: tree
- name: Update doc version switcher
run: |
curl $URL --output docs/make_vers_switcher.py
python docs/make_vers_switcher.py ${{ inputs.docs_url_prefix }}
env:
URL: https://raw.githubusercontent.com/${{ inputs.repository }}/${{ github.ref_name }}/docs/make_vers_switcher.py
- name: Push changes
id: publish
run: |
git add .
git commit -m "update content"
git push