From 95281af1632f3973e7112eda522593ab0c723d54 Mon Sep 17 00:00:00 2001 From: Daniel B <34192225+danielbeach@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:21:45 -0500 Subject: [PATCH] add ability for GitHub to publish to pypi --- .github/workflows/publish.yml | 134 ++++++++++++++++++++++++++++++++++ README.md | 16 ++++ 2 files changed, 150 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ec1b43a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,134 @@ +name: Publish to PyPI + +on: + push: + tags: + - 'v*' # Triggers on version tags like v0.1.8, v1.0.0, etc. + workflow_dispatch: # Allow manual triggering + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: rustfmt, clippy + + - name: Cache Rust dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install cibuildwheel + run: | + python -m pip install --upgrade pip + pip install cibuildwheel + + - name: Build wheels + run: cibuildwheel --platform ${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'windows-latest' && 'windows' || 'macos' }} + env: + CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* + CIBW_BEFORE_BUILD: pip install maturin + CIBW_BUILD_COMMAND: maturin build --release --interpreter {python} + + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install maturin + run: | + python -m pip install --upgrade pip + pip install maturin + + - name: Build sdist + run: maturin sdist + + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist/*.tar.gz + + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + needs: [build_wheels, build_sdist] + environment: pypi # This requires you to set up a PyPI environment in GitHub + + steps: + - name: Download wheels + uses: actions/download-artifact@v4 + with: + name: wheels-ubuntu-latest + path: dist + + - name: Download wheels (Windows) + uses: actions/download-artifact@v4 + with: + name: wheels-windows-latest + path: dist + + - name: Download wheels (macOS) + uses: actions/download-artifact@v4 + with: + name: wheels-macos-latest + path: dist + + - name: Download sdist + uses: actions/download-artifact@v4 + with: + name: sdist + path: dist + + - name: Install twine + run: | + python -m pip install --upgrade pip + pip install twine + + - name: Check distributions + run: twine check dist/* + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: twine upload dist/* diff --git a/README.md b/README.md index 06c89c3..5ac8880 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ Drainage helps you understand and optimize your data lake by identifying issues pip install drainage ``` +> **Note**: This package is automatically built and published to PyPI using GitHub Actions when version tags are pushed. + ### From Source ```bash @@ -862,6 +864,20 @@ Typical analysis times: - [ ] CloudWatch/Datadog integration - [ ] Table comparison and diff +## Releasing + +To release a new version: + +1. Update the version in `pyproject.toml` and `Cargo.toml` +2. Commit and push changes +3. Create and push a version tag: + ```bash + git tag -a v0.1.8 -m "Release v0.1.8" + git push origin main + git push origin v0.1.8 + ``` +4. GitHub Actions will automatically build and publish to PyPI + ## Contributing Contributions are welcome! Please feel free to submit a Pull Request.