From ec133d38a542f219a7fdc0c1829002d14215c019 Mon Sep 17 00:00:00 2001 From: Eiichi YAMAMOTO Date: Sat, 1 Aug 2026 11:58:41 +0900 Subject: [PATCH 1/2] ci: add PyPI publishing workflows --- .github/workflows/ci.yml | 61 +++++++++++++++++++++++++++++++++++++ .github/workflows/pypi.yml | 60 ++++++++++++++++++++++++++++++++++++ docs/source/development.rst | 26 ++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..08c20e9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + tests: + name: Tests (Python ${{ matrix.python-version }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: + - "3.10" + - "3.11" + - "3.12" + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + + - name: Install package and test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e . pytest + + - name: Run tests + run: pytest + + package: + name: Package build + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + + - name: Build distributions + run: | + python -m pip install --upgrade pip + python -m pip install build twine + python -m build + python -m twine check dist/* diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..514e5ac --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,60 @@ +name: Publish to PyPI + +on: + push: + tags: + - "v*" + +permissions: + contents: read + +jobs: + build: + name: Build distributions + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + + - name: Build and check distributions + run: | + python -m pip install --upgrade pip + python -m pip install build twine + python -m build + python -m twine check dist/* + + - name: Upload distributions + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + if-no-files-found: error + + publish: + name: Publish distributions + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/csvsmith/ + permissions: + contents: read + id-token: write + + steps: + - name: Download distributions + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/docs/source/development.rst b/docs/source/development.rst index c3d7450..4d56f78 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -21,6 +21,32 @@ To build the documentation locally, you need Sphinx installed. The generated HTML files will be in `docs/build/html`. +Release publishing +------------------ + +PyPI publishing is handled by GitHub Actions when a version tag is pushed. +The workflow uses PyPI Trusted Publishing, so no long-lived PyPI API token is +stored in GitHub. + +Before the first automated publish, configure a Trusted Publisher for the +``csvsmith`` project on PyPI with these values: + +- Owner: ``yeiichi`` +- Repository name: ``csvsmith`` +- Workflow name: ``pypi.yml`` +- Environment name: ``pypi`` + +To publish a release, make sure ``pyproject.toml`` contains the intended +version, then create and push the matching tag: + +.. code-block:: bash + + git tag v0.10.0 + git push origin v0.10.0 + +The PyPI workflow builds the source distribution and wheel, checks them with +Twine, and publishes them to PyPI. + Contributing ------------ From 94e7a0748ed8c343ffb871c964416149ac05f781 Mon Sep 17 00:00:00 2001 From: Eiichi YAMAMOTO Date: Sat, 1 Aug 2026 12:39:07 +0900 Subject: [PATCH 2/2] test: use package import for normalize tests --- tests/test_normalize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_normalize.py b/tests/test_normalize.py index ed753e5..2ac55c5 100644 --- a/tests/test_normalize.py +++ b/tests/test_normalize.py @@ -1,6 +1,6 @@ # File: tests/test_normalize.py -from src.csvsmith.utils.normalize import normalize +from csvsmith.utils.normalize import normalize def test_normalize_with_spaces():