Skip to content

Commit 91e8298

Browse files
committed
AP-605: build/publish distribution packages
* use [`setuptools_scm`](https://setuptools-scm.readthedocs.io/en/latest/) for tracking package versions. * builds distribution packages published as github artifacts on merge to main. * builds and publishes packages to pypi on tagging of a new release.
1 parent 14a272b commit 91e8298

3 files changed

Lines changed: 103 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build dev package distributions
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- closed
9+
10+
jobs:
11+
build:
12+
if: github.event.pull_request.merged == true
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
# we need to fetch the full repo history to use setuptools_scm
17+
- uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v7
23+
with:
24+
version: "0.10.7"
25+
python-version: "3.14"
26+
enable-cache: true
27+
28+
- name: Sync dependencies
29+
run: uv sync --all-extras --dev
30+
31+
- name: Build Python package
32+
run: uv build
33+
34+
- name: Upload package distributions as artifact
35+
uses: actions/upload-artifact@v7
36+
with:
37+
name: python-package-distributions
38+
path: |
39+
dist/
40+
!dist/.gitignore

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Push Release Tags
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
# we need to fetch the full repo history to use setuptools_scm
14+
- uses: actions/checkout@v6
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v7
20+
with:
21+
version: "0.10.7"
22+
python-version: "3.14"
23+
enable-cache: true
24+
25+
- name: Sync dependencies
26+
run: uv sync --all-extras --dev
27+
28+
- name: Build Python package
29+
run: uv build
30+
31+
- name: Upload package distributions as artifact
32+
uses: actions/upload-artifact@v7
33+
with:
34+
name: python-package-distributions
35+
path: |
36+
dist/
37+
!dist/.gitignore
38+
39+
40+
pypi-publish:
41+
needs: build
42+
runs-on: ubuntu-latest
43+
environment:
44+
name: pypi
45+
url: https://pypi.org/p/python-tind-client
46+
permissions:
47+
id-token: write
48+
steps:
49+
- uses: actions/checkout@v6
50+
51+
- name: Download built package distributions
52+
uses: actions/download-artifact@v8
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
- name: Public package distributions to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[build-system]
2-
requires = ["setuptools>=80"]
2+
requires = ["setuptools>=80", "setuptools-scm[simple]>=9.2"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "python-tind-client"
7-
version = "0.2.1"
7+
dynamic = ["version"]
88
description = "Python library for interacting with the TIND DA API"
99
readme = "README.md"
10-
license = { file = "LICENSE" }
10+
license-files = ["LICENSE"]
1111
authors = [
1212
{ name = "Jason Raitz", email = "raitz@berkeley.edu" },
1313
{ name = "maría a. matienzo", email = "matienzo@berkeley.edu" },
@@ -63,3 +63,5 @@ style = "sphinx"
6363

6464
[tool.pylint.format]
6565
max-line-length = 100
66+
67+
[tool.setuptools_scm]

0 commit comments

Comments
 (0)