From 752d9b0dca18fb01d4ba415de020836a6f697277 Mon Sep 17 00:00:00 2001 From: Jay Qi <jayqi@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:25:32 -0400 Subject: [PATCH 1/2] Release workflow --- .github/workflows/release.yml | 51 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 5 ++++ LICENSE | 2 +- README.md | 8 +++--- pyproject.toml | 9 +++++-- 5 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 CHANGELOG.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..59463b3 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..460e108 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## v1.0.0 (2024-03-20) + +Initial release! 🎉 diff --git a/LICENSE b/LICENSE index 9943f7e..cb9a5a0 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 55fc10b..a242226 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [](https://pypi.org/project/sortedcontainers-pydantic/) [](https://pypi.org/project/sortedcontainers-pydantic/) -[](https://github.com/jayqi/sortedcontainers-pydantic/actions/workflows/tests.yml?query=branch%3Amain) -[](https://codecov.io/gh/jayqi/sortedcontainers-pydantic) +[](https://github.com/drivendataorg/sortedcontainers-pydantic/actions/workflows/tests.yml?query=branch%3Amain) +[](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. @@ -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 ``` diff --git a/pyproject.toml b/pyproject.toml index 50abf5b..6382235 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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"] From a8d00622caf87638352ceff3448a0b5c0749e1ff Mon Sep 17 00:00:00 2001 From: Jay Qi <jayqi@users.noreply.github.com> Date: Wed, 20 Mar 2024 12:29:24 -0400 Subject: [PATCH 2/2] README tweak --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a242226..8435bd3 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ 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]))