Skip to content

Commit eabadbd

Browse files
committed
ci(release): move Reset Build Number into util/release_reset_build.py (#1967)
Per the 2026-10-23 ruling on #1967, judged step by step: of the github and tag jobs' remaining shell, only Reset Build Number has real logic (44 lines, a three-attempt push loop, five early exits, the #1634 history). Select release body, Explain a refused release tag and Create Tag stay inline, as does cron-conda.yml's release check. - util/release_reset_build.py: the former shell's decisions, git calls, lines and annotations, and its exit statuses under set -euo pipefail. - create-release.yml: the step runs the script, keeping its name and env. - tests: the former shell runs verbatim beside the script on scratch repositories, covering every way it ends; the step, its whole checkout, its git calls and 3.7 syntax are pinned. The helper test lists it. - workflows.rst: its row in the Workflow Scripts table.
1 parent cfabfb2 commit eabadbd

5 files changed

Lines changed: 700 additions & 64 deletions

File tree

‎.github/workflows/create-release.yml‎

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -543,71 +543,14 @@ jobs:
543543
fi
544544
545545
# A commit of its own on ``main``, only ever fast-forwarded by a plain push
546-
# of one commit onto the tip just fetched. It sets ``conda/build`` to 0, so
547-
# the next Conda Update bump of this version is ``+1`` -- unless:
548-
#
549-
# * this run's commit is not on ``main`` -- left alone, with a warning;
550-
# * the tip already says 0 -- usual, as util/bump_version.py writes 0;
551-
# * the tip carries another ``__version__`` -- its counter, left alone;
552-
# * origin has a ``conda-<version>+N`` tag other than ``+0`` -- rewinding
553-
# would let a later bump reuse that number; left alone, with a warning.
554-
#
555-
# A rejected push means ``main`` moved: the decision is made again from a
556-
# fresh fetch, three times at most.
546+
# of one commit onto the tip just fetched, setting ``conda/build`` to 0 so
547+
# the next Conda Update bump of this version is ``+1``. The script's
548+
# docstring says when it leaves ``main`` alone instead (#1967).
557549
- name: Reset Build Number
558550
env:
559551
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
560552
PCAPKIT_RUN_SHA: ${{ github.sha }}
561-
run: |
562-
set -euo pipefail
563-
564-
run_commit="$(git rev-parse --verify "${PCAPKIT_RUN_SHA}^{commit}")"
565-
run_version="$(git show "${run_commit}:pcapkit/__init__.py" | sed -n 's/^__version__ = //p')"
566-
builds="refs/tags/conda-${PCAPKIT_VERSION}+"
567-
568-
for attempt in 1 2 3; do
569-
git fetch --quiet origin "+refs/heads/main:refs/remotes/origin/main"
570-
tip="$(git rev-parse refs/remotes/origin/main)"
571-
572-
if ! git merge-base --is-ancestor "$run_commit" "$tip"; then
573-
echo "::warning title=conda/build not reset::${run_commit} is not on main (tip ${tip}), so main is left alone; its conda/build still reads what it did."
574-
exit 0
575-
fi
576-
tip_build="$(git show "${tip}:conda/build" | tr -d '[:space:]')"
577-
if [ "$tip_build" = "0" ]; then
578-
echo "::notice title=No conda build reset needed::main (${tip}) already carries conda/build 0."
579-
exit 0
580-
fi
581-
tip_version="$(git show "${tip}:pcapkit/__init__.py" | sed -n 's/^__version__ = //p')"
582-
if [ "$tip_version" != "$run_version" ]; then
583-
echo "::notice title=conda/build not reset::main (${tip}) has moved on to __version__ ${tip_version}; its conda/build ${tip_build} counts that version's builds."
584-
exit 0
585-
fi
586-
tagged="$(git ls-remote --tags --refs origin "${builds}*")"
587-
taken=""
588-
while read -r _ ref; do
589-
build="${ref#"$builds"}"
590-
if [ "$build" != "$ref" ] && [ "$build" != "0" ]; then
591-
taken="${taken:+${taken} }+${build}"
592-
fi
593-
done <<< "$tagged"
594-
if [ -n "$taken" ]; then
595-
echo "::warning title=conda/build not reset::conda-${PCAPKIT_VERSION} is already tagged at ${taken}; resetting conda/build ${tip_build} on main (${tip}) to 0 would let a later Conda Update bump reuse one of those build numbers."
596-
exit 0
597-
fi
598-
599-
git switch --quiet --force --detach "$tip"
600-
printf 0 > conda/build
601-
git commit --quiet -m"Reset conda build number" -m"conda-${PCAPKIT_VERSION}+0 was tagged at ${run_commit}." -- conda/build
602-
if git push origin "HEAD:refs/heads/main"; then
603-
echo "conda/build reset from ${tip_build} to 0 on main in $(git rev-parse HEAD), on top of ${tip}"
604-
exit 0
605-
fi
606-
echo "push to main rejected on attempt ${attempt}; fetching again"
607-
done
608-
609-
echo "::error title=conda/build not reset::main kept moving; three pushes were rejected. ${run_commit} is tagged regardless -- reset conda/build on main by hand if no conda-${PCAPKIT_VERSION}+N tag other than +0 exists."
610-
exit 1
553+
run: python3 util/release_reset_build.py
611554

612555
pypi:
613556
name: PyPI distribution for Python ${{ matrix.python-version }}${{ matrix.ktlo && ' (KTLO)' || '' }}

‎docs/source/contributing/workflows.rst‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,11 @@ to a script. Each script's docstring says what it does; each has tests under
13221322
<https://github.com/JarryShaw/PyPCAPKit/issues/1822>`__, `#2044
13231323
<https://github.com/JarryShaw/PyPCAPKit/issues/2044>`__).
13241324
- No.
1325+
* - :file:`util/release_reset_build.py`
1326+
- ``Reset Build Number`` in ``create-release.yml``'s ``tag``, on the image's
1327+
``python3`` (`#1634 <https://github.com/JarryShaw/PyPCAPKit/issues/1634>`__).
1328+
``Create Tag`` before it stays inline.
1329+
- No.
13251330

13261331
The summaries run on the image's ``/usr/bin/python3`` rather than the leg's
13271332
interpreter, which may have failed to set up or be too broken to run anything, so
@@ -1346,7 +1351,8 @@ tree. The release scripts run as ``python3``, from a checkout of the whole tree,
13461351
standard library only: :file:`util/release_tags.py` on the image's
13471352
own, since ``github`` has no setup-python and ``pypi`` and ``conda`` run the check
13481353
before theirs, and :file:`util/release_upload.py` on the leg's, after it.
1349-
:file:`util/release_conda.py` runs ``leg`` on the image's ``python3``, before
1354+
:file:`util/release_reset_build.py` runs on the image's own too, as ``tag`` has no
1355+
setup-python. :file:`util/release_conda.py` runs ``leg`` on the image's ``python3``, before
13501356
setup-python, ``build`` on conda's base ``python`` under the login shell, from
13511357
:file:`conda/pypcapkit`, and ``upload`` on setup-python's. A project
13521358
pin runs each on the cases the shell it replaced handled and requires the same

‎tests/project/test_actions_helper_2047.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#: The scripts that import the helper.
4646
SCRIPTS = ('apt_packages', 'check_suite_report', 'ci_timing', 'classify_changes', 'codeql_report',
4747
'coverage_report', 'discussion_report', 'leg_summary', 'pip_install', 'project_status',
48-
'python_versions', 'regenerate_samples', 'release_conda', 'release_published', 'release_status',
49-
'release_tags', 'release_tiers', 'release_upload', 'superseded',
48+
'python_versions', 'regenerate_samples', 'release_conda', 'release_published', 'release_reset_build',
49+
'release_status', 'release_tags', 'release_tiers', 'release_upload', 'superseded',
5050
'update_python_versions', 'vendor_code_changed', 'vendor_test_gate', 'verdict_covers_checkout')
5151
#: The top-level modules the helper may import, each in Python 3.7's standard
5252
#: library: the running interpreter's :data:`sys.stdlib_module_names` would
@@ -68,6 +68,7 @@
6868
'regenerate_samples': (['--help'], {}),
6969
'release_conda': (['--help'], {}),
7070
'release_published': (['--help'], {}),
71+
'release_reset_build': (['--help'], {}),
7172
'release_status': (['--help'], {}),
7273
'release_tags': (['--help'], {}),
7374
'release_tiers': (['--help'], {}),

0 commit comments

Comments
 (0)