From 8485423d61300d9ac043f8b89b811144e3ef879c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20A=2E=20Matienzo?= Date: Mon, 20 Apr 2026 15:53:09 -0700 Subject: [PATCH 1/2] AP-605: build pypi packages * builds pypi packages with versioning managed by setuptools_scm --- .github/workflows/build.yml | 59 +++++++++++++++++++++++++++++++++++++ pyproject.toml | 8 +++-- 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..726bbe4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,59 @@ +name: Build and publish dev release to PyPI + +on: + pull_request: + branches: + - main + # types: + # - closed + +jobs: + build: + # if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "0.10.7" + python-version: "3.14" + enable-cache: true + - name: Sync dependencies + run: uv sync --all-extras --dev + - name: Build Python package + run: | + uv build + + - name: Upload package distributions as artifact + uses: actions/upload-artifact@v7 + with: + name: python-package-distributions + path: | + dist/ + !dist/.gitignore + + testpypi-publish: + needs: build + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/python-tind-client + permissions: + id-token: write + steps: + - uses: actions/checkout@v6 + + - name: Download built package distributions + uses: actions/download-artifact@v8 + with: + name: python-package-distributions + path: dist/ + + - name: Public package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/pyproject.toml b/pyproject.toml index 4d92ccf..e8bec64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,13 @@ [build-system] -requires = ["setuptools>=80"] +requires = ["setuptools>=80", "setuptools-scm[simple]>=9.2"] build-backend = "setuptools.build_meta" [project] name = "python-tind-client" -version = "0.2.1" +dynamic = ["version"] description = "Python library for interacting with the TIND DA API" readme = "README.md" -license = { file = "LICENSE" } +license-files = ["LICENSE"] authors = [ { name = "Jason Raitz", email = "raitz@berkeley.edu" }, { name = "marĂ­a a. matienzo", email = "matienzo@berkeley.edu" }, @@ -63,3 +63,5 @@ style = "sphinx" [tool.pylint.format] max-line-length = 100 + +[tool.setuptools_scm] From 7a2055e98eb4235aa22fe834d5e4943ad9cac6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20A=2E=20Matienzo?= Date: Mon, 20 Apr 2026 16:36:58 -0700 Subject: [PATCH 2/2] update build/release workflows --- .github/workflows/build.yml | 31 ++++--------------- .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ pyproject.toml | 1 - 3 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 726bbe4..f98714a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build and publish dev release to PyPI +name: Build dev package distributions on: pull_request: @@ -12,6 +12,8 @@ jobs: # if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: + + # we need to fetch the full repo history to use setuptools_scm - uses: actions/checkout@v6 with: fetch-depth: 0 @@ -22,11 +24,12 @@ jobs: version: "0.10.7" python-version: "3.14" enable-cache: true + - name: Sync dependencies run: uv sync --all-extras --dev + - name: Build Python package - run: | - uv build + run: uv build - name: Upload package distributions as artifact uses: actions/upload-artifact@v7 @@ -35,25 +38,3 @@ jobs: path: | dist/ !dist/.gitignore - - testpypi-publish: - needs: build - runs-on: ubuntu-latest - environment: - name: testpypi - url: https://test.pypi.org/p/python-tind-client - permissions: - id-token: write - steps: - - uses: actions/checkout@v6 - - - name: Download built package distributions - uses: actions/download-artifact@v8 - with: - name: python-package-distributions - path: dist/ - - - name: Public package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..aaf4894 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Push Release Tags + +on: + push: + tags: + - '**' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + # we need to fetch the full repo history to use setuptools_scm + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "0.10.7" + python-version: "3.14" + enable-cache: true + + - name: Sync dependencies + run: uv sync --all-extras --dev + + - name: Build Python package + run: uv build + + - name: Upload package distributions as artifact + uses: actions/upload-artifact@v7 + with: + name: python-package-distributions + path: | + dist/ + !dist/.gitignore + + + pypi-publish: + needs: build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/python-tind-client + permissions: + id-token: write + steps: + - uses: actions/checkout@v6 + + - name: Download built package distributions + uses: actions/download-artifact@v8 + with: + name: python-package-distributions + path: dist/ + + - name: Public package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index e8bec64..750cc7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,4 +64,3 @@ style = "sphinx" [tool.pylint.format] max-line-length = 100 -[tool.setuptools_scm]