diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..72c266b --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,51 @@ +name: Publish to PyPI + +on: + push: + tags: + - 'v*' # Triggers on version tags like v1.0.0, v0.1.2, etc. + +jobs: + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/polymathic-aion + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch full history for setuptools_scm + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build + + - name: Build package + run: python -m build + + - name: Verify version matches tag + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/v} + PACKAGE_VERSION=$(python -c "import setuptools_scm; print(setuptools_scm.get_version())") + echo "Tag version: $TAG_VERSION" + echo "Package version: $PACKAGE_VERSION" + if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then + echo "Version mismatch! Tag: $TAG_VERSION, Package: $PACKAGE_VERSION" + exit 1 + fi + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + # This action uses OIDC trusted publishing - no API tokens needed! + # Just configure your PyPI project to trust this GitHub repository diff --git a/pyproject.toml b/pyproject.toml index a6948ce..ec2ba53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=61"] +requires = ["setuptools>=61", "setuptools_scm>=8.0"] build-backend = "setuptools.build_meta" [project] name = "aion" -version = "0.0.1" +dynamic = ["version"] description = "AstronomIcal Omnimodal Network" requires-python = ">=3.10" dependencies = [ @@ -43,3 +43,9 @@ ignore = ["F722"] [tool.setuptools.packages.find] include = ["aion*"] # Only include the 'aion' package and its subpackages + +[tool.setuptools_scm] +# This section configures setuptools_scm +# It will use git tags to determine version numbers +# If no tags exist, it will use 0.1.dev0+g +fallback_version = "0.1.dev0"