Skip to content

Commit 6ba8afd

Browse files
committed
Add PyPI publish workflow
1 parent a7e4337 commit 6ba8afd

8 files changed

Lines changed: 1184 additions & 3 deletions

File tree

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# =============================================================================
2+
# PyDebFlow Environment Variables
3+
# =============================================================================
4+
# Copy this file to .env and fill in your values
5+
# NEVER commit the .env file to version control!
6+
# =============================================================================
7+
8+
# PyPI API Token for publishing
9+
# Get this from: https://pypi.org/manage/account/token/
10+
PYPI_API_TOKEN=pypi-your_token_here
11+
12+
# TestPyPI API Token for test publishing (optional)
13+
# Get this from: https://test.pypi.org/manage/account/token/
14+
TEST_PYPI_API_TOKEN=pypi-your_test_token_here

.github/workflows/publish.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
# =========================================================================
10+
# Job 1: Run ALL tests (including API tests)
11+
# =========================================================================
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: true # Stop immediately if any test fails
16+
matrix:
17+
os: [ubuntu-latest, windows-latest]
18+
python-version: ['3.10', '3.11', '3.12']
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r requirements.txt
32+
pip install pytest pytest-cov
33+
34+
- name: Run ALL tests (library, API, scripts, integration)
35+
run: |
36+
python -m pytest tests/ -v --tb=short
37+
38+
- name: Verify package imports
39+
run: |
40+
python -c "from src.core.flow_model import TwoPhaseFlowModel; print('Import OK')"
41+
42+
# =========================================================================
43+
# Job 2: Build the package (only if ALL tests pass)
44+
# =========================================================================
45+
build:
46+
needs: test
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.12'
56+
57+
- name: Install build tools
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install build twine
61+
62+
- name: Build package
63+
run: python -m build
64+
65+
- name: Verify package
66+
run: twine check dist/*
67+
68+
- name: Upload artifacts
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: python-package-distributions
72+
path: dist/
73+
74+
# =========================================================================
75+
# Job 3: Publish directly to PyPI (no TestPyPI)
76+
# =========================================================================
77+
publish:
78+
needs: build
79+
runs-on: ubuntu-latest
80+
81+
environment:
82+
name: pypi
83+
url: https://pypi.org/p/pydebflow
84+
85+
permissions:
86+
id-token: write
87+
88+
steps:
89+
- name: Download artifacts
90+
uses: actions/download-artifact@v4
91+
with:
92+
name: python-package-distributions
93+
path: dist/
94+
95+
- name: Publish to PyPI
96+
uses: pypa/gh-action-pypi-publish@release/v1
97+
with:
98+
password: ${{ secrets.PYPI_API_TOKEN }}

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,23 @@ PyDebFlow implements a **two-phase (solid + fluid) shallow water model** with ad
144144
- **pip** package manager
145145
- **Git** (for cloning)
146146

147-
### Method 1: Quick Install with Scripts (Recommended)
147+
### Method 1: Install from PyPI (Easiest)
148+
149+
```bash
150+
# Basic installation
151+
pip install pydebflow
152+
153+
# With visualization support (3D viewer, animations)
154+
pip install pydebflow[visualization]
155+
156+
# With GUI support
157+
pip install pydebflow[gui]
158+
159+
# Full installation (all features)
160+
pip install pydebflow[all]
161+
```
162+
163+
### Method 2: Quick Install with Scripts
148164

149165
```bash
150166
# Clone the repository

0 commit comments

Comments
 (0)