This repository was archived by the owner on May 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 200
chore: add PyPI publishing infrastructure for wren-core-py #1496
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| name: Publish wren-core-py to PyPI | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write # Required for trusted publishing (OIDC) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| target: | ||
| description: "Publish target" | ||
| required: true | ||
| default: "testpypi" | ||
| type: choice | ||
| options: | ||
| - testpypi | ||
| - pypi | ||
|
|
||
| jobs: | ||
| build-wheels: | ||
| name: Build wheel — ${{ matrix.os }} (${{ matrix.target }}) | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # Linux x86_64 | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| # Linux aarch64 | ||
| - os: ubuntu-latest | ||
| target: aarch64-unknown-linux-gnu | ||
| # macOS x86_64 | ||
| - os: macos-13 | ||
| target: x86_64-apple-darwin | ||
| # macOS arm64 | ||
| - os: macos-latest | ||
| target: aarch64-apple-darwin | ||
| # Windows x86_64 | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
| - name: Build wheel | ||
| uses: PyO3/maturin-action@v1 | ||
| with: | ||
| target: ${{ matrix.target }} | ||
| args: --release --out dist | ||
| manylinux: auto | ||
| working-directory: wren-core-py | ||
| - name: Upload wheel | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheel-${{ matrix.target }} | ||
| path: wren-core-py/dist/*.whl | ||
|
|
||
| build-sdist: | ||
| name: Build sdist | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Build sdist | ||
| uses: PyO3/maturin-action@v1 | ||
| with: | ||
| command: sdist | ||
| args: --out dist | ||
| working-directory: wren-core-py | ||
| - name: Upload sdist | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: sdist | ||
| path: wren-core-py/dist/*.tar.gz | ||
|
|
||
| publish: | ||
| name: Publish to ${{ github.event.inputs.target || 'testpypi' }} | ||
| needs: [build-wheels, build-sdist] | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: ${{ github.event.inputs.target || 'testpypi' }} | ||
| url: ${{ github.event.inputs.target == 'pypi' && 'https://pypi.org/project/wren-core-py/' || 'https://test.pypi.org/project/wren-core-py/' }} | ||
| steps: | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: dist | ||
| merge-multiple: true | ||
|
|
||
| - name: List artifacts | ||
| run: ls -lhR dist/ | ||
|
|
||
| - name: Publish to ${{ github.event.inputs.target }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: ${{ github.event.inputs.target == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }} | ||
| packages-dir: dist/ | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Build and publish wren-core-py to PyPI or TestPyPI. | ||
| # | ||
| # Usage: | ||
| # ./scripts/publish.sh # build + publish to PyPI | ||
| # ./scripts/publish.sh --test # build + publish to TestPyPI | ||
| # ./scripts/publish.sh --build # build only (no publish) | ||
| # | ||
| # Prerequisites: | ||
| # - Rust toolchain (rustup, cargo) | ||
| # - maturin (pip install maturin) | ||
| # - twine (pip install twine) | ||
| # | ||
| # Environment variables (optional): | ||
| # MATURIN_ARGS — extra args passed to maturin build (e.g. "--target x86_64-unknown-linux-gnu") | ||
| # | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" | ||
| DIST_DIR="$PROJECT_DIR/dist" | ||
|
|
||
| MODE="publish" # publish | test | build | ||
| REPOSITORY="pypi" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --test) | ||
| MODE="test" | ||
| REPOSITORY="testpypi" | ||
| shift | ||
| ;; | ||
| --build) | ||
| MODE="build" | ||
| shift | ||
| ;; | ||
| -h|--help) | ||
| echo "Usage: $0 [--test | --build | -h]" | ||
| echo "" | ||
| echo " (no flag) Build and publish to PyPI" | ||
| echo " --test Build and publish to TestPyPI" | ||
| echo " --build Build only, no publish" | ||
| echo " -h, --help Show this help" | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| cd "$PROJECT_DIR" | ||
|
|
||
| # --- Check prerequisites --- | ||
| for cmd in cargo maturin; do | ||
| if ! command -v "$cmd" &>/dev/null; then | ||
| echo "Error: '$cmd' is not installed." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| if [[ "$MODE" != "build" ]]; then | ||
| if ! command -v twine &>/dev/null; then | ||
| echo "Error: 'twine' is not installed. Run: pip install twine" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # --- Read version from Cargo.toml --- | ||
| VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') | ||
| echo "==> Building wren-core-py v${VERSION}" | ||
|
|
||
| # --- Clean previous dist --- | ||
| rm -rf "$DIST_DIR" | ||
| mkdir -p "$DIST_DIR" | ||
|
|
||
| # --- Build wheel --- | ||
| echo "==> Running maturin build --release" | ||
| maturin build --release --out "$DIST_DIR" ${MATURIN_ARGS:-} | ||
|
|
||
| # --- Build sdist --- | ||
| echo "==> Running maturin sdist" | ||
| maturin sdist --out "$DIST_DIR" | ||
|
|
||
| # --- List artifacts --- | ||
| echo "" | ||
| echo "==> Built artifacts:" | ||
| ls -lh "$DIST_DIR" | ||
|
|
||
| # --- Validate --- | ||
| echo "" | ||
| echo "==> Validating with twine check" | ||
| twine check "$DIST_DIR"/* 2>/dev/null || { | ||
| if [[ "$MODE" == "build" ]]; then | ||
| echo "Warning: twine not available for validation (build-only mode)" | ||
| else | ||
| exit 1 | ||
| fi | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validation failures are masked in This block treats any 💡 Proposed fix-echo "==> Validating with twine check"
-twine check "$DIST_DIR"/* 2>/dev/null || {
- if [[ "$MODE" == "build" ]]; then
- echo "Warning: twine not available for validation (build-only mode)"
- else
- exit 1
- fi
-}
+echo "==> Validating with twine check"
+if command -v twine &>/dev/null; then
+ twine check "$DIST_DIR"/*
+elif [[ "$MODE" == "build" ]]; then
+ echo "Warning: twine not installed; skipping validation in build-only mode"
+else
+ echo "Error: 'twine' is not installed. Run: pip install twine" >&2
+ exit 1
+fi🤖 Prompt for AI Agents |
||
|
|
||
| if [[ "$MODE" == "build" ]]; then | ||
| echo "" | ||
| echo "==> Build complete. Artifacts in: $DIST_DIR" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # --- Publish --- | ||
| echo "" | ||
| if [[ "$REPOSITORY" == "testpypi" ]]; then | ||
| echo "==> Publishing to TestPyPI" | ||
| echo " After upload, install with:" | ||
| echo " pip install --index-url https://test.pypi.org/simple/ wren-core-py" | ||
| else | ||
| echo "==> Publishing to PyPI" | ||
| fi | ||
| echo "" | ||
|
|
||
| twine upload --repository "$REPOSITORY" "$DIST_DIR"/* | ||
|
|
||
| echo "" | ||
| echo "==> Done! Published wren-core-py v${VERSION} to ${REPOSITORY}" | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Canner/wren-engine
Length of output: 856
Invalid macOS runner label will break the wheel matrix.
Line 34 uses
macos-13, which is not a valid GitHub Actions hosted runner label, so that job will fail to start.💡 Proposed fix
🧰 Tools
🪛 actionlint (1.7.11)
[error] 34-34: label "macos-13" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2025", "windows-2025-vs2026", "windows-2022", "windows-11-arm", "ubuntu-slim", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-24.04-arm", "ubuntu-22.04", "ubuntu-22.04-arm", "macos-latest", "macos-latest-xlarge", "macos-latest-large", "macos-26-xlarge", "macos-26-large", "macos-26", "macos-15-intel", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xlarge", "macos-14-large", "macos-14", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file
(runner-label)
🤖 Prompt for AI Agents