Repository navigation
1046 lines (976 loc) · 56.6 KB
/
Copy pathcreate-release.yml
File metadata and controls
1046 lines (976 loc) · 56.6 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
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_run:
workflows: [ "Vendor Update" ]
types:
- completed
# #1968: no scopes for a job without `permissions:` of its own. Each job has one.
permissions: {}
name: Create Release
# One release run at a time per ref, never cancelling one in progress: two
# Vendor Update runs completing close together start two runs on one tip (runs
# 34894022730 and 34894646592), and both would read PCAPKIT_TAG_EXISTS before
# either had tagged.
#
# #1705: a group holds one pending run and cancels it when another joins, so a
# run that cannot release -- its Vendor Update did not conclude ``success``, so
# ``version_check`` skips -- is keyed on its own ``github.run_id``. Keyed on the
# ref, such a run, 38499295798, displaced the pending 38499150441. A tag push
# keeps its tag's group. The one pending run, and ``run_id`` being unique:
# https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency
#
# A manual Vendor Update (``workflow_dispatch``) builds only and pushes
# nothing, so the run it raises releases nothing and is keyed on its own id too.
concurrency:
group: create-release-${{ (github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'workflow_dispatch')) && github.ref || github.run_id }}
cancel-in-progress: false
# Environments: every job with an effect outside this run declares one, one per
# credential and blast radius, and only ``github-release`` carries a required
# reviewer (#887):
#
# github -> github-release the GitHub Release, and the ``v*`` tag
# ``action-gh-release``'s ``tag_name`` creates
# tag -> conda-tag a commit pushed to ``main``, and the ``conda-*`` tag
# pypi -> pypi PyPI and TestPyPI; trusted publishing matches its
# OIDC claim against this name
# conda -> anaconda anaconda.org/jarryshaw
#
# That one approval gates the release because ``tag``, ``pypi`` and ``conda``
# all need ``github``: rejecting it leaves nothing tagged and nothing published.
# ``TestGatedJobsDependOnGithub`` in tests/project/test_release_gates.py checks
# the ``needs:`` closure. Do not add a reviewer elsewhere without re-examining
# it: a reviewer on ``conda-tag`` with ``needs: [ version_check ]`` is #887's
# defect, which tags and commits to ``main`` before the Release is
# approved. One shared ``release`` would publish PyPI and Anaconda, different
# credentials and indexes, together; and PyPI cannot afford an unintended
# publish, since an accepted version number cannot be reused (``skip-existing:
# true`` makes the re-upload *succeed* having published nothing). ``github``
# spends the release App's token, minted from ``github-release``'s secret and
# revoked when the job ends; ``tag`` a long-lived PAT and a deploy key (#1634).
# docs/source/contributing/releasing.rst has the full pipeline.
#
# Repository settings no test can check (#641):
#
# * An ``environment:`` naming one that does not exist is created implicitly,
# with no protection rules, and the job proceeds unapproved -- as
# ``github-pages`` has, with ``"protection_rules": []``. So
# ``github-release`` needs creating under Settings -> Environments with a
# required reviewer.
# * Leave each one's "Deployment branches and tags" at "No restriction": a
# branch policy not listing ``v*`` fails the job with "Branch is not allowed
# to deploy to <environment>" rather than pausing it for approval.
#
# tests/project/test_release_gates.py checks the workflow half: no job here
# publishes without naming an environment.
#
# #888: each publisher reads its own evidence, never "the ``v*`` tag exists" --
# the two diverge on a half-completed release, and a run reading the tag would
# skip every job and report green. ``github`` still reads ``PCAPKIT_TAG_EXISTS``,
# since that tag is its own artefact; ``tag`` reads whether ``conda-<version>+0``
# exists, ``pypi`` PyPI's file count, and ``conda`` Anaconda's aggregate count
# (a cost saver) plus, per leg, its own distribution -- the correctness fix,
# since ``anaconda/actions/upload-package`` has no ``skip-existing``, only
# ``force:``, never set here. The ``macos-26-intel`` and ``windows-latest``
# legs upload with the anaconda-client CLI and ``--skip-existing`` instead
# (#2044, #2060).
#
# GitHub skips a job whose ``needs:`` skipped before evaluating its ``if:``,
# unless the ``if:`` calls a status-check function, and ``github`` skips on
# exactly the retry #888 is for. So ``tag``, ``pypi`` and ``conda`` open with
# ``!cancelled()`` and spell each publishing predecessor (``github``, and for
# ``conda`` ``tag``) as ``(== 'success' || == 'skipped')``, not as the callers
# of unit-tests.yml do, ``!= 'failure'``: that admits ``cancelled``, and a
# cancelled ``tag`` would send ``conda`` into checking a ``conda-<version>+0``
# tag never pushed, a failed step for a clean skip. ``version_check`` is held to
# ``== 'success'`` alone, since it produces the evidence the gates read, and so
# is ``unit-tests`` (#1052 below).
#
# ``release_status`` at the end reports why a run released nothing; a stranded
# partial release, the shape #888 was about, is its loud (``::error``) case.
#
# #1052: ``version_check`` runs before the release test gate, so the ~20-minute
# gate is spent only when something will be published -- most Vendor Update
# runs leave ``__version__`` alone. ``unit-tests`` runs on a ``v*`` ref or when
# any evidence output is not ``'true'``, which covers every case a publisher can
# run in; ``!= 'true'`` rather than ``== 'false'``, so an unset output costs a
# run, never a release. Every publisher names the gate: ``github`` through
# ``needs:`` and the implicit ``success()``, the others with
# ``needs.unit-tests.result == 'success'``. So if the predicates drift, the
# failure is a release that did not happen, reported by ``release_status``,
# never one that went out untested. tests/project/test_release_gates.py checks
# both halves.
#
# #1634: every job that checks out, tags, builds or publishes pins
# ``github.sha``, never a ref that moves while the run waits for approval. On
# ``workflow_run`` that is ``main``'s tip when the run was created, not
# ``github.event.workflow_run.head_sha``, which predates Vendor Update's bump
# (run 38008819343: ``github.sha`` ``b6b95bc8e``, Vendor Update run 38008512299
# on ``945c3c3d8``). Approved three days later, that run tagged ``main``'s tip
# ``2c0008c3c`` as ``v1.5.0b9`` and ``conda-1.5.0b9+0``. ``github``, ``tag``,
# ``pypi`` and ``conda`` also refuse to publish under a tag naming another
# commit; finishing a release means re-running the run that tagged it.
# tests/project/test_release_tags_the_run_sha_1634.py checks this and runs
# ``tag``'s scripts against a scratch repository.
#
# #1748: so a version tagged at another commit would fail every later run for
# it (``v1.5.0b12`` names ``2025da5e5`` with only part of its Anaconda files).
# Off a ``v*`` ref, ``PCAPKIT_RELEASED_ELSEWHERE`` reading ``'true'`` skips the
# gate and every publisher, and ``release_status`` reports, green, whether that
# release is complete. A ``v*`` push still meets the #1634 check. The
# ``vendor_update`` job is the issue's other half.
#
# Owner ruling, 2026-10-30: ``__version__`` carries a PEP 440 dev-release
# suffix (``X.Y.Z.devN``) while a version is still under active development, a
# work-in-progress signal with no gate of its own -- and the
# ``workflow_run`` trigger above means a scheduled Vendor Update can reach this
# workflow and carry that dev version all the way to ``github``'s one reviewer
# approval (#887, below). That approval is not nothing, but it is one person
# approving a diff for reasons that are usually unrelated to the version
# string, so a stray ``.devN`` is easy to miss there; and a re-run of a job
# that already skipped ``github`` once does not ask for a fresh approval at
# all. ``PCAPKIT_DEV_RELEASE`` closes that gap in code rather than leaving it
# to review. ``PCAPKIT_DEV_RELEASE`` (``version_check``'s ``is_devrelease``)
# is read by ``github``, ``tag``, ``pypi`` and ``conda`` alike, deliberately not
# ``PCAPKIT_PRERELEASE`` (``is_prerelease``): the latter is also ``true`` for a
# deliberately-tagged alpha/beta/rc this project has shipped for real (e.g.
# ``1.5.0b14``), and gating on it would silently block one.
# tests/project/test_release_gates.py's ``test_all_four_publishers_gate_on_dev_release``
# checks this text, and ``gate_rows``/``GITHUB_ROWS`` evaluate it. ``release_status``
# also reads it: with the gate skipping all four publishers, their evidence
# outputs stay ``false``, which would otherwise read as #888's stranded partial
# release. util/release_status.py's ``dev_release_skipped()`` reports that
# combination as a quiet, deliberate no-op instead.
jobs:
# #1748: a Vendor Update raised by a Unit Tests verdict for another commit
# updates nothing -- ``vendor-update`` skips -- yet concludes ``success``
# (Vendor Update 38650191283), since its ``verdict`` job has to run to decide;
# 38655782606, whose jobs all skipped, concluded ``skipped``. So this reads
# that run's ``vendor-update`` job with "List jobs for a workflow run", whose
# ``filter`` defaults to ``latest``:
# https://docs.github.com/en/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
# ``updated`` is ``'false'`` only for a ``skipped`` job; anything else it cannot
# read leaves it unset, and ``version_check`` runs as it otherwise would.
#
# The concurrency group reads only the event, so such a run still joins
# ``main``'s group and can displace a run pending there. It releases nothing
# in that run's place, so the displaced run's release waits for the next run
# on ``main``: the tip's own Vendor Update if the tip's Unit Tests run has not
# completed yet, else the next push's or Saturday's.
vendor_update:
name: Triggering Vendor Update
runs-on: ubuntu-latest
if: >-
${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event != 'workflow_dispatch' }}
timeout-minutes: 5
permissions:
actions: read
outputs:
updated: ${{ steps.updated.outputs.updated }}
steps:
- name: Read whether its vendor-update job ran
id: updated
env:
GH_TOKEN: ${{ github.token }}
PCAPKIT_VENDOR_RUN_ID: ${{ github.event.workflow_run.id }}
run: |
set -uo pipefail
if ! result="$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${PCAPKIT_VENDOR_RUN_ID}/jobs" \
--paginate --jq '.jobs[] | select(.name == "vendor-update") | .conclusion')"; then
echo "::warning title=Vendor Update not read (#1748)::could not list the jobs of Vendor Update run ${PCAPKIT_VENDOR_RUN_ID}, so this run treats it as one that updated."
exit 0
fi
case "$result" in
success)
echo "updated=true" >> "$GITHUB_OUTPUT"
;;
skipped)
echo "updated=false" >> "$GITHUB_OUTPUT"
echo "Vendor Update run ${PCAPKIT_VENDOR_RUN_ID} skipped vendor-update: its verdict did not cover the commit it checked out."
;;
*)
echo "::warning title=Vendor Update not read (#1748)::Vendor Update run ${PCAPKIT_VENDOR_RUN_ID} reports vendor-update as '${result//$'\n'/ }', so this run treats it as one that updated."
;;
esac
version_check:
name: Check Version
runs-on: ubuntu-latest
# Read-only -- it installs the package and reads public endpoints -- so
# running it ahead of the test gate risks nothing (#1052).
#
# #1634: a ``v*`` push by the release App's bot skips: that is the tag
# ``github`` makes with the App's token, which, unlike ``GITHUB_TOKEN``'s,
# starts a run, and the run that made it releases that commit. Otherwise it
# would rerun the gate, ask for a second approval, and race the first run's
# uploads from another concurrency group. Whether that push fires with the
# bot's ``github.actor_id`` is unmeasured; if not, this never matches.
#
# #1748: and a Vendor Update whose ``vendor-update`` job skipped, or a
# manual one, which builds only. ``!cancelled()`` because ``vendor_update`` skips on a push, and a skipped
# need skips its dependents unless the ``if:`` says otherwise:
# https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-jobs
needs: [ vendor_update ]
if: >-
${{ !cancelled() &&
(github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event != 'workflow_dispatch')) &&
!(github.event_name == 'push' && github.actor_id == vars.RELEASE_APP_BOT_ID) &&
needs.vendor_update.outputs.updated != 'false' }}
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
# #1660: `latest` for this job and the ``pypi`` and ``conda`` matrices,
# from this run's commit, and the tags the completeness checks count until
# the version is tagged.
- name: Read the Python versions
id: python-versions
run: python3 util/python_versions.py --github-output
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ steps.python-versions.outputs.latest }}
- name: Install and Setup
run: |
python -m pip install -U pip setuptools wheel packaging
# Owner ruling, 2026-10-30: during active development on a not-yet-released
# version, ``__version__`` carries a PEP 440 dev-release suffix
# (``X.Y.Z.devN``) as a work-in-progress signal. ``PCAPKIT_DEV_RELEASE`` is
# ``is_devrelease``, not ``is_prerelease`` -- the latter is also ``true``
# for a deliberately-tagged alpha/beta/rc (e.g. ``1.5.0b14``, a real
# release), and gating on it would silently block one. ``github``, ``tag``,
# ``pypi`` and ``conda`` all read this below so that a scheduled Vendor
# Update bumping a dev version never tags or publishes it on the strength
# of ``github-release``'s one reviewer alone, who can miss a stray
# ``.devN`` in an otherwise-unrelated approval; see
# docs/source/contributing/releasing.rst.
- name: Get Version
id: get_version
run: |
set -ex
python -m pip install -e .
{
echo "PCAPKIT_VERSION=$(python -c 'import pcapkit; print(pcapkit.__version__)')"
echo "PCAPKIT_PRERELEASE=$(python -c 'from packaging.version import Version; import pcapkit; print(str(Version(pcapkit.__version__).is_prerelease).lower())')"
echo "PCAPKIT_DEV_RELEASE=$(python -c 'from packaging.version import Version; import pcapkit; print(str(Version(pcapkit.__version__).is_devrelease).lower())')"
echo "PCAPKIT_CONDA_LABEL=$(python -c 'from packaging.version import Version; import pcapkit; print("dev" if Version(pcapkit.__version__).is_prerelease else "main")')"
} >> "$GITHUB_OUTPUT"
- uses: mukunku/tag-exists-action@5c39604fe8aef7e65acb6fbcf96ec580f7680313 # v1.7.0
id: check_tag
with:
tag: "v${{ steps.get_version.outputs.PCAPKIT_VERSION }}"
# #888: ``tag``'s own evidence. ``PCAPKIT_TAG_EXISTS`` answers only for
# ``github``: a half-failed release leaves the ``v*`` tag behind with the
# other targets incomplete.
- uses: mukunku/tag-exists-action@5c39604fe8aef7e65acb6fbcf96ec580f7680313 # v1.7.0
id: check_conda_tag
with:
tag: "conda-${{ steps.get_version.outputs.PCAPKIT_VERSION }}+0"
# #1660: once the ``v*`` tag exists, count what the version was released
# with: the tier file at the tag's commit, read by that commit's
# util/python_versions.py. A version added to the tier since was never
# built for it, and counting it would read a finished release as
# incomplete and fail #1634's tag check on every run until the next
# release. A tag older than the file counts the tiers the file was added
# with, which #1677 copied unchanged from the workflows of the time.
- name: Read the released Python versions
id: released
env:
PCAPKIT_TAG: v${{ steps.get_version.outputs.PCAPKIT_VERSION }}
PCAPKIT_TAG_EXISTS: ${{ steps.check_tag.outputs.exists }}
PCAPKIT_PYPI_WHEELS: ${{ steps.python-versions.outputs.pypi-wheels }}
PCAPKIT_CONDA_BUILDS: ${{ steps.python-versions.outputs.conda-builds }}
run: python3 util/release_tiers.py
# PyPI evidence: a wheel per supported-tier leg (``PCAPKIT_PYPI_WHEELS``;
# #1633 -- a KTLO wheel neither completes the release nor, failing, leaves
# it incomplete) plus the sdist the ``latest`` leg keeps. A 200 alone
# proves only that *some* file landed. It reads ``urls``: this endpoint's
# ``releases`` was empty on every request checked, and the versionless
# ``/pypi/pypcapkit/json`` is ~950KB to this one's ~15KB. Fastly caches it
# (900s max-age), but staleness can only undercount -- PyPI never removes
# a file -- which re-enters ``pypi``, harmless under ``skip-existing:
# true``; it cannot call an incomplete release complete.
- name: Check PyPI publish completeness
id: check_pypi
env:
PCAPKIT_VERSION: ${{ steps.get_version.outputs.PCAPKIT_VERSION }}
PCAPKIT_PYPI_WHEELS: ${{ steps.released.outputs.pypi-wheels }}
run: python3 util/release_published.py pypi /tmp/pypi_release.json
# Anaconda evidence, as PyPI's above, per platform and Python: the
# job-level cost saver, under which ``conda``'s per-leg checks, the
# correctness fix, still run. This endpoint read ``cf-cache-status:
# DYNAMIC`` (uncached) on every request checked, so no staleness applies.
- name: Check Anaconda publish completeness
id: check_conda
env:
PCAPKIT_VERSION: ${{ steps.get_version.outputs.PCAPKIT_VERSION }}
PCAPKIT_CONDA_BUILDS: ${{ steps.released.outputs.conda-builds }}
# #2060: once tagged, the platforms its tag's commit published.
PCAPKIT_TAG_EXISTS: ${{ steps.check_tag.outputs.exists }}
run: python3 util/release_published.py anaconda /tmp/anaconda_release.json
# #1748: resolved as #1634's check in ``github``, ``pypi`` and ``conda``
# resolves it, so the gates skip exactly the runs that check would refuse.
# ``PCAPKIT_RELEASED_ELSEWHERE`` is ``true`` only for a tag elsewhere.
- name: Check which commit the version's tag names
id: owner
env:
PCAPKIT_TAG: v${{ steps.get_version.outputs.PCAPKIT_VERSION }}
PCAPKIT_RUN_SHA: ${{ github.sha }}
run: python3 util/release_tags.py owner
outputs:
PCAPKIT_VERSION: ${{ steps.get_version.outputs.PCAPKIT_VERSION }}
PCAPKIT_PRERELEASE: ${{ steps.get_version.outputs.PCAPKIT_PRERELEASE }}
PCAPKIT_DEV_RELEASE: ${{ steps.get_version.outputs.PCAPKIT_DEV_RELEASE }}
PCAPKIT_TAG_EXISTS: ${{ steps.check_tag.outputs.exists }}
PCAPKIT_CONDA_TAG_EXISTS: ${{ steps.check_conda_tag.outputs.exists }}
PCAPKIT_PYPI_COMPLETE: ${{ steps.check_pypi.outputs.PCAPKIT_PYPI_COMPLETE }}
PCAPKIT_CONDA_COMPLETE: ${{ steps.check_conda.outputs.PCAPKIT_CONDA_COMPLETE }}
PCAPKIT_CONDA_LABEL: ${{ steps.get_version.outputs.PCAPKIT_CONDA_LABEL }}
PCAPKIT_RELEASED_AT: ${{ steps.owner.outputs.PCAPKIT_RELEASED_AT }}
PCAPKIT_RELEASED_ELSEWHERE: ${{ steps.owner.outputs.PCAPKIT_RELEASED_ELSEWHERE }}
# #1660: from .github/python-versions.toml, for ``pypi`` and ``conda``.
PYTHON_LATEST: ${{ steps.python-versions.outputs.latest }}
PYTHON_PYPI: ${{ steps.python-versions.outputs.pypi }}
PYTHON_CONDA: ${{ steps.python-versions.outputs.conda }}
# No ``environment:``: no outward effect, and a job calling a reusable
# workflow may not declare one. Runs exactly when a publisher could (#1052,
# #1748, and, since the dev-release gate below, owner ruling 2026-10-30);
# see the note above ``jobs:``. ``PCAPKIT_DEV_RELEASE`` carries none of the
# other clauses' ``startsWith(github.ref_name, 'v')`` exemption, matching
# ``github``, ``tag``, ``pypi`` and ``conda`` below: a dev version can never
# be published regardless of how this run started, so spending the ~20
# minutes here on one is the same waste #1052 added this job to avoid.
unit-tests:
name: Release test gate
needs: [ version_check ]
if: >-
${{ needs.version_check.result == 'success' &&
needs.version_check.outputs.PCAPKIT_DEV_RELEASE != 'true' &&
(startsWith(github.ref_name, 'v') ||
needs.version_check.outputs.PCAPKIT_RELEASED_ELSEWHERE != 'true') &&
(startsWith(github.ref_name, 'v') ||
needs.version_check.outputs.PCAPKIT_TAG_EXISTS != 'true' ||
needs.version_check.outputs.PCAPKIT_CONDA_TAG_EXISTS != 'true' ||
needs.version_check.outputs.PCAPKIT_PYPI_COMPLETE != 'true' ||
needs.version_check.outputs.PCAPKIT_CONDA_COMPLETE != 'true') }}
permissions:
contents: read
uses: ./.github/workflows/unit-tests.yml
with:
gate-only: true
github:
name: GitHub Release
runs-on: ubuntu-latest
# The release's only approval (#887). Gated on ``PCAPKIT_TAG_EXISTS``
# because the ``v*`` tag is its own artefact (#888). Its ``if:`` calls no
# status-check function, so the implicit ``success()`` requires the gate
# (#1052). The release App's private key is a ``github-release`` secret, so
# no job in this workflow reads it before this approval; the cron ``pr``
# jobs read their own copy from ``release-app``. #1748:
# ``PCAPKIT_TAG_EXISTS`` already skips a tag at another commit off a ``v*``
# ref, unless it was pushed between ``check_tag`` and ``owner``; the other
# publishers' clause covers that too.
environment: github-release
permissions:
contents: write
needs: [ unit-tests, version_check ]
if: >-
${{ (startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_RELEASED_ELSEWHERE != 'true') &&
needs.version_check.outputs.PCAPKIT_DEV_RELEASE != 'true' &&
(startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_TAG_EXISTS == 'false') }}
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
# CHANGELOG.md (util/changelog_md.py) holds the newest changelog entry: the
# version being prepared, which differs from the one released on every
# automated bump, since util/bump_version.py adds no entry and a ``.postN``
# vendor refresh is an "Also released" line in its base version's entry.
# So it is the body only when its heading's version token is this version
# ("-- unreleased" still matches, with a warning); otherwise the generated
# notes alone, the honest summary of a vendor refresh. Both are logged.
- name: Select release body
id: release_body
shell: bash
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
run: |
set -euo pipefail
if [ ! -f CHANGELOG.md ]; then
echo "::warning title=Release body generated::CHANGELOG.md is absent, so this release carries the automatically generated notes alone. The file is generated by util/changelog_md.py and the 'Changelog drift' job gates it on the release path, so reaching this branch means that gate did not run."
exit 0
fi
# The generated file opens with ``## <version> -- <date-or-unreleased>``.
heading="$(sed -n '1s/^## \([^[:space:]]*\).*/\1/p' CHANGELOG.md)"
if [ "$heading" != "$PCAPKIT_VERSION" ]; then
echo "::notice title=Release body generated::CHANGELOG.md holds the entry for '${heading:-<no parseable heading>}', not ${PCAPKIT_VERSION}, so this release carries the automatically generated notes alone. Expected for a pre-release and for a .postN vendor refresh, neither of which has a changelog entry of its own."
exit 0
fi
echo 'path=CHANGELOG.md' >> "$GITHUB_OUTPUT"
echo "::notice title=Release body from CHANGELOG.md::The changelog entry for ${PCAPKIT_VERSION} leads the release body; the generated pull-request list follows it."
if sed -n '1p' CHANGELOG.md | grep -qi 'unreleased'; then
echo "::warning title=Changelog entry is undated::The entry for ${PCAPKIT_VERSION} still reads 'unreleased', so the release body says so too. Date the heading in docs/source/changelog/${PCAPKIT_VERSION}.rst, regenerate CHANGELOG.md and the body can be corrected in place."
fi
# #1634: for a target that "adds or modifies any file under
# .github/workflows/ relative to the repository's default branch",
# https://docs.github.com/en/rest/releases/releases#create-a-release
# requires the "Workflows" permission (write), and "The GITHUB_TOKEN
# available to GitHub Actions cannot be authorized for this". With no
# ``owner`` or ``repositories`` the token is "scoped to only the current
# repository", and the action's ``post`` step revokes it (v3.3.0's
# README). Skipped while ``vars.RELEASE_APP_CLIENT_ID`` is unset (``''``).
- name: Mint the release App's token
id: app_token
if: ${{ vars.RELEASE_APP_CLIENT_ID != '' }}
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
permission-workflows: write
- name: Create Release
id: create_release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
# An empty ``body_path`` is skipped by the action's truthy guard, and
# it joins ``<body>\n\n<generated>``, so the entry leads and the
# pull-request list follows.
body_path: ${{ steps.release_body.outputs.path }}
generate_release_notes: true
name: PyPCAPKit v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
prerelease: ${{ needs.version_check.outputs.PCAPKIT_PRERELEASE }}
tag_name: "v${{ needs.version_check.outputs.PCAPKIT_VERSION }}"
# #1634: on ``workflow_run`` this creates the tag, and an unset target
# would be whatever ``main`` had become by approval. On a ``v*`` push
# the tag exists and the check below proves it names ``github.sha``, so
# this is ``''`` (unset): the REST docs apply the workflow-file rule to
# a given target, so one here would expose a hand-pushed tag to it
# under ``GITHUB_TOKEN``. ``pypi`` and ``conda`` upload with ``gh
# release upload``, which never calls Update a release; cron-conda.yml's
# upload does, naming the default branch: see releasing.rst.
target_commitish: ${{ github.event_name == 'workflow_run' && github.sha || '' }}
# "A non-empty explicit token overrides GITHUB_TOKEN" (the action's
# ``action.yml``), so no ``env:`` names one.
token: ${{ steps.app_token.outputs.token || secrets.GITHUB_TOKEN }}
# #1634: the same check ``pypi`` and ``conda`` make before they publish
# under this tag. ``tag`` has no such step: its "Create Tag" makes the
# equivalent comparison inline, ``git rev-parse`` on the tags its own
# checkout fetched, without ``release_tags.resolve``'s fetch of the tag.
# Here the check catches the tag having existed already at another commit, which
# ``action-gh-release`` silently reuses.
- name: Check the release tags name this run's commit
env:
PCAPKIT_TAGS: v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_RUN_SHA: ${{ github.sha }}
run: python3 util/release_tags.py check
# #1634: a refusal is most likely the workflow-file rule quoted at "Mint
# the release App's token", which GitHub's 2023-11-02 changelog words more
# narrowly; which reading is enforced is unmeasured. For a final release
# the action creates a draft and publishes it in this same step; a re-run
# would reuse a leftover draft, target and all, so it is deleted first.
- name: Explain a refused release tag
if: ${{ failure() && steps.create_release.outcome == 'failure' }}
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_RUN_SHA: ${{ github.sha }}
PCAPKIT_APP_TOKEN_OUTCOME: ${{ steps.app_token.outcome }}
run: |
if [ "$PCAPKIT_APP_TOKEN_OUTCOME" = success ]; then
fix="Create Release spent the release App's token, so check that the App still has Contents and Workflows read and write and is installed on this repository."
else
fix="Create Release spent GITHUB_TOKEN, which cannot be authorized for this, because vars.RELEASE_APP_CLIENT_ID is unset. Set up the release App once, as docs/source/contributing/releasing.rst describes: Contents and Workflows read and write, installed on this repository only; repository variables RELEASE_APP_CLIENT_ID and RELEASE_APP_BOT_ID; github-release environment secret RELEASE_APP_PRIVATE_KEY."
fi
echo "::error title=Could not create v${PCAPKIT_VERSION} at ${PCAPKIT_RUN_SHA} (#1634)::If Create Release failed with 404 Not Found or 403 'Resource not accessible by integration', the likely cause is GitHub's workflow-file rule: its REST docs for Create a release require a token authorized to modify workflows for a commit that adds or modifies a file under .github/workflows/ relative to the default branch, which this commit may if main has changed one since. ${fix} Then delete any draft release v${PCAPKIT_VERSION} this left behind, since a re-run would reuse it and its target, and re-run this job. Any other failure is not this."
tag:
# "(release)": cron-conda.yml has a ``Conda Tag`` too, and both run on a
# push to main, so the two check rows could not be told apart.
name: Conda Tag (release)
runs-on: ubuntu-latest
# Writes through the deploy key and PAT below, not the run's token, so
# ``permissions: {}`` does not constrain it. Needs ``github`` so the one
# approval gates it (#887), and reads its own evidence under
# ``!cancelled()`` (#888); see the note above ``jobs:``. #1634: "Create
# Tag" tags ``github.sha`` before anything looks at ``main``, and "Reset
# Build Number" is a separate commit that never moves the tag.
environment: conda-tag
permissions: {}
needs: [ github, unit-tests, version_check ]
if: >-
${{ !cancelled() && needs.version_check.result == 'success' &&
needs.unit-tests.result == 'success' &&
needs.version_check.outputs.PCAPKIT_DEV_RELEASE != 'true' &&
(needs.github.result == 'success' || needs.github.result == 'skipped') &&
(startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_RELEASED_ELSEWHERE != 'true') &&
(startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_CONDA_TAG_EXISTS == 'false') }}
steps:
- name: Load maintenance deploy key
uses: webfactory/ssh-agent@e83874834305fe9a4a2997156cb26c5de65a8555 # v0.10.0
with:
ssh-private-key: ${{ secrets.PYPCAPKIT_ACTIONS_DEPLOY_KEY }}
# Detached at this run's commit (#1634): pulling ``main`` before tagging
# moved ``b6b95bc8e`` to ``2c0008c3c`` in job 115087308551.
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ secrets.PYPCAPKIT }}
ref: ${{ github.sha }}
fetch-depth: 0
# Everything after this step writes through the deploy key loaded above.
# Kept to these lines alone: the project test runs the steps below
# against a scratch repository, standing in for this one.
- name: Configure git for the deploy key
run: |
git remote set-url origin git@github.com:JarryShaw/PyPCAPKit.git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# ``conda-<version>+0`` goes on this run's commit, and only if the ``v*``
# tag is there too: one elsewhere means the release is that commit's. An
# existing ``conda-<version>+0`` here is a re-run, left alone; one
# elsewhere is never moved.
- name: Create Tag
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_RUN_SHA: ${{ github.sha }}
run: |
set -euo pipefail
run_commit="$(git rev-parse --verify "${PCAPKIT_RUN_SHA}^{commit}")"
release_tag="v${PCAPKIT_VERSION}"
released="$(git rev-parse -q --verify "refs/tags/${release_tag}^{commit}" || true)"
if [ "$released" != "$run_commit" ]; then
echo "::error title=${release_tag} is not this run's commit (#1634)::${release_tag} resolves to '${released:-no commit}', not ${run_commit}, the commit this run was created for. That release is not this commit's, so this commit gets no conda tag either."
exit 1
fi
conda_tag="conda-${PCAPKIT_VERSION}+0"
tagged="$(git rev-parse -q --verify "refs/tags/${conda_tag}^{commit}" || true)"
if [ -z "$tagged" ]; then
git tag "$conda_tag" -m"Conda Build" "$run_commit"
git push origin "refs/tags/${conda_tag}"
echo "${conda_tag} -> ${run_commit}"
elif [ "$tagged" = "$run_commit" ]; then
echo "::notice title=${conda_tag} already tagged::${conda_tag} already names ${run_commit}; nothing to tag."
else
echo "::error title=${conda_tag} is not this run's commit (#1634)::${conda_tag} already names ${tagged}, not ${run_commit}. A pushed tag is never moved here."
exit 1
fi
# A commit of its own on ``main``, only ever fast-forwarded by a plain push
# of one commit onto the tip just fetched, setting ``conda/build`` to 0 so
# the next Conda Update bump of this version is ``+1``. The script's
# docstring says when it leaves ``main`` alone instead (#1967).
- name: Reset Build Number
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_RUN_SHA: ${{ github.sha }}
run: python3 util/release_reset_build.py
pypi:
name: PyPI distribution for Python ${{ matrix.python-version }}${{ matrix.ktlo && ' (KTLO)' || '' }}
runs-on: ubuntu-latest
# The environment's name matters: PyPI's trusted-publishing claim is matched
# on it (#641, #887; see the note above ``jobs:``). #888: its evidence is a
# cost saver, not the correctness fix, as ``skip-existing: true`` already
# makes it idempotent.
environment: pypi
permissions:
contents: write
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
needs: [ github, unit-tests, version_check ]
if: >-
${{ !cancelled() && needs.version_check.result == 'success' &&
needs.unit-tests.result == 'success' &&
needs.version_check.outputs.PCAPKIT_DEV_RELEASE != 'true' &&
(needs.github.result == 'success' || needs.github.result == 'skipped') &&
(startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_RELEASED_ELSEWHERE != 'true') &&
(startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_PYPI_COMPLETE == 'false') }}
# #1633: each KTLO leg's own outcome, under a name only that leg sets --
# matrix job outputs are combined across legs -- so ``release_status`` can
# report it although it never reaches ``needs.pypi.result``.
outputs:
ktlo_310: ${{ steps.ktlo.outputs.ktlo_310 }}
ktlo_pypy310: ${{ steps.ktlo.outputs.ktlo_pypy310 }}
strategy:
## one leg failing must not cancel its siblings: each leg still has its own
## wheel to attach to the GitHub Release, and a cancelled leg never does
fail-fast: false
# #1660: from .github/python-versions.toml through ``version_check``.
# #1633: the supported tier is the ``python-version`` axis, whose wheels
# ``version_check`` counts; ``include`` adds the KTLO tier (end-of-life,
# published, never blocking) without the versions needing an older runner.
# Steps that can fail carry step-level ``continue-on-error``, so
# ``needs.pypi.result`` cannot see a KTLO failure, as in unit-tests.yml's
# ``test`` job. #1672: each step after setup-python waits on the
# ``outcome`` of the one it needs, so a KTLO leg stops at its first
# failure, and "KTLO summary" warns per failed step. A KTLO leg also needs
# its own ``ktlo_*`` output above (test_python_matrix_tiers_1633.py).
matrix: ${{ fromJSON(needs.version_check.outputs.PYTHON_PYPI) }}
steps:
# #1634: this run's commit, not ``ref: v<version>``, which is whatever
# ``main`` has become by approval; the next step checks the tag names it.
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
- name: Check the release tags name this run's commit
env:
PCAPKIT_TAGS: v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_RUN_SHA: ${{ github.sha }}
run: python3 util/release_tags.py check
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
id: setup
continue-on-error: ${{ matrix.ktlo == true }}
with:
python-version: ${{ matrix.python-version }}
- name: Install and Setup
id: install
if: ${{ steps.setup.outcome == 'success' }}
continue-on-error: ${{ matrix.ktlo == true }}
run: |
set -x
python -m pip install -U pip setuptools wheel
python -m pip install -U build
- name: Build Package
id: build
if: ${{ steps.install.outcome == 'success' }}
continue-on-error: ${{ matrix.ktlo == true }}
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
run: |
python -m build
python util/wheel_rename.py dist/*.whl
- name: No Source Distribution for Python ${{ matrix.python-version }}
id: no_sdist
if: ${{ matrix.python-version != needs.version_check.outputs.PYTHON_LATEST && steps.build.outcome == 'success' }}
continue-on-error: ${{ matrix.ktlo == true }}
run: |
rm dist/*.tar.gz
- name: Publish to PyPI
id: publish
if: ${{ steps.build.outcome == 'success' && steps.no_sdist.outcome != 'failure' }}
continue-on-error: ${{ matrix.ktlo == true }}
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
skip-existing: true
attestations: false
## TestPyPI is a secondary target and its availability must not gate the
## real release. A transient ``test.pypi.org`` read timeout failed the
## 1.5.0b2 Python 3.12 leg *after* PyPI had already accepted the upload,
## which skipped the GitHub Release step below and lost that wheel.
- name: Publish package to TestPyPI
if: ${{ steps.publish.outcome == 'success' }}
continue-on-error: true
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
attestations: false
# #1634: ``gh release upload``, not ``action-gh-release``, which calls
# Update a release before every upload (``release`` in its
# ``src/github.ts``), where GitHub re-checks the release's target against
# the workflow-file rule: a workflow change reaching ``main`` after
# ``github`` ran would fail this after PyPI had published. #1640: a file already ``uploaded`` is left
# alone, as a rebuild is not byte-identical; after a 502 an asset "may
# leave an empty asset with a state of starter", which ``--clobber``
# replaces. A missing release fails ("release not found") where the action
# creates one on the default branch. ``conda`` runs the same script.
- name: Upload package to GitHub Release
id: upload
if: ${{ steps.publish.outcome == 'success' }}
continue-on-error: ${{ matrix.ktlo == true }}
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PCAPKIT_RELEASE_TAG: v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_ASSETS: dist/*
run: python3 util/release_upload.py
# #1633: this KTLO leg's outcome despite ``continue-on-error``, for
# ``release_status``. ``steps.*.outcome`` covers every step with an ``id``:
# all that can fail here but the TestPyPI upload, never a failure, and
# #1634's tag check, which fails every leg alike.
- name: Record this KTLO leg's outcome
id: ktlo
if: ${{ !cancelled() && matrix.ktlo == true }}
continue-on-error: ${{ matrix.ktlo == true }}
env:
LEG: ${{ matrix.python-version }}
OUTCOMES: ${{ join(steps.*.outcome, ' ') }}
run: |
case " $OUTCOMES " in
*" failure "*) result=failure ;;
*) result=success ;;
esac
echo "ktlo_$(printf '%s' "$LEG" | tr -d '.')=$result" >> "$GITHUB_OUTPUT"
echo "Python $LEG (KTLO, non-blocking): $result (step outcomes: $OUTCOMES)"
# #1672: the warning and job-summary line for each failed step, the same
# step as ends every KTLO leg in unit-tests.yml; see its ``test`` job.
- name: KTLO summary
if: ${{ !cancelled() && matrix.ktlo == true }}
continue-on-error: ${{ matrix.ktlo == true }}
shell: bash
env:
LEG: Python ${{ matrix.python-version }}${{ matrix.ktlo && ' (KTLO, non-blocking)' || '' }}
STEPS: ${{ toJSON(steps) }}
run: /usr/bin/python3 util/leg_summary.py ktlo
conda:
name: Conda deployment (release) on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
# Uploads with ``ANACONDA_TOKEN``, gated through ``needs:`` (#641, #887; see
# the note above ``jobs:``). #888: the aggregate evidence is a cost saver;
# "Check whether this leg is already on Anaconda" is the correctness fix.
environment: anaconda
permissions:
contents: write
needs: [ tag, github, unit-tests, version_check ]
if: >-
${{ !cancelled() && needs.version_check.result == 'success' &&
needs.unit-tests.result == 'success' &&
needs.version_check.outputs.PCAPKIT_DEV_RELEASE != 'true' &&
(needs.github.result == 'success' || needs.github.result == 'skipped') &&
(needs.tag.result == 'success' || needs.tag.result == 'skipped') &&
(startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_RELEASED_ELSEWHERE != 'true') &&
(startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_CONDA_COMPLETE == 'false') }}
strategy:
fail-fast: false
matrix:
# #1822: each leg builds and publishes its own runner's platform only,
# since ``conda convert`` copies binaries unchanged. ``macos-latest`` is
# arm64, so osx-arm64, and ``macos-26-intel`` is Intel, so osx-64, per
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners
# (GA in actions/runner-images#13739). The osx-64 leg ends with GitHub's
# Intel images, which actions/runner-images#13045 says will end.
os:
- macos-latest
- macos-26-intel
- ubuntu-latest
# #2060: win-64. Its `run:` steps name `bash`, as Windows runs `pwsh`.
- windows-latest
# #1633, #1660: the supported tier only. No KTLO 3.10 leg: the list
# util/conda_vendor.py derives omits typing-extensions, which
# pcapkit/utilities/compat.py imports below 3.11, and pins each
# dependency's newest release, a rising floor.
python-version: ${{ fromJSON(needs.version_check.outputs.PYTHON_CONDA) }}
steps:
# #1634: this run's commit, not ``ref: conda-<version>+0``, then the check
# that both tags these packages are filed under name it.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 0
- name: Check the release tags name this run's commit
shell: bash
env:
PCAPKIT_TAGS: v${{ needs.version_check.outputs.PCAPKIT_VERSION }} conda-${{ needs.version_check.outputs.PCAPKIT_VERSION }}+0
PCAPKIT_RUN_SHA: ${{ github.sha }}
run: python3 util/release_tags.py check
# #888: the per-leg correctness fix. Uncached, per ``version_check``'s
# Anaconda check, so this reads the live state. #1967: util/release_conda.py
# holds this step's shell, and the build's and the Intel upload's, which
# cron-conda.yml's ``conda-dist`` runs too; before setup-python, so here
# on the image's ``python3``. On Windows, Git Bash hands it ``/tmp`` as
# the user's temporary directory.
- name: Check whether this leg is already on Anaconda
id: check_leg
shell: bash
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_CONDA_OS: ${{ matrix.os }}
PCAPKIT_PYTHON_VERSION: ${{ matrix.python-version }}
run: python3 util/release_conda.py leg /tmp/anaconda_release.json
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python-version }}
# #1854: nothing below imports pcapkit from this interpreter. ``pip
# download`` needs pip alone, ``conda build`` installs into its own host
# environment, the version comes from job outputs, and the smoke test
# runs its probe under ``-I -S``. So pcapkit and its extras are not
# installed here: on ``macos-26-intel`` they resolve a cryptography with
# no Intel wheel, which pip has to compile or fail on.
- name: Install and Setup
shell: bash
run: |
set -x
python -m pip install -U pip setuptools wheel
- name: Setup Conda Distribution
shell: bash
run: |
set -x
mkdir -p conda/wheels
python -m pip download -r conda/requirements.txt -d conda/wheels
# With `activate-environment: base`, `python-version` installs that Python
# into base, next to conda itself. conda-forge's conda has no py315
# build, so on 3.15 that fails with "RemoveError: Conda cannot remove
# itself" (#1633, measured with conda 26.7.2). So 3.15 leaves base on its
# own Python: `conda build --python` below builds against 3.15 regardless,
# measured to build and import pypcapkit-*-py315_0. Drop the exception
# once conda publishes a py315 build. #2123: nor on macos-26-intel, where
# changing base's Python rebuilds conda-forge's libmambapy at a version
# conda-libmamba-solver cannot drive, failing "Install conda build tools".
- name: Conda environment creation and activation
uses: conda-incubator/setup-miniconda@be893c923ea9cf1cf7cd510fbdde27c7e18cbdcb # v4.1.0
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_BUILD: "0"
with:
# #2044: with no installer named, the Intel runner downloads
# Miniconda3-latest-MacOSX-x86_64.sh, frozen at conda 25.7.0: too old
# for conda-forge's conda-content-trust, and with no py314 build. So
# that leg installs Miniforge. An empty string names no installer, so
# the other legs keep the bundled or downloaded Miniconda.
miniforge-version: ${{ matrix.os == 'macos-26-intel' && 'latest' || '' }}
python-version: ${{ matrix.os != 'macos-26-intel' && matrix.python-version != '3.15' && matrix.python-version || '' }}
activate-environment: base
auto-update-conda: false
auto-activate: true
channels: conda-forge,defaults
conda-remove-defaults: false
show-channel-urls: true
# A login shell, as for the build below: on Windows only that one has the
# `conda` setup-miniconda's `conda init` defines.
- name: Install conda build tools
shell: bash -el {0}
run: |
conda install -n base --override-channels -c conda-forge -y conda-build
conda build --version
# On conda's base ``python``, which the login shell activates, from this
# directory, as conda-dist's step of the same name.
- name: Build conda packages
id: conda_build
shell: bash -el {0}
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
# Build 0 because this is the build ``conda-<version>+0`` names, not
# because ``conda/build`` says so: at a hand-tagged commit it may still
# hold the previous version's counter until ``tag``'s reset (#1634).
PCAPKIT_BUILD: "0"
PCAPKIT_CONDA_OS: ${{ matrix.os }}
PCAPKIT_PYTHON_VERSION: ${{ matrix.python-version }}
working-directory: conda/pypcapkit
run: python ../../util/release_conda.py build
# #1855: cron-conda.yml's ``conda-dist`` step of the same name, which says
# what it checks and why it runs setup-python's interpreter, so a release
# package is checked as a Conda Update bump's is, before anything below
# uploads it. Not gated on ``check_leg``, since the GitHub upload is not.
- name: Smoke-test the vendored packages
shell: bash
env:
PCAPKIT_CONDA_PACKAGE: ${{ steps.conda_build.outputs.host_package }}
run: |
python="${pythonLocation}/bin/python"
if [ "$RUNNER_OS" = Windows ]; then
python="$(cygpath -u "$pythonLocation")/python.exe"
fi
"$python" util/conda_vendor.py --smoke "$PCAPKIT_CONDA_PACKAGE"
# #2044: not on macos-26-intel, whose leg "Upload conda packages to
# Anaconda (Intel)" uploads instead, nor, #2060, on windows-latest, whose
# "Upload conda packages to Anaconda (Windows)" does.
- name: Upload conda packages to Anaconda
if: ${{ matrix.os != 'macos-26-intel' && matrix.os != 'windows-latest' && steps.check_leg.outputs.PCAPKIT_LEG_EXISTS != 'true' }}
uses: anaconda/actions/upload-package@a6f488910b4a1e4f3fe01736241ca1b92b4b355a # v0.3.1
with:
token: ${{ secrets.ANACONDA_TOKEN }}
channel: jarryshaw
packages: ${{ steps.conda_build.outputs.packages }}
labels: ${{ needs.version_check.outputs.PCAPKIT_CONDA_LABEL }}
# #2044: upload-package v0.3.1 installs its CLI from
# anaconda.sh/releases/stable/v0.2.1/ana-darwin-x86_64, which returns 404,
# so the Intel leg runs the call the action makes -- `anaconda --token
# upload --user`, with the same channel, labels and files and the new CLI
# parser -- from conda-forge's anaconda-client in base. One difference:
# `--skip-existing`, so a file anaconda.org already has is skipped where
# the action, with no `force:`, fails on it. "Check whether this leg is
# already on Anaconda" still gates both. ``release_conda.py upload`` runs
# on setup-python's ``python3``.
- name: Upload conda packages to Anaconda (Intel)
if: ${{ matrix.os == 'macos-26-intel' && steps.check_leg.outputs.PCAPKIT_LEG_EXISTS != 'true' }}
shell: bash
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
ANACONDA_CLI_FORCE_NEW: "1"
PCAPKIT_CONDA_CHANNEL: jarryshaw
PCAPKIT_CONDA_PACKAGES: ${{ steps.conda_build.outputs.packages }}
PCAPKIT_CONDA_LABELS: ${{ needs.version_check.outputs.PCAPKIT_CONDA_LABEL }}
run: python3 util/release_conda.py upload
# #2060: the Intel leg's call, on win-64, under a login shell as "Build
# conda packages" is: only there is base active, so the script can start
# `conda` as base's `Scripts\conda.exe`, and `python` is base's. The
# script runs base's `Scripts\anaconda.exe`.
- name: Upload conda packages to Anaconda (Windows)
if: ${{ matrix.os == 'windows-latest' && steps.check_leg.outputs.PCAPKIT_LEG_EXISTS != 'true' }}
shell: bash -el {0}
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
ANACONDA_CLI_FORCE_NEW: "1"
PCAPKIT_CONDA_CHANNEL: jarryshaw
PCAPKIT_CONDA_PACKAGES: ${{ steps.conda_build.outputs.packages }}
PCAPKIT_CONDA_LABELS: ${{ needs.version_check.outputs.PCAPKIT_CONDA_LABEL }}
run: python util/release_conda.py upload
# ``pypi``'s upload script, for the same reasons (#1634, #1640). Not
# gated on ``check_leg`` as the Anaconda upload is: a leg whose Anaconda
# upload landed and whose GitHub upload then failed would get no GitHub
# asset on any re-run. Skipping a file the release already has is what
# stops the replacement #1640 measured.
- name: Upload package to GitHub Release
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PCAPKIT_RELEASE_TAG: v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_ASSETS: ${{ steps.conda_build.outputs.packages }}
run: python3 util/release_upload.py
# #888: a run that released nothing says why, in one place. ``version_check``
# can skip before any evidence exists, and ``unit-tests`` can fail or skip
# (#1052), so this reconstructs the outcome from ``needs.*.result`` and the
# trigger. ``!cancelled()`` keeps a skipped upstream from skipping it, and is
# chosen over ``always()`` so that cancelling the run cancels this report too
# rather than leaving it to describe a run it cannot fully see.