Skip to content

Commit 1b2162c

Browse files
authored
Merge pull request #11 from danielbeach/fixtests
add ability for GitHub to publish to pypi
2 parents 533464e + 95281af commit 1b2162c

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

.github/workflows/publish.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Triggers on version tags like v0.1.8, v1.0.0, etc.
7+
workflow_dispatch: # Allow manual triggering
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
build_wheels:
15+
name: Build wheels on ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, windows-latest, macos-latest]
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@master
27+
with:
28+
toolchain: stable
29+
components: rustfmt, clippy
30+
31+
- name: Cache Rust dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
~/.cargo/registry
36+
~/.cargo/git
37+
target
38+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-cargo-
41+
42+
- name: Install Python
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.11'
46+
47+
- name: Install cibuildwheel
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install cibuildwheel
51+
52+
- name: Build wheels
53+
run: cibuildwheel --platform ${{ matrix.os == 'ubuntu-latest' && 'linux' || matrix.os == 'windows-latest' && 'windows' || 'macos' }}
54+
env:
55+
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-*
56+
CIBW_BEFORE_BUILD: pip install maturin
57+
CIBW_BUILD_COMMAND: maturin build --release --interpreter {python}
58+
59+
- name: Upload wheels
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: wheels-${{ matrix.os }}
63+
path: ./wheelhouse/*.whl
64+
65+
build_sdist:
66+
name: Build source distribution
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Install Python
73+
uses: actions/setup-python@v4
74+
with:
75+
python-version: '3.11'
76+
77+
- name: Install maturin
78+
run: |
79+
python -m pip install --upgrade pip
80+
pip install maturin
81+
82+
- name: Build sdist
83+
run: maturin sdist
84+
85+
- name: Upload sdist
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: sdist
89+
path: dist/*.tar.gz
90+
91+
publish:
92+
name: Publish to PyPI
93+
runs-on: ubuntu-latest
94+
needs: [build_wheels, build_sdist]
95+
environment: pypi # This requires you to set up a PyPI environment in GitHub
96+
97+
steps:
98+
- name: Download wheels
99+
uses: actions/download-artifact@v4
100+
with:
101+
name: wheels-ubuntu-latest
102+
path: dist
103+
104+
- name: Download wheels (Windows)
105+
uses: actions/download-artifact@v4
106+
with:
107+
name: wheels-windows-latest
108+
path: dist
109+
110+
- name: Download wheels (macOS)
111+
uses: actions/download-artifact@v4
112+
with:
113+
name: wheels-macos-latest
114+
path: dist
115+
116+
- name: Download sdist
117+
uses: actions/download-artifact@v4
118+
with:
119+
name: sdist
120+
path: dist
121+
122+
- name: Install twine
123+
run: |
124+
python -m pip install --upgrade pip
125+
pip install twine
126+
127+
- name: Check distributions
128+
run: twine check dist/*
129+
130+
- name: Publish to PyPI
131+
env:
132+
TWINE_USERNAME: __token__
133+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
134+
run: twine upload dist/*

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Drainage helps you understand and optimize your data lake by identifying issues
4444
pip install drainage
4545
```
4646

47+
> **Note**: This package is automatically built and published to PyPI using GitHub Actions when version tags are pushed.
48+
4749
### From Source
4850

4951
```bash
@@ -862,6 +864,20 @@ Typical analysis times:
862864
- [ ] CloudWatch/Datadog integration
863865
- [ ] Table comparison and diff
864866

867+
## Releasing
868+
869+
To release a new version:
870+
871+
1. Update the version in `pyproject.toml` and `Cargo.toml`
872+
2. Commit and push changes
873+
3. Create and push a version tag:
874+
```bash
875+
git tag -a v0.1.8 -m "Release v0.1.8"
876+
git push origin main
877+
git push origin v0.1.8
878+
```
879+
4. GitHub Actions will automatically build and publish to PyPI
880+
865881
## Contributing
866882

867883
Contributions are welcome! Please feel free to submit a Pull Request.

0 commit comments

Comments
 (0)