Skip to content

Commit 713dad0

Browse files
author
Drew Yang
committed
ci: 🎨 improve pyproject.toml and release flow
1 parent f484bf2 commit 713dad0

File tree

2 files changed

+54
-91
lines changed

2 files changed

+54
-91
lines changed

‎.github/workflows/release.yaml‎

Lines changed: 36 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,55 @@ name: Release
22
on:
33
workflow_dispatch:
44
jobs:
5-
build:
6-
runs-on: ubuntu-latest
7-
strategy:
8-
matrix:
9-
include:
10-
- py_ver: ["3.9", "3.10", "3.11", "3.12", "3.13"]
11-
env:
12-
PY_VER: ${{matrix.py_ver}}
13-
steps:
14-
- uses: actions/checkout@v4
15-
- uses: actions/setup-python@v5
16-
with:
17-
python-version: ${{matrix.py_ver}}
18-
- name: Build pip artifacts
19-
run: |
20-
DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
21-
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
22-
python3 -m pip install build
23-
python3 -m build .
24-
- name: Add pip artifacts
25-
uses: actions/upload-artifact@v4
26-
with:
27-
name: pip-datajoint-${{env.DJ_VERSION}}
28-
path: dist
29-
retention-days: 1
30-
publish-release:
31-
if: |
32-
github.event_name == 'push' &&
33-
startsWith(github.ref, 'refs/tags')
34-
needs: build
5+
build-release:
356
runs-on: ubuntu-latest
367
strategy:
378
matrix:
389
include:
3910
- py_ver: "3.9"
40-
distro: debian
41-
image: djbase
4211
env:
4312
PY_VER: ${{matrix.py_ver}}
44-
DISTRO: ${{matrix.distro}}
45-
IMAGE: ${{matrix.image}}
4613
TWINE_USERNAME: ${{secrets.twine_username}}
4714
TWINE_PASSWORD: ${{secrets.twine_password}}
48-
DOCKER_CLIENT_TIMEOUT: "120"
49-
COMPOSE_HTTP_TIMEOUT: "120"
50-
outputs:
51-
release_upload_url: ${{steps.create_gh_release.outputs.upload_url}}
5215
steps:
5316
- uses: actions/checkout@v4
5417
- name: Set up Python ${{matrix.py_ver}}
5518
uses: actions/setup-python@v5
5619
with:
5720
python-version: ${{matrix.py_ver}}
58-
- name: Determine package version
21+
# Merging build and release steps just for the simplicity,
22+
# since datajoint-python doesn't have platform specific dependencies or binaries,
23+
# and the build process is fairly fast, so removed upload/download artifacts
24+
- name: Build package
25+
run: |
26+
python -m pip install build
27+
python -m build .
28+
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
29+
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
30+
- name: Publish package
31+
run: |
32+
export HOST_UID=$(id -u)
33+
docker compose run --build --quiet-pull \
34+
-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \
35+
sh -c "pip install twine && python -m twine upload dist/*"
36+
- name: Login to DockerHub
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{secrets.docker_username}}
40+
password: ${{secrets.docker_password}}
41+
- name: Publish image
42+
run: |
43+
IMAGE=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Repository}}")
44+
TAG=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Tag}}")
45+
docker push "${IMAGE}:${TAG}"
46+
docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
47+
docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
48+
[ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "debian" ] \
49+
&& docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
50+
&& docker push "${IMAGE}:latest" \
51+
|| echo "skipping 'latest' tag..."
52+
# Make sure all above release targets are done first, then make a GH release
53+
- name: Make release notes
5954
run: |
6055
DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
6156
RELEASE_BODY=$(python -c \
@@ -76,15 +71,7 @@ jobs:
7671
body: ${{env.RELEASE_BODY}}
7772
prerelease: false
7873
draft: false
79-
- name: Fetch pip artifacts
80-
uses: actions/download-artifact@v4
81-
with:
82-
name: pip-datajoint-${{env.DJ_VERSION}}
83-
path: dist
84-
- name: Determine pip artifact paths
85-
run: |
86-
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
87-
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
74+
# Upload package as release assets
8875
- name: Upload pip wheel asset to release
8976
uses: actions/upload-release-asset@v1
9077
env:
@@ -103,34 +90,9 @@ jobs:
10390
asset_path: ${{env.DJ_SDIST_PATH}}
10491
asset_name: pip-datajoint-${{env.DJ_VERSION}}.tar.gz
10592
asset_content_type: application/gzip
106-
- name: Publish pip release
107-
run: |
108-
export HOST_UID=$(id -u)
109-
docker compose run --build --quiet-pull \
110-
-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \
111-
sh -c "pip install twine && python -m twine upload dist/*"
112-
- name: Login to DockerHub
113-
uses: docker/login-action@v3
114-
with:
115-
username: ${{secrets.docker_username}}
116-
password: ${{secrets.docker_password}}
117-
- name: Publish image
118-
run: |
119-
IMAGE=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Repository}}")
120-
TAG=$(docker images --filter "reference=datajoint/datajoint*" --format "{{.Tag}}")
121-
docker push "${IMAGE}:${TAG}"
122-
docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
123-
docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
124-
[ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "debian" ] \
125-
&& docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
126-
&& docker push "${IMAGE}:latest" \
127-
|| echo "skipping 'latest' tag..."
12893
# only release docs when a release is published
12994
call-publish-docs:
130-
if: |
131-
github.event_name == 'push' &&
132-
startsWith(github.ref, 'refs/tags')
133-
needs: publish-release
95+
needs: build-release
13496
runs-on: ubuntu-latest
13597
steps:
13698
- uses: ./.github/workflows/docs.yaml

‎pyproject.toml‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools>=60"]
3+
build-backend = "setuptools.build_meta"
4+
15
[project]
26
name = "datajoint"
37
# dynamically set in tools.setuptools.dynamic
@@ -57,11 +61,23 @@ classifiers = [
5761
"Intended Audience :: Science/Research",
5862
"Intended Audience :: Healthcare Industry",
5963
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
64+
"Topic :: Software Development :: Libraries :: Python Modules",
6065
"Topic :: Scientific/Engineering",
6166
"Topic :: Scientific/Engineering :: Bio-Informatics",
6267
"Topic :: Scientific/Engineering :: Neuroscience", # Not standard, but just in case
6368
]
6469

70+
[project.urls]
71+
Homepage = "https://datajoint.com/docs"
72+
Documentation = "https://datajoint.com/docs"
73+
Repository = "https://github.com/datajoint/datajoint-python"
74+
"Bug Tracker" = "https://github.com/datajoint/datajoint-python/issues"
75+
"Release Notes" = "https://github.com/datajoint/datajoint-python/releases"
76+
77+
[project.entry-points."console_scripts"]
78+
dj = "datajoint.cli:cli"
79+
datajoint = "datajoint.cli:cli"
80+
6581
[project.optional-dependencies]
6682
test = [
6783
"pytest",
@@ -78,23 +94,8 @@ dev = [
7894
"pytest-cov",
7995
]
8096

81-
[project.urls]
82-
Homepage = "https://datajoint.com/docs"
83-
Documentation = "https://datajoint.com/docs"
84-
Repository = "https://github.com/datajoint/datajoint-python"
85-
"Bug Tracker" = "https://github.com/datajoint/datajoint-python/issues"
86-
"Release Notes" = "https://github.com/datajoint/datajoint-python/releases"
87-
88-
[project.entry-points."console_scripts"]
89-
dj = "datajoint.cli:cli"
90-
datajoint = "datajoint.cli:cli"
91-
92-
[build-system]
93-
requires = [
94-
"setuptools>=60",
95-
"setuptools-scm>=8.0"
96-
]
97-
build-backend = "setuptools.build_meta"
97+
[tool.isort]
98+
profile = "black"
9899

99100
[tool.setuptools]
100101
packages = ["datajoint"]

0 commit comments

Comments
 (0)