diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 207134b..e143c80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,8 @@ on: - 'README.md' branches: - main + tags: + - v*.* pull_request: branches: - main @@ -19,11 +21,11 @@ jobs: python-version: [ "3.10", "3.11", "3.12", "3.13" ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Set up Python id: setup-python - uses: actions/setup-python@v4 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} @@ -34,3 +36,30 @@ jobs: - name: Run tests run: | make test + release: + needs: test + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/plux + permissions: + id-token: write + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up Python + id: setup-python + uses: actions/setup-python@v6 + with: + python-version: '3.13' + + - name: Build release + run: make dist + + - name: List artifacts + run: ls -lah dist/ + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index e60091a..f72ab41 100644 --- a/.gitignore +++ b/.gitignore @@ -135,3 +135,6 @@ venv.bak/ # don't ignore build package !plux/build + +# Ignore dynamically generated version.py +plux/version.py \ No newline at end of file diff --git a/plux/__init__.py b/plux/__init__.py index 9a85e65..c665258 100644 --- a/plux/__init__.py +++ b/plux/__init__.py @@ -14,11 +14,10 @@ plugin, ) from plux.runtime.manager import PluginContainer, PluginManager +from plux.version import __version__ name = "plux" -__version__ = "1.14.0" - __all__ = [ "FunctionPlugin", "Plugin", @@ -34,4 +33,5 @@ "PluginSpecResolver", "PluginType", "plugin", + "__version__" ] diff --git a/pyproject.toml b/pyproject.toml index ca6a9e9..42cab61 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ['hatchling'] +requires = ['hatchling', 'hatch-vcs'] build-backend = "hatchling.build" [project] @@ -35,8 +35,11 @@ dev = [ "ruff==0.9.1", ] +[tool.hatch.build.hooks.vcs] +version-file = "plux/version.py" + [tool.hatch.version] -path = "plux/__init__.py" +source = "vcs" [tool.ruff] line-length = 110