Skip to content

Commit 4a5735b

Browse files
Merge pull request #1 from vilsonrodrigues/init
init project
2 parents b96d98c + 0846738 commit 4a5735b

File tree

8 files changed

+480
-0
lines changed

8 files changed

+480
-0
lines changed

.github/workflows/publish.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Release
2+
3+
# Dynamic run name that appears in the GitHub UI
4+
run-name: Release version ${{ github.ref_name }} of the SDK
5+
6+
on:
7+
# no explicit inputs for tag_name; rely on the selected reference from the UI
8+
workflow_dispatch:
9+
10+
# ensures only a single instance of this release workflow is running at any one time
11+
concurrency:
12+
group: release-${{ github.ref_name }}
13+
cancel-in-progress: true
14+
15+
env:
16+
PACKAGE_NAME: "msgspec-ext"
17+
TEST_PYPI_URL: "https://test.pypi.org/pypi"
18+
PYPI_URL: "https://pypi.org/pypi"
19+
20+
jobs:
21+
get_tag_details:
22+
name: Get Tag Details
23+
runs-on: msgspec-ext-python-runner
24+
outputs:
25+
tag_name: ${{ steps.release.outputs.tag_name }}
26+
new_version: ${{ steps.release.outputs.new_version }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0 # fetch all history
31+
32+
- name: Check if a tag is selected
33+
run: |
34+
if [ "${{ github.ref_type }}" != "tag" ]; then
35+
echo "Error: Workflow must be triggered with a tag selected. Current ref_type is ${{ github.ref_type }}."
36+
exit 1
37+
fi
38+
TAG_NAME=${{ github.ref_name }}
39+
echo "Selected tag is $TAG_NAME"
40+
41+
- name: Extract version from tag
42+
id: release
43+
run: |
44+
TAG_NAME=${{ github.ref_name }}
45+
# Validate tag format
46+
if [[ ! $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+(a[0-9]+|b[0-9]+|rc[0-9]+)?$ ]]; then
47+
echo "Invalid tag format. Tag must be in the format vX.Y.Z, vX.Y.ZaN, vX.Y.ZbN, or vX.Y.ZrcN."
48+
exit 1
49+
fi
50+
NEW_VERSION=${TAG_NAME#v}
51+
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
52+
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
53+
echo "Tag name is $TAG_NAME"
54+
echo "Version is $NEW_VERSION"
55+
56+
setup_build_and_publish:
57+
name: Build Package and Publish to PyPI
58+
needs: [get_tag_details]
59+
runs-on: msgspec-ext-python-runner
60+
permissions:
61+
contents: read
62+
id-token: write # Required for trusted publishing to PyPI
63+
steps:
64+
- name: Checkout the repository
65+
uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
69+
- name: Set up Python
70+
uses: actions/setup-python@v5
71+
with:
72+
python-version: "3.10"
73+
74+
- name: Install uv
75+
uses: astral-sh/setup-uv@c7f87aa956e4c323abf06d5dec078e358f6b4d04 # v6
76+
with:
77+
version: "0.7.3"
78+
79+
- name: Install dependencies
80+
run: uv sync --locked
81+
82+
- name: Build source and wheel distribution
83+
run: |
84+
uv build
85+
86+
- name: Upload build artifacts
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: dist
90+
path: dist/*
91+
if-no-files-found: error
92+
93+
- name: Publish to PyPI
94+
run: uv publish
95+
96+
github_release:
97+
name: Create GitHub Release
98+
needs: [get_tag_details, setup_build_and_publish]
99+
runs-on: msgspec-ext-python-runner
100+
permissions:
101+
contents: write
102+
steps:
103+
- name: Checkout Code
104+
uses: actions/checkout@v4
105+
with:
106+
fetch-depth: 0
107+
108+
- name: Download build artifacts
109+
uses: actions/download-artifact@v4
110+
with:
111+
name: dist
112+
path: dist/
113+
114+
- name: Create GitHub Release
115+
id: create_release
116+
env:
117+
GH_TOKEN: ${{ github.token }}
118+
run: |
119+
gh release create ${{ needs.get_tag_details.outputs.tag_name }} dist/* --title ${{ needs.get_tag_details.outputs.tag_name }} --generate-notes

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
env/
2+
.env
3+
venv/
4+
.venv
5+
.envrc
6+
env3*/
7+
Pipfile
8+
*.lock
9+
*.py[cod]
10+
*.egg-info/
11+
/build/
12+
dist/
13+
.cache/
14+
/site/
15+
/site.zip
16+
.pytest_cache/
17+
.python-version
18+
__pycache__/
19+
.vscode/
20+
_build/
21+
.auto-format
22+
/sandbox/
23+
/worktrees/
24+
/.ruff_cache/
25+
.DS_Store

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
default_install_hook_types: [pre-commit, pre-push]
2+
3+
repos:
4+
- repo: https://github.com/gitleaks/gitleaks
5+
rev: v8.23.1
6+
hooks:
7+
- id: gitleaks
8+
9+
- repo: https://github.com/astral-sh/uv-pre-commit
10+
rev: 0.8.3 # uv version.
11+
hooks:
12+
- id: uv-lock
13+
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.11.7
16+
hooks:
17+
- id: ruff
18+
args: [--fix]
19+
- id: ruff-format

pyproject.toml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "msgspec-ext"
7+
dynamic = ["version"]
8+
description = "Settings management using msgspec"
9+
readme = "README.md"
10+
license = "MIT"
11+
authors = [
12+
{ name = "Vilson Rodrigues", email = "vilson@msgflux.com" }
13+
]
14+
requires-python = ">=3.9"
15+
dependencies = [
16+
"msgspec>=0.19.0",
17+
"python-dotenv>=1.1.1",
18+
]
19+
classifiers = [
20+
"Development Status :: 4 - Beta",
21+
"Intended Audience :: Developers",
22+
"Intended Audience :: Science/Research",
23+
"License :: OSI Approved :: MIT License",
24+
"Operating System :: MacOS :: MacOS X",
25+
"Operating System :: POSIX :: Linux",
26+
"Operating System :: Microsoft :: Windows",
27+
"Programming Language :: Python",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: 3.13",
33+
"Topic :: Software Development :: Libraries",
34+
"Topic :: Software Development :: Libraries :: Python Modules"
35+
]
36+
37+
[tool.hatch.version]
38+
path = "src/msgspec_ext/version.py"
39+
40+
[project.urls]
41+
Homepage = "https://github.com/msgflux/msgspec-ext"
42+
Documentation = "https://github.com/msgflux/msgspec-ext"
43+
Repository = "https://github.com/msgflux/msgspec-ext"
44+
45+
[dependency-groups]
46+
dev = [
47+
"pytest>=8.4.1",
48+
"ruff>=0.12.5",
49+
]
50+
51+
[tool.ruff]
52+
target-version = "py39"
53+
line-length = 88
54+
55+
[tool.ruff.lint]
56+
select = [
57+
"A",
58+
"ARG",
59+
"B",
60+
"C",
61+
"D",
62+
"DTZ",
63+
"E",
64+
"EM",
65+
"F",
66+
"FBT",
67+
"I",
68+
"ICN",
69+
"ISC",
70+
"N",
71+
"PLC",
72+
"PLE",
73+
"PLR",
74+
"PLW",
75+
"Q",
76+
"RUF",
77+
"S",
78+
"T",
79+
"TID",
80+
"UP",
81+
"W",
82+
"YTT",
83+
]
84+
ignore = [
85+
"D100", # Allow missing docstring in top level module
86+
"D104", # Allow missing docstring in public package
87+
"D105", # Allow missing docstring in magic method
88+
"D203", # Allow docstring directly below class definition (as enforced by D211)
89+
"D213", # Allow multi-line-summary on first line of docstring (as enforced by D212)
90+
"D401", # Allow non imperative mood in docstring
91+
"D413", # Allow no new line at end of docstring.
92+
"EM101", # Allow `raise ValueError(msg)`
93+
"EM102", # Allow f strings in `raise` statements
94+
"FBT003", # Allow boolean positional values in function calls, like `dict.get(... True)`
95+
"TID252", # Allow relative imports
96+
"UP007", # Allow `from typing import Optional` instead of `X | None`
97+
"UP035", # Allow `from typing import Sequence` instead of `Sequence[X]`
98+
"PLR0913",
99+
]
100+
unfixable = ["F401"]
101+
102+
[tool.ruff.lint.isort]
103+
known-first-party = ["msgspec_ext"]
104+
105+
[tool.ruff.lint.flake8-tidy-imports]
106+
ban-relative-imports = "all"
107+
108+
[tool.ruff.lint.per-file-ignores]
109+
"tests/**/*" = [
110+
"D",
111+
"PLR0911",
112+
"PLR0912",
113+
"PLR0915",
114+
"PLR2004",
115+
"S101",
116+
"S105",
117+
"S106",
118+
"S107",
119+
"TID252",
120+
]
121+
"examples/**/*" = ["D", "S101", "T201"]

src/msgspec_ext/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .settings import BaseSettings, SettingsConfigDict
2+
3+
4+
__all__ = [
5+
"BaseSettings",
6+
"SettingsConfigDict",
7+
]

src/msgspec_ext/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)