Skip to content

Commit c3d3bd5

Browse files
authored
Release workflow (#1)
* Release workflow * README tweak --------- Co-authored-by: Jay Qi <jayqi@users.noreply.github.com>
1 parent 50b55d5 commit c3d3bd5

File tree

5 files changed

+70
-9
lines changed

5 files changed

+70
-9
lines changed

.github/workflows/release.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build:
10+
name: Publish release
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python and uv
17+
uses: drivendataorg/setup-python-uv-action@v1
18+
with:
19+
python-version: "3.11"
20+
21+
- name: Install requirements
22+
run: |
23+
uv pip install -r dev-requirements.txt
24+
25+
- name: Check that versions match
26+
id: version
27+
run: |
28+
echo "Release tag: [${{ github.ref_name }}]"
29+
PACKAGE_VERSION=$(python -c "import sortedcontainers_pydantic; print(sortedcontainers_pydantic.__version__)")
30+
echo "Package version: [$PACKAGE_VERSION]"
31+
[ "${{ github.ref_name }}" == "v$PACKAGE_VERSION" ] || { exit 1; }
32+
echo "major_minor_version=v${PACKAGE_VERSION%.*}" >> $GITHUB_OUTPUT
33+
34+
- name: Build package
35+
run: |
36+
python -m build
37+
38+
- name: Publish to Test PyPI
39+
uses: pypa/gh-action-pypi-publish@v1.8.11
40+
with:
41+
user: ${{ secrets.PYPI_TEST_USERNAME }}
42+
password: ${{ secrets.PYPI_TEST_PASSWORD }}
43+
repository-url: https://test.pypi.org/legacy/
44+
skip-existing: true
45+
46+
- name: Publish to Production PyPI
47+
uses: pypa/gh-action-pypi-publish@v1.8.11
48+
with:
49+
user: ${{ secrets.PYPI_PROD_USERNAME }}
50+
password: ${{ secrets.PYPI_PROD_PASSWORD }}
51+
skip-existing: false

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## v1.0.0 (2024-03-20)
4+
5+
Initial release! 🎉

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Jay Qi
3+
Copyright (c) 2024 DrivenData
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
[![PyPI](https://img.shields.io/pypi/v/sortedcontainers-pydantic.svg)](https://pypi.org/project/sortedcontainers-pydantic/)
44
[![Supported Python versions](https://img.shields.io/pypi/pyversions/sortedcontainers-pydantic)](https://pypi.org/project/sortedcontainers-pydantic/)
5-
[![tests](https://github.com/jayqi/sortedcontainers-pydantic/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/jayqi/sortedcontainers-pydantic/actions/workflows/tests.yml?query=branch%3Amain)
6-
[![codecov](https://codecov.io/gh/jayqi/sortedcontainers-pydantic/branch/main/graph/badge.svg)](https://codecov.io/gh/jayqi/sortedcontainers-pydantic)
5+
[![tests](https://github.com/drivendataorg/sortedcontainers-pydantic/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/drivendataorg/sortedcontainers-pydantic/actions/workflows/tests.yml?query=branch%3Amain)
6+
[![codecov](https://codecov.io/gh/drivendataorg/sortedcontainers-pydantic/branch/main/graph/badge.svg)](https://codecov.io/gh/drivendataorg/sortedcontainers-pydantic)
77

88
This package adds [Pydantic](https://docs.pydantic.dev/latest/) support to [sortedcontainers](https://github.com/grantjenks/python-sortedcontainers/), a fast pure-Python library for sorted mutable collections.
99

10-
It implements [Pydantic's special methods](https://docs.pydantic.dev/latest/concepts/types/#customizing-validation-with-__get_pydantic_core_schema__) on subclasses of sortedcontainer's `SortedDict`, `SortedList`, and `SortedSet` classes so that you can use them with Pydantic's models, validation, and serialization. To use, simply import the respective class of the same name from `sortedcontainers_pydantic` instead of from `sortedcontainers`. Currently, only Pydantic V2 is supported.
10+
It implements [Pydantic's special methods](https://docs.pydantic.dev/latest/concepts/types/#customizing-validation-with-__get_pydantic_core_schema__) on subclasses of sortedcontainer's `SortedDict`, `SortedList`, and `SortedSet` classes so that you can use them with Pydantic's models, validation, and serialization. To use, simply import the respective class of the same name from `sortedcontainers_pydantic` instead of from `sortedcontainers`. Only Pydantic V2 is supported.
1111

1212
```python
1313
from pydantic import BaseModel, TypeAdapter
1414
from sortedcontainers_pydantic import SortedList
1515

1616
class MyModel(BaseModel):
17-
sorted_list: SortedList
17+
sorted_list: SortedList[int]
1818

1919
MyModel(sorted_list=[3, 1, 2])
2020
#> MyModel(sorted_list=SortedList([1, 2, 3]))
@@ -36,8 +36,8 @@ TypeAdapter(SortedList).validate_json("[3, 1, 2]")
3636

3737
## Installation
3838

39-
sortedcontainers-pydantic is not yet available on PyPI. For now, install from GitHub:
39+
sortedcontainers-pydantic is available on [PyPI](https://pypi.org/project/sortedcontainers-pydantic/). You can install it with
4040

4141
```bash
42-
pip install sortedcontainers-pydantic@git+https://github.com/jayqi/sortedcontainers-pydantic.git
42+
pip install sortedcontainers-pydantic
4343
```

pyproject.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ name = "sortedcontainers-pydantic"
77
dynamic = ["version"]
88
description = "Pydantic support for the sortedcontainers package."
99
readme = "README.md"
10-
authors = [{ name = "Jay Qi", email = "jayqi.opensource@gmail.com" }]
11-
license = { file = "LICENSE" }
10+
authors = [
11+
{ name = "DrivenData", email = "info@drivendata.org" },
12+
{ name = "Jay Qi", email = "jayqi.opensource@gmail.com" },
13+
]
14+
license = { text = "MIT License" }
1215
keywords = ["sorted", "sorteddict", "sortedlist", "sortedset", "pydantic"]
1316
classifiers = [
1417
"Intended Audience :: Developers",
@@ -20,6 +23,8 @@ classifiers = [
2023
"Programming Language :: Python :: 3.10",
2124
"Programming Language :: Python :: 3.11",
2225
"Programming Language :: Python :: 3.12",
26+
"Framework :: Pydantic",
27+
"Framework :: Pydantic :: 2",
2328
]
2429
requires-python = '>=3.8'
2530
dependencies = ["pydantic>=2", "pydantic-core", "sortedcontainers"]

0 commit comments

Comments
 (0)