feat(ansible): read .python-version in release workflow#30
Merged
Conversation
release-ansible-collection.yml had a python_version input defaulting to 3.11 and never read the repo-root .python-version file, so a collection that bumped .python-version still published with 3.11 unless it also passed the input. Add a "Resolve Python version" step that picks the input when set, otherwise the first line of .python-version, otherwise 3.11. The input default changes from 3.11 to empty; callers passing python_version are unaffected, callers that relied on the silent 3.11 default now get .python-version when present. This makes .python-version authoritative for the publish build, closing the caveat documented in AGENTS.md. The input is passed via env into the resolve step rather than interpolated into the script. Signed-off-by: Simon Bärlocher <s.baerlocher@sbaerlocher.ch>
There was a problem hiding this comment.
Clean, well-scoped change. Resolution order (input → .python-version → 3.11) is correct, checkout precedes the resolution step so the file is available, and the input is safely passed via env: rather than interpolated into the script. AGENTS.md and CHANGELOG are accurately updated and the non-breaking claim holds for input-passing callers.
One minor, non-blocking suggestion left inline: the 3.11 fallback only fires when .python-version is absent, not when it's empty/whitespace-only — a small guard would make the behavior match the documented contract. Drift-protection (Renovate) keeps the file populated, so this is an edge case and not blocking.
An existing but empty or whitespace-only .python-version yielded an empty VERSION, passed as an empty python-version to setup-python instead of the documented 3.11 fallback. Read the file into FILE_VERSION first and treat an empty result the same as an absent file. Signed-off-by: Simon Bärlocher <s.baerlocher@sbaerlocher.ch>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the release-path caveat from #27/#28.
release-ansible-collection.ymlnow reads the publish Python version from the repo-root
.python-versionfileinstead of silently defaulting to
3.11.python_versioninput when set →.python-versionfirst line →3.11fallback.3.11→ empty. Not breaking: callers passingpython_versionare unaffected; callers that relied on the silent3.11now get
.python-versionif present, else still3.11.env:into the step, not interpolated into the script.Test plan
.python-version>3.11