91e75e620b
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
109 lines
3.1 KiB
YAML
109 lines
3.1 KiB
YAML
name: Reusable Package Publish Workflow
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
package_name:
|
|
description: "Name of the package (e.g. computer, agent)"
|
|
required: true
|
|
type: string
|
|
package_dir:
|
|
description: "Directory containing the package relative to workspace root (e.g. libs/python/computer)"
|
|
required: true
|
|
type: string
|
|
version:
|
|
description: "Version to publish"
|
|
required: true
|
|
type: string
|
|
base_package_name:
|
|
description: "PyPI package name (e.g. cua-agent)"
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
PYPI_TOKEN:
|
|
required: true
|
|
outputs:
|
|
version:
|
|
description: "The version that was published"
|
|
value: ${{ jobs.build-and-publish.outputs.version }}
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
runs-on: macos-latest
|
|
permissions:
|
|
contents: read
|
|
outputs:
|
|
version: ${{ steps.set-version.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
fetch-depth: 0 # Full history for release creation
|
|
|
|
- name: Ensure latest main branch
|
|
run: |
|
|
git fetch origin main
|
|
git reset --hard origin/main
|
|
echo "Current HEAD commit:"
|
|
git log -1 --oneline
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Create root pdm.lock file
|
|
run: |
|
|
# Create an empty pdm.lock file in the root
|
|
touch pdm.lock
|
|
|
|
- name: Install PDM
|
|
uses: pdm-project/setup-pdm@v3
|
|
with:
|
|
python-version: "3.11"
|
|
cache: true
|
|
|
|
- name: Set version
|
|
id: set-version
|
|
run: |
|
|
echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
|
|
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Verify version consistency
|
|
run: |
|
|
# Install toml parser
|
|
pip install toml
|
|
|
|
# Verify version matches using script (exits with error if mismatch)
|
|
python ${GITHUB_WORKSPACE}/.github/scripts/get_pyproject_version.py \
|
|
${GITHUB_WORKSPACE}/${{ inputs.package_dir }}/pyproject.toml \
|
|
${{ inputs.version }}
|
|
|
|
- name: Initialize PDM in package directory
|
|
run: |
|
|
# Make sure we're working with a properly initialized PDM project
|
|
cd ${{ inputs.package_dir }}
|
|
|
|
# Create pdm.lock if it doesn't exist
|
|
if [ ! -f "pdm.lock" ]; then
|
|
echo "No pdm.lock found, initializing PDM project..."
|
|
pdm lock
|
|
fi
|
|
|
|
- name: Build and publish
|
|
env:
|
|
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
run: |
|
|
cd ${{ inputs.package_dir }}
|
|
# Build with PDM
|
|
pdm build
|
|
|
|
echo "Publishing ${{ inputs.base_package_name }} ${VERSION}"
|
|
|
|
# Install and use twine directly instead of PDM publish
|
|
echo "Installing twine for direct publishing..."
|
|
pip install twine
|
|
|
|
echo "Publishing to PyPI using twine..."
|
|
TWINE_USERNAME="__token__" TWINE_PASSWORD="$PYPI_TOKEN" python -m twine upload dist/*
|