Skip to content

Commit 3b50471

Browse files
mergify[bot]cdoern
andauthored
fix: override version from release tag for all packages (backport #4788) (#4789)
# What does this PR do? - Patch pyproject.toml and _version.py in external Python client repo at build time using the release tag version - Use npm version to set TypeScript client version from release tag - Prefix npm tarball path with ./ to prevent npm from interpreting it as a GitHub shorthand URL <hr>This is an automatic backport of pull request #4788 done by [Mergify](https://mergify.com). Signed-off-by: Charlie Doern <cdoern@redhat.com> Co-authored-by: Charlie Doern <cdoern@redhat.com>
1 parent d1f06d8 commit 3b50471

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/pypi.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,36 @@ jobs:
251251
if: steps.should-build.outputs.skip != 'true' && matrix.type == 'external' && matrix.registry == 'pypi'
252252
working-directory: external-repo
253253
run: |
254+
# Override version from tag or input
255+
if [ -n "${{ inputs.version }}" ]; then
256+
VERSION="${{ inputs.version }}"
257+
elif [ "${{ github.event_name }}" == "release" ]; then
258+
VERSION="${GITHUB_REF#refs/tags/v}"
259+
fi
260+
if [ -n "$VERSION" ]; then
261+
echo "Setting version to $VERSION"
262+
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
263+
# Also update __version__ in _version.py if it exists
264+
VERSION_FILE=$(find . -name "_version.py" -path "*/llama_stack_client/*" | head -1)
265+
if [ -n "$VERSION_FILE" ]; then
266+
sed -i "s/__version__ = .*/__version__ = \"$VERSION\"/" "$VERSION_FILE"
267+
fi
268+
fi
254269
# Use python -m build for better compatibility
255270
uv pip install --system build
256271
python -m build --outdir dist
257-
env:
258-
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ inputs.version || '' }}
259-
# Note: external packages have their own versioning; only override if explicitly provided
260272
261273
# === NPM PACKAGE BUILD ===
262274
- name: Build TypeScript package
263275
if: steps.should-build.outputs.skip != 'true' && matrix.registry == 'npm'
264276
working-directory: external-repo
265277
run: |
278+
# Override version from tag or input
279+
if [ -n "${{ inputs.version }}" ]; then
280+
npm version "${{ inputs.version }}" --no-git-tag-version
281+
elif [ "${{ github.event_name }}" == "release" ]; then
282+
npm version "${GITHUB_REF#refs/tags/v}" --no-git-tag-version
283+
fi
266284
npm install
267285
npm run build
268286
@@ -618,14 +636,14 @@ jobs:
618636
exit 1
619637
fi
620638
# Extract and publish from the tarball
621-
TARBALL=$(ls dist/*.tgz | head -1)
639+
TARBALL=$(ls ./dist/*.tgz | head -1)
622640
npm publish "$TARBALL" --access public
623641
else
624642
echo "DRY RUN: Verifying npm package (not publishing)"
625643
echo "Package tarball:"
626644
ls -la dist/*.tgz
627645
# Verify the tarball is valid
628-
TARBALL=$(ls dist/*.tgz | head -1)
646+
TARBALL=$(ls ./dist/*.tgz | head -1)
629647
tar -tzf "$TARBALL" | head -20
630648
echo "... (truncated)"
631649
fi

0 commit comments

Comments
 (0)