mirror of
https://github.com/datalab-to/chandra.git
synced 2025-11-29 00:23:12 +00:00
43 lines
1.4 KiB
YAML
43 lines
1.4 KiB
YAML
name: Python package
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Extract and verify version
|
|
id: version
|
|
run: |
|
|
# Get the tag name (e.g., v1.2.3)
|
|
TAG_VERSION="${GITHUB_REF#refs/tags/}"
|
|
echo "Tag version: $TAG_VERSION"
|
|
|
|
# Extract version from pyproject.toml (e.g., 1.2.3)
|
|
PYPROJECT_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
|
|
echo "pyproject.toml version: $PYPROJECT_VERSION"
|
|
|
|
# Compare versions (tag should be v{pyproject_version})
|
|
if [ "$TAG_VERSION" != "v$PYPROJECT_VERSION" ]; then
|
|
echo "Error: Tag version ($TAG_VERSION) does not match pyproject.toml version (v$PYPROJECT_VERSION)"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Version verification passed!"
|
|
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
|
|
- name: Build package
|
|
run: |
|
|
uv build
|
|
- name: Publish package
|
|
env:
|
|
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
run: |
|
|
uv publish --token "$PYPI_TOKEN" |