Skip to content

Commit 0ddc29f

Browse files
committed
chore: bump build setuptools and add stable publish workflow
Align dev.toml with the setuptools floor already on pyproject.toml and add the GitHub Actions workflow that publishes the stable package to PyPI on pushes to main.
1 parent 2243918 commit 0ddc29f

2 files changed

Lines changed: 120 additions & 1 deletion

File tree

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Publish MailThunder Stable to PyPI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths-ignore:
7+
- '**.md'
8+
- 'docs/**'
9+
- '.github/**'
10+
11+
permissions:
12+
contents: write
13+
14+
concurrency:
15+
group: publish-stable
16+
cancel-in-progress: false
17+
18+
jobs:
19+
test:
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
fail-fast: true
23+
matrix:
24+
os: [ ubuntu-latest, windows-latest, macos-latest ]
25+
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install pytest
39+
pip install -e .
40+
41+
- name: Run tests
42+
run: python -m pytest test/unit_test/ --ignore=test/unit_test/manual_test -v
43+
44+
publish:
45+
needs: test
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
ref: main
51+
token: ${{ secrets.GITHUB_TOKEN }}
52+
fetch-depth: 0
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: "3.12"
58+
59+
- name: Install build tooling
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install build twine tomli tomli-w
63+
64+
- name: Bump patch version in pyproject.toml
65+
id: bump
66+
run: |
67+
python - <<'PY'
68+
import os
69+
import tomli
70+
import tomli_w
71+
72+
path = "pyproject.toml"
73+
with open(path, "rb") as handle:
74+
data = tomli.load(handle)
75+
76+
current = data["project"]["version"]
77+
major, minor, patch = (int(part) for part in current.split("."))
78+
patch += 1
79+
new_version = f"{major}.{minor}.{patch}"
80+
data["project"]["version"] = new_version
81+
82+
with open(path, "wb") as handle:
83+
tomli_w.dump(data, handle)
84+
85+
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as out:
86+
out.write(f"old_version={current}\n")
87+
out.write(f"new_version={new_version}\n")
88+
89+
print(f"Bumped version: {current} -> {new_version}")
90+
PY
91+
92+
- name: Build distributions
93+
run: python -m build
94+
95+
- name: Publish to PyPI
96+
env:
97+
TWINE_USERNAME: __token__
98+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
99+
run: python -m twine upload --non-interactive dist/*
100+
101+
- name: Commit and tag version bump
102+
run: |
103+
git config user.name "github-actions[bot]"
104+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
105+
git add pyproject.toml
106+
git commit -m "chore: bump stable version to ${{ steps.bump.outputs.new_version }}"
107+
git tag "v${{ steps.bump.outputs.new_version }}"
108+
git push origin main
109+
git push origin "v${{ steps.bump.outputs.new_version }}"
110+
111+
- name: Create GitHub Release
112+
env:
113+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
run: |
115+
gh release create "v${{ steps.bump.outputs.new_version }}" \
116+
--title "v${{ steps.bump.outputs.new_version }}" \
117+
--notes "Automated stable release for v${{ steps.bump.outputs.new_version }}. Published to PyPI as \`je-mail-thunder==${{ steps.bump.outputs.new_version }}\`." \
118+
--target main \
119+
dist/*

dev.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rename to dev version
22
# This is dev version
33
[build-system]
4-
requires = ["setuptools>=61.0"]
4+
requires = ["setuptools>=82.0.1"]
55
build-backend = "setuptools.build_meta"
66

77
[project]

0 commit comments

Comments
 (0)