From 60c733ce1fc6480162576bff1d701bab95729af4 Mon Sep 17 00:00:00 2001 From: Arunanshu Biswas <48434243+arunanshub@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:37:27 +0530 Subject: [PATCH] build(pynanoid): configure CI to publish to pypi on tag publish (#11) --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 +++ pyproject.toml | 21 +++++++++++++++++++-- rust/nanoid.rs | 3 +-- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c45d09e..8f88dd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -144,6 +144,21 @@ jobs: path: | ./wheelhouse/*.whl + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + finish-coverage: name: Finish Coverage Report needs: [test] @@ -155,3 +170,25 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true + + publish: + name: Publish to PyPI + if: success() && startsWith(github.ref, 'refs/tags/v') + needs: [build-wheels, build_sdist, test] + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - name: Checkout repository 👁 + uses: actions/checkout@v4 + + - name: Fetch wheel and sdist from artifacts 🫖 + uses: actions/download-artifact@v4 + with: + pattern: cibw-* + merge-multiple: true + path: dist/ + + - name: Publish to PyPI 📦 + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/Cargo.toml b/Cargo.toml index 42ed665..f0d77ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" edition = "2021" license-file = "LICENSE" readme = "README.md" +repository = "https://github.com/arunanshub/pynanoid" +categories = ["algorithms"] +description = "A tiny, secure, URL-friendly, unique string ID generator." # only the listed files are included in the source distribution (sdist) include = [ "/pyproject.toml", diff --git a/pyproject.toml b/pyproject.toml index f84c113..889bed7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,13 +4,30 @@ build-backend = "maturin" [project] name = "pynanoid" -version = "0.1.0" description = "A tiny, secure, URL-friendly, unique string ID generator for Python written in Rust" authors = [{ name = "Arunanshu Biswas", email = "mydellpc07@gmail.com" }] dependencies = [] requires-python = ">=3.9" readme = "README.md" license = { file = "LICENSE" } +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Rust", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Operating System :: OS Independent", + "License :: OSI Approved :: MIT License", + "Typing :: Typed", +] +# the version is derived from Cargo.toml by maturin +dynamic = ["version"] [project.urls] repository = "https://github.com/arunanshub/pynanoid" @@ -64,7 +81,7 @@ extend-select = [ 'ANN', # annotations 'FA', # future-annotations 'PL', # pylint - 'PYI', + 'PYI', # python stubs ] [tool.ruff.lint.extend-per-file-ignores] diff --git a/rust/nanoid.rs b/rust/nanoid.rs index bfd481a..a8a2ecf 100644 --- a/rust/nanoid.rs +++ b/rust/nanoid.rs @@ -1,6 +1,5 @@ -use rand::Rng; - use crate::error::Error; +use rand::Rng; #[inline(always)] fn get_random_bytes(buffer: &mut [u8]) -> Result<(), Error> {