From 8cfe505ef1d0c676e238e00e227c70cb8e664d64 Mon Sep 17 00:00:00 2001 From: tgross03 Date: Fri, 22 Aug 2025 13:51:56 +0200 Subject: [PATCH] Add publish workflow --- .github/release-drafter.yml | 43 ++++++++++++++++++++++ .github/workflows/pypi-publish.yml | 59 ++++++++++++++++++++++++++++++ pyproject.toml | 24 ++---------- 3 files changed, 105 insertions(+), 21 deletions(-) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/pypi-publish.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..4706511 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,43 @@ +categories: + - title: "New features" + labels: + - "new functionality" + - "enhancement" + - title: "API Changes" + labels: + - "Breaking change" + - "API change" + - title: "Data Model Changes" + labels: + - "data model change" + - title: "Bug Fixes" + labels: + - "bug" + - "fix" + - title: "Refactoring and Optimization" + labels: + - "optimization" + - "refactoring" + - title: "Maintenance" + labels: + - "build" + - "documentation" + - "installation" + - "maintenance" +change-template: "- $TITLE (#$NUMBER) @$AUTHOR" +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +template: | + + ## Summary + + ... + + ## Contributors + + $CONTRIBUTORS + + ## What has changed since $PREVIOUS_TAG + + Pull-requests containing changes of multiple nature are repeated. + + $CHANGES diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 0000000..e0cfac8 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,59 @@ +name: Build Python Package + +on: + push: + workflow_dispatch: + release: + types: + - published + +jobs: + dist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hynek/build-and-inspect-python-package@v2 + with: + path: . + + distlong: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: astral-sh/setup-uv@v6 + + - name: Build SDist and wheel + run: uvx --from build pyproject-build + + - uses: actions/upload-artifact@v4 + with: + name: Packages-distlong-${{ github.job }} + path: dist/* + + - name: Check metadata + run: uvx twine check ./dist/* + + publishtrusted: + needs: [ dist ] + environment: pypi + permissions: + id-token: write + attestations: write + contents: read + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + + - name: Generate artifact attestation for sdist and wheel + uses: actions/attest-build-provenance@v2 + with: + subject-path: "./dist/*" + + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index 71d21b9..f62cc2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,23 +48,11 @@ dependencies = [ [project.optional-dependencies] -pyvisgen = [ - "pyvisgen" -] +pyvisgen = ["pyvisgen"] [dependency-groups] -tests = [ - "h5py", - "pytest >= 7.0", - "pytest-cov", - "tomli", -] -dev = [ - "pre-commit", - "ipython", - "jupyter", - {include-group = "tests"}, -] +tests = ["h5py", "pytest >= 7.0", "pytest-cov", "tomli"] +dev = ["pre-commit", "ipython", "jupyter", { include-group = "tests" }] [project.urls] repository = "https://github.com/radionets-project/pyvisgrid" @@ -78,9 +66,3 @@ version-file = "pyvisgrid/_version.py" [tool.hatch.build.targets.wheel] packages = ["."] - -# as long as we still directly install -# pyvisgen from git we need to set this -# to true -[tool.hatch.metadata] -allow-direct-references = true