Skip to content

Commit

Permalink
build(pynanoid): configure CI to publish to pypi on tag publish (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
arunanshub authored Aug 28, 2024
1 parent a22fa8a commit 60c733c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 19 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" }]
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"
Expand Down Expand Up @@ -64,7 +81,7 @@ extend-select = [
'ANN', # annotations
'FA', # future-annotations
'PL', # pylint
'PYI',
'PYI', # python stubs
]

[tool.ruff.lint.extend-per-file-ignores]
Expand Down
3 changes: 1 addition & 2 deletions rust/nanoid.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down

0 comments on commit 60c733c

Please sign in to comment.