From 09ce4ccc4ea8ab6dedbdefe9810c0d1c0d2a788a Mon Sep 17 00:00:00 2001 From: nicosammito Date: Tue, 18 Aug 2026 22:01:57 +0200 Subject: [PATCH] feat: add build and publish workflows for package management --- .github/workflows/build.yml | 25 +++++++++++++++++++++++ .github/workflows/publish.yml | 38 +++++++++++++++++++++++++++++++++++ pyproject.toml | 7 +++++++ 3 files changed, 70 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e44a8dc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build package + +on: + push: + +jobs: + python: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v6 + - name: Set up uv + uses: astral-sh/setup-uv@v6 + with: + python-version: '3.12' + - name: Install dependencies + run: uv sync --extra dev + - name: Run tests + run: uv run pytest + - name: Build package + run: uv build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2f794d1 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Publish package + +on: + push: + tags: + - '*' + +jobs: + pypi: + runs-on: ubuntu-latest + + environment: packages + + permissions: + # Required for PyPI trusted publishing (OIDC); no API token needed. + id-token: write + + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v6 + - name: Set up uv + uses: astral-sh/setup-uv@v6 + with: + python-version: '3.12' + - name: Install dependencies + run: uv sync --extra dev + - name: Set version + # The git tag (minus any leading "v") becomes the package version. + run: uv version "${GITHUB_REF_NAME#v}" + - name: Run tests + run: uv run pytest + - name: Build package + run: uv build + - name: Publish package + run: uv publish --trusted-publishing always diff --git a/pyproject.toml b/pyproject.toml index 22684a3..a38467f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,13 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = ["src/cadtopo"] +[tool.hatch.build.targets.sdist] +only-include = [ + "src", + "README.md", + "LICENSE", +] + [tool.pytest.ini_options] testpaths = ["tests"] addopts = "-ra"