Skip to content

Commit 95844d9

Browse files
committed
pypi integration
1 parent 2c88959 commit 95844d9

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish to PyPI
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
id-token: write
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.12"
16+
- run: pip install build
17+
- run: python -m build
18+
- uses: pypa/gh-action-pypi-publish@release/v1

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ VENV = venv
22
PYTHON = $(VENV)/bin/python
33
PIP = $(VENV)/bin/pip
44

5-
.PHONY: venv install test clean publish
5+
.PHONY: venv install test clean publish release minor
66

77
venv:
88
python3 -m venv $(VENV)
@@ -18,5 +18,23 @@ publish:
1818
$(PYTHON) -m build
1919
. .env && $(PYTHON) -m twine upload dist/* -u __token__ -p $$PYPI_API_KEY
2020

21+
_current_version = $(shell grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
22+
_major = $(word 1,$(subst ., ,$(_current_version)))
23+
_minor = $(word 2,$(subst ., ,$(_current_version)))
24+
_patch = $(word 3,$(subst ., ,$(_current_version)))
25+
26+
release:
27+
$(eval VERSION := $(or $(v),$(if $(filter minor,$(MAKECMDGOALS)),$(_major).$(shell echo $$(($(_minor)+1))).0,$(_major).$(_minor).$(shell echo $$(($(_patch)+1))))))
28+
@echo "Releasing v$(VERSION) (was $(_current_version))..."
29+
sed -i '' 's/^version = ".*"/version = "$(VERSION)"/' pyproject.toml
30+
git add pyproject.toml
31+
git commit -m "bump version to $(VERSION)"
32+
git tag "v$(VERSION)"
33+
git push origin HEAD "v$(VERSION)"
34+
gh release create "v$(VERSION)" --generate-notes --title "v$(VERSION)"
35+
36+
minor: release
37+
@true
38+
2139
clean:
2240
rm -rf $(VENV) *.egg-info dist/

0 commit comments

Comments
 (0)