Skip to content

Commit c19f489

Browse files
Configure release to PyPI (#30)
* Configure release to PyPI * betterproto -> betterproto2 * Update version * Format code * Condition to update workflow * Move distributing condition
1 parent 881bd6e commit c19f489

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+916
-895
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,30 @@ on:
1212

1313
jobs:
1414
packaging:
15+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
1516
name: Distribution
1617
runs-on: ubuntu-latest
18+
19+
permissions:
20+
id-token: write
21+
22+
environment:
23+
name: pypi
24+
url: https://pypi.org/p/betterproto2
25+
1726
steps:
18-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
28+
1929
- name: Set up Python 3.8
2030
uses: actions/setup-python@v4
2131
with:
22-
python-version: 3.8
32+
python-version: "3.8"
33+
2334
- name: Install poetry
2435
run: python -m pip install poetry
36+
2537
- name: Build package
2638
run: poetry build
27-
- name: Publish package to PyPI
28-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
29-
env:
30-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi }}
31-
run: poetry publish -n
39+
40+
- name: Publish package distributions to PyPI
41+
uses: pypa/gh-action-pypi-publish@release/v1.12

benchmarks/benchmarks.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
from dataclasses import dataclass
22
from typing import List
33

4-
import betterproto
4+
import betterproto2
55

66

77
@dataclass
8-
class TestMessage(betterproto.Message):
9-
foo: int = betterproto.uint32_field(1)
10-
bar: str = betterproto.string_field(2)
11-
baz: float = betterproto.float_field(3)
8+
class TestMessage(betterproto2.Message):
9+
foo: int = betterproto2.uint32_field(1)
10+
bar: str = betterproto2.string_field(2)
11+
baz: float = betterproto2.float_field(3)
1212

1313

1414
@dataclass
15-
class TestNestedChildMessage(betterproto.Message):
16-
str_key: str = betterproto.string_field(1)
17-
bytes_key: bytes = betterproto.bytes_field(2)
18-
bool_key: bool = betterproto.bool_field(3)
19-
float_key: float = betterproto.float_field(4)
20-
int_key: int = betterproto.uint64_field(5)
15+
class TestNestedChildMessage(betterproto2.Message):
16+
str_key: str = betterproto2.string_field(1)
17+
bytes_key: bytes = betterproto2.bytes_field(2)
18+
bool_key: bool = betterproto2.bool_field(3)
19+
float_key: float = betterproto2.float_field(4)
20+
int_key: int = betterproto2.uint64_field(5)
2121

2222

2323
@dataclass
24-
class TestNestedMessage(betterproto.Message):
25-
foo: TestNestedChildMessage = betterproto.message_field(1)
26-
bar: TestNestedChildMessage = betterproto.message_field(2)
27-
baz: TestNestedChildMessage = betterproto.message_field(3)
24+
class TestNestedMessage(betterproto2.Message):
25+
foo: TestNestedChildMessage = betterproto2.message_field(1)
26+
bar: TestNestedChildMessage = betterproto2.message_field(2)
27+
baz: TestNestedChildMessage = betterproto2.message_field(3)
2828

2929

3030
@dataclass
31-
class TestRepeatedMessage(betterproto.Message):
32-
foo_repeat: List[str] = betterproto.string_field(1)
33-
bar_repeat: List[int] = betterproto.int64_field(2)
34-
baz_repeat: List[bool] = betterproto.bool_field(3)
31+
class TestRepeatedMessage(betterproto2.Message):
32+
foo_repeat: List[str] = betterproto2.string_field(1)
33+
bar_repeat: List[int] = betterproto2.int64_field(2)
34+
baz_repeat: List[bool] = betterproto2.bool_field(3)
3535

3636

3737
class BenchMessage:
@@ -59,10 +59,10 @@ def time_overhead(self):
5959
"""Overhead in class definition."""
6060

6161
@dataclass
62-
class Message(betterproto.Message):
63-
foo: int = betterproto.uint32_field(1)
64-
bar: str = betterproto.string_field(2)
65-
baz: float = betterproto.float_field(3)
62+
class Message(betterproto2.Message):
63+
foo: int = betterproto2.uint32_field(1)
64+
bar: str = betterproto2.string_field(2)
65+
baz: float = betterproto2.float_field(3)
6666

6767
def time_instantiation(self):
6868
"""Time instantiation"""

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[tool.poetry]
2-
name = "betterproto"
3-
version = "2.0.0b7"
2+
name = "betterproto2"
3+
version = "0.0.2"
44
description = "A better Protobuf / gRPC generator & library"
5-
authors = ["Daniel G. Taylor <[email protected]>"]
5+
authors = ["Adrien Vannson <[email protected]>", "Daniel G. Taylor <[email protected]>"]
66
readme = "README.md"
7-
repository = "https://github.com/danielgtaylor/python-betterproto"
7+
repository = "https://github.com/betterproto/python-betterproto2"
88
keywords = ["protobuf", "gRPC"]
99
license = "MIT"
1010
packages = [
11-
{ include = "betterproto", from = "src" }
11+
{ include = "betterproto2", from = "src" }
1212
]
1313

1414
[tool.poetry.dependencies]
@@ -44,7 +44,7 @@ cachelib = "^0.10.2"
4444
tomlkit = ">=0.7.0"
4545

4646
[tool.poetry.scripts]
47-
protoc-gen-python_betterproto = "betterproto.plugin:main"
47+
protoc-gen-python_betterproto = "betterproto2.plugin:main"
4848

4949
[tool.poetry.extras]
5050
compiler = ["ruff", "jinja2"]
@@ -130,7 +130,7 @@ help = "Clean out generated files from the workspace"
130130
[tool.poe.tasks.generate_lib]
131131
cmd = """
132132
protoc
133-
--plugin=protoc-gen-custom=src/betterproto/plugin/main.py
133+
--plugin=protoc-gen-custom=src/betterproto2/plugin/main.py
134134
--custom_opt=INCLUDE_GOOGLE
135135
--custom_out=src/betterproto/lib/std
136136
-I /usr/local/include/

src/betterproto/lib/google/protobuf/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/betterproto/lib/google/protobuf/compiler/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
File renamed without changes.

src/betterproto2/_version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from importlib import metadata
2+
3+
__version__ = metadata.version("betterproto2")
File renamed without changes.

0 commit comments

Comments
 (0)