File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,13 +137,21 @@ jobs:
137137 with :
138138 python-version : ' 3.12'
139139
140- - name : Compute version
140+ - name : Compute version from PyPI
141141 id : version
142142 run : |
143143 base=$(cat VERSION | tr -d '[:space:]')
144- version="${base}.${{ github.run_number }}"
144+ pkg="drp-cli"
145+ latest=$(curl -sf "https://pypi.org/pypi/${pkg}/json" \
146+ | python3 -c "import sys,json; print(json.load(sys.stdin)['info']['version'])" 2>/dev/null || echo "")
147+ if [ -n "$latest" ] && echo "$latest" | grep -q "^${base}\."; then
148+ patch=$(echo "$latest" | cut -d. -f3)
149+ version="${base}.$((patch + 1))"
150+ else
151+ version="${base}.0"
152+ fi
145153 echo "version=$version" >> "$GITHUB_OUTPUT"
146- echo "Publishing drp-cli $ version"
154+ echo "Publishing ${pkg} ${ version} (latest on PyPI: ${latest:-none}) "
147155
148156 - name : Stamp version into CLI
149157 run : |
Original file line number Diff line number Diff line change @@ -169,13 +169,21 @@ jobs:
169169 with :
170170 python-version : ' 3.12'
171171
172- - name : Compute version
172+ - name : Compute version from PyPI
173173 id : version
174174 run : |
175175 base=$(cat VERSION | tr -d '[:space:]')
176- version="${base}.${{ github.run_number }}"
176+ pkg="drp"
177+ latest=$(curl -sf "https://pypi.org/pypi/${pkg}/json" \
178+ | python3 -c "import sys,json; print(json.load(sys.stdin)['info']['version'])" 2>/dev/null || echo "")
179+ if [ -n "$latest" ] && echo "$latest" | grep -q "^${base}\."; then
180+ patch=$(echo "$latest" | cut -d. -f3)
181+ version="${base}.$((patch + 1))"
182+ else
183+ version="${base}.0"
184+ fi
177185 echo "version=$version" >> "$GITHUB_OUTPUT"
178- echo "Publishing drp $ version"
186+ echo "Publishing ${pkg} ${ version} (latest on PyPI: ${latest:-none}) "
179187
180188 - name : Collect commits since last release
181189 run : |
Original file line number Diff line number Diff line change 11"""drp CLI — command-line tool for drp."""
22
33# VERSION file holds major.minor (e.g. "0.3") — only bumped manually.
4- # CI computes full version (major.minor.run_number) and seds this line
5- # to a literal before building: __version__ = '0.3.42'
6- # Never auto- committed, so merges between dev↔main stay clean.
4+ # CI queries PyPI for latest published version, bumps patch +1,
5+ # and seds this line to a literal before building: __version__ = '0.3.42'
6+ # Nothing committed back — merges between dev↔main stay clean.
77# Fallback: importlib.metadata for installed packages.
88
99def _resolve_version ():
Original file line number Diff line number Diff line change @@ -550,7 +550,7 @@ def test_version_is_semver(self):
550550 from cli import __version__
551551 parts = __version__ .split ('.' )
552552 # Locally: "0.3" (major.minor from VERSION file)
553- # CI/installed: "0.3.42" (major.minor.run_number )
553+ # CI/installed: "0.3.42" (major.minor.patch from PyPI bump )
554554 assert len (parts ) >= 2
555555 for part in parts :
556556 assert part .isdigit ()
You can’t perform that action at this time.
0 commit comments