Skip to content

Commit c5bab88

Browse files
msch-nutrientclaude
andcommitted
Add Python Semantic Release for automated version management
- Add python-semantic-release dependency via pixi - Configure PSR in pyproject.toml with version tracking and changelog generation - Update release workflow to use manual dispatch with patch/minor/major options - Run full test suite (linting, type checking, unit tests, integration tests) before release - Use pixi for package management in GitHub Actions - Implement PSR for automated version bumping and tagging - Maintain PyPI trusted publishing for secure releases 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 803c2fc commit c5bab88

File tree

4 files changed

+1401
-100
lines changed

4 files changed

+1401
-100
lines changed

.github/workflows/release.yml

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,84 @@
11
name: Release
22

33
on:
4-
release:
5-
types: [created]
4+
workflow_dispatch:
5+
inputs:
6+
level:
7+
description: 'Version level to bump'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
615

716
jobs:
8-
deploy:
17+
release:
918
runs-on: ubuntu-latest
10-
19+
concurrency: release
20+
permissions:
21+
id-token: write
22+
contents: write
23+
1124
steps:
1225
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
token: ${{ secrets.GITHUB_TOKEN }}
1329

1430
- name: Set up Python
1531
uses: actions/setup-python@v5
1632
with:
1733
python-version: '3.12'
1834

19-
- name: Install dependencies
35+
- name: Cache pip dependencies
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.cache/pip
39+
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
40+
restore-keys: |
41+
${{ runner.os }}-pip-
42+
43+
- name: Install Pixi
44+
uses: prefix-dev/setup-pixi@v0.8.1
45+
with:
46+
pixi-version: v0.29.0
47+
48+
- name: Run linting with ruff
2049
run: |
21-
python -m pip install --upgrade pip
22-
pip install -e ".[dev]"
50+
pixi run python -m ruff check .
51+
pixi run python -m ruff format --check .
52+
53+
- name: Run type checking with mypy
54+
run: pixi run python -m mypy src tests
55+
56+
- name: Run unit tests with pytest
57+
run: pixi run python -m pytest tests/unit/ -v --cov=nutrient_dws --cov-report=xml --cov-report=term
58+
59+
- name: Run integration tests
60+
if: github.repository == 'jdrhyne/nutrient-dws-client-python'
61+
run: |
62+
pixi run python -c "
63+
import os
64+
with open('tests/integration/integration_config.py', 'w') as f:
65+
f.write(f'API_KEY = \"{os.environ[\"NUTRIENT_DWS_API_KEY\"]}\"\n')
66+
"
67+
pixi run python -m pytest tests/integration/ -v
68+
env:
69+
NUTRIENT_DWS_API_KEY: ${{ secrets.NUTRIENT_DWS_API_KEY }}
2370

2471
- name: Build package
25-
run: python -m build
72+
run: pixi run python -m build
2673

27-
- name: Publish to PyPI
74+
- name: Check package with twine
75+
run: pixi run twine check dist/*
76+
77+
- name: Semantic Release
78+
run: pixi run python -m semantic_release version --${{ inputs.level }}
2879
env:
29-
TWINE_USERNAME: __token__
30-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
31-
run: twine upload dist/*
80+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Publish to PyPI
83+
uses: pypa/gh-action-pypi-publish@release/v1
84+
if: github.ref == 'refs/heads/main'

0 commit comments

Comments
 (0)