Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release workflow #1

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: release

on:
release:
types:
- published

jobs:
build:
name: Publish release
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v4

- name: Set up Python and uv
uses: drivendataorg/setup-python-uv-action@v1
with:
python-version: "3.11"

- name: Install requirements
run: |
uv pip install -r dev-requirements.txt

- name: Check that versions match
id: version
run: |
echo "Release tag: [${{ github.ref_name }}]"
PACKAGE_VERSION=$(python -c "import sortedcontainers_pydantic; print(sortedcontainers_pydantic.__version__)")
echo "Package version: [$PACKAGE_VERSION]"
[ "${{ github.ref_name }}" == "v$PACKAGE_VERSION" ] || { exit 1; }
echo "major_minor_version=v${PACKAGE_VERSION%.*}" >> $GITHUB_OUTPUT

- name: Build package
run: |
python -m build

- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
user: ${{ secrets.PYPI_TEST_USERNAME }}
password: ${{ secrets.PYPI_TEST_PASSWORD }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Publish to Production PyPI
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
user: ${{ secrets.PYPI_PROD_USERNAME }}
password: ${{ secrets.PYPI_PROD_PASSWORD }}
skip-existing: false
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## v1.0.0 (2024-03-20)

Initial release! 🎉
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Jay Qi
Copyright (c) 2024 DrivenData

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

[![PyPI](https://img.shields.io/pypi/v/sortedcontainers-pydantic.svg)](https://pypi.org/project/sortedcontainers-pydantic/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/sortedcontainers-pydantic)](https://pypi.org/project/sortedcontainers-pydantic/)
[![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)
[![codecov](https://codecov.io/gh/jayqi/sortedcontainers-pydantic/branch/main/graph/badge.svg)](https://codecov.io/gh/jayqi/sortedcontainers-pydantic)
[![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)
[![codecov](https://codecov.io/gh/drivendataorg/sortedcontainers-pydantic/branch/main/graph/badge.svg)](https://codecov.io/gh/drivendataorg/sortedcontainers-pydantic)

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.

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.
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.

```python
from pydantic import BaseModel, TypeAdapter
from sortedcontainers_pydantic import SortedList

class MyModel(BaseModel):
sorted_list: SortedList
sorted_list: SortedList[int]

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

## Installation

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

```bash
pip install sortedcontainers-pydantic@git+https://github.com/jayqi/sortedcontainers-pydantic.git
pip install sortedcontainers-pydantic
```
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ name = "sortedcontainers-pydantic"
dynamic = ["version"]
description = "Pydantic support for the sortedcontainers package."
readme = "README.md"
authors = [{ name = "Jay Qi", email = "jayqi.opensource@gmail.com" }]
license = { file = "LICENSE" }
authors = [
{ name = "DrivenData", email = "info@drivendata.org" },
{ name = "Jay Qi", email = "jayqi.opensource@gmail.com" },
]
license = { text = "MIT License" }
keywords = ["sorted", "sorteddict", "sortedlist", "sortedset", "pydantic"]
classifiers = [
"Intended Audience :: Developers",
Expand All @@ -20,6 +23,8 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Pydantic",
"Framework :: Pydantic :: 2",
]
requires-python = '>=3.8'
dependencies = ["pydantic>=2", "pydantic-core", "sortedcontainers"]
Expand Down