Skip to content

Commit d5b3f3f

Browse files
abrichrclaude
andauthored
ci: switch to python-semantic-release for automated versioning (#3)
Conventional commit PR titles (feat:, fix:, etc.) auto-bump version, tag, publish to PyPI, and create GitHub Releases on merge to main. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 41afded commit d5b3f3f

File tree

2 files changed

+63
-8
lines changed

2 files changed

+63
-8
lines changed

.github/workflows/publish.yml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,60 @@
1-
name: Publish to PyPI
1+
name: Release and PyPI Publish
22

33
on:
44
push:
5-
tags:
6-
- "v*"
5+
branches:
6+
- main
77

88
jobs:
9-
publish:
9+
release:
1010
runs-on: ubuntu-latest
1111
environment: release
12+
concurrency: release
1213
permissions:
1314
id-token: write
15+
contents: write
16+
1417
steps:
15-
- uses: actions/checkout@v4
16-
- uses: astral-sh/setup-uv@v4
17-
- run: uv build
18-
- uses: pypa/gh-action-pypi-publish@release/v1
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
token: ${{ secrets.ADMIN_TOKEN }}
23+
24+
- name: Check if should skip
25+
id: check_skip
26+
run: |
27+
if [ "$(git log -1 --pretty=format:'%an')" = "semantic-release" ]; then
28+
echo "skip=true" >> $GITHUB_OUTPUT
29+
fi
30+
31+
- name: Set up Python
32+
if: steps.check_skip.outputs.skip != 'true'
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.12'
36+
37+
- name: Install uv
38+
if: steps.check_skip.outputs.skip != 'true'
39+
uses: astral-sh/setup-uv@v4
40+
41+
- name: Python Semantic Release
42+
if: steps.check_skip.outputs.skip != 'true'
43+
id: release
44+
uses: python-semantic-release/python-semantic-release@v9.15.2
45+
with:
46+
github_token: ${{ secrets.ADMIN_TOKEN }}
47+
48+
- name: Build package
49+
if: steps.check_skip.outputs.skip != 'true' && steps.release.outputs.released == 'true'
50+
run: uv build
51+
52+
- name: Publish to PyPI
53+
if: steps.check_skip.outputs.skip != 'true' && steps.release.outputs.released == 'true'
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
56+
- name: Publish to GitHub Releases
57+
if: steps.check_skip.outputs.skip != 'true' && steps.release.outputs.released == 'true'
58+
uses: python-semantic-release/publish-action@v9.15.2
59+
with:
60+
github_token: ${{ secrets.ADMIN_TOKEN }}

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@ packages = ["openadapt_types"]
4545

4646
[tool.pytest.ini_options]
4747
testpaths = ["tests"]
48+
49+
[tool.semantic_release]
50+
version_toml = ["pyproject.toml:project.version"]
51+
commit_message = "chore: release {version}"
52+
major_on_zero = false
53+
54+
[tool.semantic_release.branches.main]
55+
match = "main"
56+
57+
[tool.semantic_release.commit_parser_options]
58+
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "style", "test"]
59+
minor_tags = ["feat"]
60+
patch_tags = ["fix", "perf"]

0 commit comments

Comments
 (0)