Python: resolve release tags against real package directories - #7795
Conversation
Pass the release tag through the step env block and reference it as a quoted shell variable, and validate the package name derived from the tag before using it as a directory path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 73f2e039-3ff4-4a5a-a8f8-253b0bfa94f3
There was a problem hiding this comment.
Pull request overview
Improves release-tag handling and package path quoting in the Python release workflow.
Changes:
- Passes release tags through step environment variables.
- Adds package-name validation.
- Quotes package directory paths.
Suppressed comments (1)
.github/workflows/python-release.yml:46
- This condition does not verify that the tag matched
python-<package>-<version>.sedreturns the original input on no match, and its.*also accepts an empty version; for example,python-core-yieldscore, passes this check, and builds the package despite having no version. Validate the full tag/extraction match (including a nonempty version) before checking the package identifier.
echo "Error: could not derive a valid package name from tag '$TAG'"
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 1b8dff257ce7
Model: gpt-5.6-sol
Overview
The change removes direct release-tag interpolation from shell source, constrains the derived package identifier, and quotes the package path used by the build command. The environment handoff remains job-scoped, and the existing package-directory check prevents nonexistent targets from reaching the build. No publishable Critical, High, or Medium defect was introduced by this diff.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Package names can contain hyphens and can use underscores where the tag uses hyphens, so splitting the tag on the first hyphen picked the wrong directory. Resolve the name against the actual packages/ listing instead, and handle the python-<version> workspace tag explicitly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 73f2e039-3ff4-4a5a-a8f8-253b0bfa94f3
|
/review |
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: Findings reported
Scope: 1 net-new commit(s): 654835742abc
Model: gpt-5.6-sol
Overview
The workflow now resolves package tags against real package directories, handles underscore-to-hyphen aliases, quotes tag-derived values, and fails when a package name cannot be resolved. The full-workspace build is also wired through the repository's existing root build task. One input-validation gap remains: any single-component suffix is accepted as a workspace version, allowing malformed package tags to attach the full artifact set.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: .github/workflows/python-release.yml
Selecting the workspace build on the absence of a hyphen meant a malformed tag such as python-devui built and uploaded the whole workspace. Match the suffix against the supported version formats instead, and reject tags that are neither shape. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 73f2e039-3ff4-4a5a-a8f8-253b0bfa94f3
Motivation & Context
python-release.ymlbuilds the release assets for a release by deriving a package namefrom the release tag. The extraction is a single
sedthat splits the tag on the firsthyphen:
PACKAGE=$(echo "$TAG" | sed 's/^python-\([^-]*\)-.*$/\1/')That assumes package names never contain a hyphen and always match their directory name
exactly. Neither holds, so against the tags this repo actually produces:
python-devui-1.0.0b260414devuipython-hosting-a2a-1.0.0a260723hostingpackages/hostingexists, so it succeeds silentlypython-github-copilot-1.0.0githubgithub_copilotpython-1.14.0python-1.14.0The
hosting-a2acase is the concerning one: the job attaches artifacts for a differentpackage to the release without any error.
Separately, the tag value was templated directly into the
run:script text rather thanpassed through the step
env:block. Every other workflow in this repo already uses theenv:block forgithub.event.*values, so this one was the odd one out.Description & Review Guide
What are the major changes?
covers the lifecycle versions from the
python-package-managementskill plus there-cut suffixes present in the tag history (
1.0.0b251105.1,1.0.0b251106.post1):^[0-9]+\.[0-9]+\.[0-9]+([ab][0-9]+|rc[0-9]+)?(\.[0-9]+|\.post[0-9]+)?$.Tags matching neither shape are rejected instead of being guessed at.
packages/listing instead of guessing thehyphen boundary. The trailing
-<version>component is stripped, and the remainder ismatched against each directory name both literally and with
_normalized to-,which covers
hosting-a2a,azure-ai-search,github_copilot, andfoundry_local.python-<version>workspace tag explicitly. It now runs the rootuv run poe build, which builds every workspace package plus theagent-frameworkmeta package into
python/dist/, instead of failing on a nonsensical package name.packages, rather than falling through to a confusing later failure.
env:block asTAG_NAMEand reference it as a quoted shellvariable, matching the pattern used elsewhere in
.github/workflows/.set -euo pipefailto the scripted steps.What is the impact of these changes?
Single-package release tags now resolve to the correct directory, including the ones that
previously resolved to the wrong package or failed outright. Workspace-level
python-X.Y.Ztags now build assets instead of erroring. Malformed tags fail with a clearmessage instead of producing an arbitrary build. Renamed the first step from
"Set environment variables" to "Resolve the package to build" to reflect what it does.
What do you want reviewers to focus on?
The
python-<version>branch: it now invokes the rootpoe build, which builds allpackages plus the meta package. Please confirm that is the intended asset set for a
workspace-level release tag — that is the one behavior here that is a deliberate choice
rather than a straightforward correction.
Verified against all 62 existing
python-*tags in the repo (all resolve as expected), asynthetic tag for each of the 35 directories under
python/packages/(all round-trip tothe correct directory), and a set of malformed tags (
python-devui,python-typo,python-,python-hosting-a2a,python-devui-notaversion,python-1.0), which allerror out.
Related Issue
N/A — no tracking issue; found while reading the release workflow.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.