Skip to content

Commit 4d2e2b9

Browse files
dccoteclaude
andcommitted
Add CI/CD workflows and modernize Python version requirements
- Add GitHub Actions CI workflow: runs tests on push/PR for Python 3.10-3.12 - Add publish workflow: auto-publish to PyPI and create GitHub Release on tag push - Update requires-python to >=3.10 and classifiers to match Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 55c00fd commit 4d2e2b9

File tree

3 files changed

+135
-2
lines changed

3 files changed

+135
-2
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, macos-latest]
16+
python-version: ["3.10", "3.11", "3.12"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # needed for setuptools-scm
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -e ".[postgresql]"
32+
33+
- name: Run tests
34+
working-directory: dcclab/tests
35+
run: python -m unittest discover -v

.github/workflows/publish.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Publish to PyPI & GitHub Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+"
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # needed for setuptools-scm
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.12"
24+
25+
- name: Install build tools
26+
run: pip install build
27+
28+
- name: Build package
29+
run: python -m build
30+
31+
- name: Verify version matches tag
32+
run: |
33+
TAG=${GITHUB_REF#refs/tags/}
34+
PKG_VERSION=$(python -c "from setuptools_scm import get_version; print(get_version())")
35+
echo "Tag: $TAG, Package version: $PKG_VERSION"
36+
if [ "$TAG" != "$PKG_VERSION" ]; then
37+
echo "::error::Tag $TAG does not match package version $PKG_VERSION"
38+
exit 1
39+
fi
40+
41+
- name: Upload build artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: dist
45+
path: dist/
46+
47+
pypi:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
environment: pypi
51+
permissions:
52+
id-token: write
53+
steps:
54+
- name: Download build artifacts
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: dist
58+
path: dist/
59+
60+
- name: Publish to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
63+
github-release:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
steps:
69+
- uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Download build artifacts
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: dist
77+
path: dist/
78+
79+
- name: Generate release notes
80+
id: notes
81+
run: |
82+
TAG=${GITHUB_REF#refs/tags/}
83+
PREV_TAG=$(git tag --sort=-v:refname | grep -A1 "^${TAG}$" | tail -1)
84+
if [ "$PREV_TAG" != "$TAG" ] && [ -n "$PREV_TAG" ]; then
85+
echo "## Changes since ${PREV_TAG}" > notes.md
86+
git log --pretty=format:"- %s" ${PREV_TAG}..${TAG} >> notes.md
87+
else
88+
echo "## Release ${TAG}" > notes.md
89+
fi
90+
91+
- name: Create GitHub Release
92+
uses: softprops/action-gh-release@v2
93+
with:
94+
body_path: notes.md
95+
files: dist/*
96+
generate_release_notes: false

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "A Python library to read, transform, manipulate image and manage databases"
99
readme = "README.md"
1010
license = "MIT"
11-
requires-python = ">=3"
11+
requires-python = ">=3.10"
1212
authors = [
1313
{ name = "Daniel Côté", email = "dccote@cervo.ulaval.ca" },
1414
{ name = "Gabriel Genest" },
@@ -24,7 +24,9 @@ classifiers = [
2424
"Topic :: Education",
2525
"Programming Language :: Python",
2626
"Programming Language :: Python :: 3",
27-
"Programming Language :: Python :: 3.7",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
2830
"Operating System :: OS Independent",
2931
]
3032
dependencies = [

0 commit comments

Comments
 (0)