Skip to content

Commit 0071a79

Browse files
authored
add tag-based release workflow (#36)
1 parent ee3fa1a commit 0071a79

5 files changed

Lines changed: 46 additions & 18 deletions

File tree

.github/workflows/build.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- 'docs/**'
88
branches:
99
- main
10+
tags:
11+
- 'v*.*'
1012
pull_request:
1113
branches:
1214
- main
@@ -22,11 +24,11 @@ jobs:
2224
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2325
steps:
2426
- name: Checkout
25-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2628

2729
- name: Set up Python
2830
id: setup-python
29-
uses: actions/setup-python@v4
31+
uses: actions/setup-python@v5
3032
with:
3133
python-version: ${{ matrix.python-version }}
3234

@@ -45,3 +47,32 @@ jobs:
4547
- name: Report coverage
4648
run: |
4749
make coveralls
50+
51+
release:
52+
needs: test
53+
runs-on: ubuntu-latest
54+
environment:
55+
name: pypi
56+
url: https://pypi.org/p/rolo
57+
permissions:
58+
id-token: write
59+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
66+
- name: Set up Python
67+
uses: actions/setup-python@v5
68+
with:
69+
python-version: "3.13"
70+
71+
- name: Build release
72+
run: make dist
73+
74+
- name: List artifacts
75+
run: ls -lah dist/
76+
77+
- name: Publish package distributions to PyPI
78+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ venv.bak/
135135

136136
# sqlite database files created by examples
137137
*.db
138+
139+
# Hatch VCS hook generates this file during build
140+
rolo/version.py

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ venv: $(VENV_ACTIVATE)
88

99
$(VENV_ACTIVATE): pyproject.toml
1010
test -d .venv || $(VENV_BIN) .venv
11-
$(VENV_RUN); pip install --upgrade pip setuptools wheel
11+
$(VENV_RUN); pip install --upgrade pip
1212
$(VENV_RUN); pip install -e .[dev]
1313
touch $(VENV_DIR)/bin/activate
1414

pyproject.toml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "rolo"
77
authors = [
88
{ name = "LocalStack Contributors", email = "info@localstack.cloud" }
99
]
10-
version = "0.8.0"
1110
description = "A Python framework for building HTTP-based server applications"
1211
dependencies = [
1312
"requests>=2.20",
@@ -26,7 +25,7 @@ classifiers = [
2625
"Programming Language :: Python :: 3.13",
2726
"Topic :: Software Development :: Libraries"
2827
]
29-
dynamic = ["readme"]
28+
dynamic = ["readme", "version"]
3029

3130

3231
[project.optional-dependencies]
@@ -48,18 +47,11 @@ docs = [
4847
"myst_parser",
4948
]
5049

51-
[tool.setuptools]
52-
include-package-data = false
50+
[tool.hatch.version]
51+
source = "vcs"
5352

54-
[tool.setuptools.dynamic]
55-
readme = {file = ["README.md"], content-type = "text/markdown"}
56-
57-
[tool.setuptools.packages.find]
58-
include = ["rolo*"]
59-
exclude = ["tests*"]
60-
61-
[tool.setuptools.package-data]
62-
"*" = ["*.md"]
53+
[tool.hatch.build.hooks.vcs]
54+
version-file = "rolo/version.py"
6355

6456
[tool.black]
6557
line_length = 100

rolo/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .response import Response
33
from .routing.resource import Resource, resource
44
from .routing.router import Router, route
5+
from .version import __version__
56

67
__all__ = [
78
"route",
@@ -10,4 +11,5 @@
1011
"Router",
1112
"Response",
1213
"Request",
14+
"__version__",
1315
]

0 commit comments

Comments
 (0)