Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 4 additions & 61 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -543,71 +543,14 @@ jobs:
fi

# A commit of its own on ``main``, only ever fast-forwarded by a plain push
# of one commit onto the tip just fetched. It sets ``conda/build`` to 0, so
# the next Conda Update bump of this version is ``+1`` -- unless:
#
# * this run's commit is not on ``main`` -- left alone, with a warning;
# * the tip already says 0 -- usual, as util/bump_version.py writes 0;
# * the tip carries another ``__version__`` -- its counter, left alone;
# * origin has a ``conda-<version>+N`` tag other than ``+0`` -- rewinding
# would let a later bump reuse that number; left alone, with a warning.
#
# A rejected push means ``main`` moved: the decision is made again from a
# fresh fetch, three times at most.
# 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: |
set -euo pipefail

run_commit="$(git rev-parse --verify "${PCAPKIT_RUN_SHA}^{commit}")"
run_version="$(git show "${run_commit}:pcapkit/__init__.py" | sed -n 's/^__version__ = //p')"
builds="refs/tags/conda-${PCAPKIT_VERSION}+"

for attempt in 1 2 3; do
git fetch --quiet origin "+refs/heads/main:refs/remotes/origin/main"
tip="$(git rev-parse refs/remotes/origin/main)"

if ! git merge-base --is-ancestor "$run_commit" "$tip"; then
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."
exit 0
fi
tip_build="$(git show "${tip}:conda/build" | tr -d '[:space:]')"
if [ "$tip_build" = "0" ]; then
echo "::notice title=No conda build reset needed::main (${tip}) already carries conda/build 0."
exit 0
fi
tip_version="$(git show "${tip}:pcapkit/__init__.py" | sed -n 's/^__version__ = //p')"
if [ "$tip_version" != "$run_version" ]; then
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."
exit 0
fi
tagged="$(git ls-remote --tags --refs origin "${builds}*")"
taken=""
while read -r _ ref; do
build="${ref#"$builds"}"
if [ "$build" != "$ref" ] && [ "$build" != "0" ]; then
taken="${taken:+${taken} }+${build}"
fi
done <<< "$tagged"
if [ -n "$taken" ]; then
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."
exit 0
fi

git switch --quiet --force --detach "$tip"
printf 0 > conda/build
git commit --quiet -m"Reset conda build number" -m"conda-${PCAPKIT_VERSION}+0 was tagged at ${run_commit}." -- conda/build
if git push origin "HEAD:refs/heads/main"; then
echo "conda/build reset from ${tip_build} to 0 on main in $(git rev-parse HEAD), on top of ${tip}"
exit 0
fi
echo "push to main rejected on attempt ${attempt}; fetching again"
done

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."
exit 1
run: python3 util/release_reset_build.py

pypi:
name: PyPI distribution for Python ${{ matrix.python-version }}${{ matrix.ktlo && ' (KTLO)' || '' }}
Expand Down
8 changes: 7 additions & 1 deletion docs/source/contributing/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,11 @@ to a script. Each script's docstring says what it does; each has tests under
<https://github.com/JarryShaw/PyPCAPKit/issues/1822>`__, `#2044
<https://github.com/JarryShaw/PyPCAPKit/issues/2044>`__).
- No.
* - :file:`util/release_reset_build.py`
- ``Reset Build Number`` in ``create-release.yml``'s ``tag``, on the image's
``python3`` (`#1634 <https://github.com/JarryShaw/PyPCAPKit/issues/1634>`__).
``Create Tag`` before it stays inline.
- No.

The summaries run on the image's ``/usr/bin/python3`` rather than the leg's
interpreter, which may have failed to set up or be too broken to run anything, so
Expand All @@ -1346,7 +1351,8 @@ tree. The release scripts run as ``python3``, from a checkout of the whole tree,
standard library only: :file:`util/release_tags.py` on the image's
own, since ``github`` has no setup-python and ``pypi`` and ``conda`` run the check
before theirs, and :file:`util/release_upload.py` on the leg's, after it.
:file:`util/release_conda.py` runs ``leg`` on the image's ``python3``, before
:file:`util/release_reset_build.py` runs on the image's own too, as ``tag`` has no
setup-python. :file:`util/release_conda.py` runs ``leg`` on the image's ``python3``, before
setup-python, ``build`` on conda's base ``python`` under the login shell, from
:file:`conda/pypcapkit`, and ``upload`` on setup-python's. A project
pin runs each on the cases the shell it replaced handled and requires the same
Expand Down
5 changes: 3 additions & 2 deletions tests/project/test_actions_helper_2047.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#: The scripts that import the helper.
SCRIPTS = ('apt_packages', 'check_suite_report', 'ci_timing', 'classify_changes', 'codeql_report',
'coverage_report', 'discussion_report', 'leg_summary', 'pip_install', 'project_status',
'python_versions', 'regenerate_samples', 'release_conda', 'release_published', 'release_status',
'release_tags', 'release_tiers', 'release_upload', 'superseded',
'python_versions', 'regenerate_samples', 'release_conda', 'release_published', 'release_reset_build',
'release_status', 'release_tags', 'release_tiers', 'release_upload', 'superseded',
'update_python_versions', 'vendor_code_changed', 'vendor_test_gate', 'verdict_covers_checkout')
#: The top-level modules the helper may import, each in Python 3.7's standard
#: library: the running interpreter's :data:`sys.stdlib_module_names` would
Expand All @@ -68,6 +68,7 @@
'regenerate_samples': (['--help'], {}),
'release_conda': (['--help'], {}),
'release_published': (['--help'], {}),
'release_reset_build': (['--help'], {}),
'release_status': (['--help'], {}),
'release_tags': (['--help'], {}),
'release_tiers': (['--help'], {}),
Expand Down
Loading
Loading