Skip to content

Commit 075d378

Browse files
committed
upd
1 parent 7ee54c7 commit 075d378

1 file changed

Lines changed: 150 additions & 0 deletions

File tree

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Publish flashinfer-cubin wheel to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Tag (e.g., v1.2.3) to build and publish'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build-and-upload:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Validate tag format
16+
run: |
17+
if [[ ! "${{ inputs.tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([a-z0-9]+)?$ ]]; then
18+
echo "Error: Tag '${{ inputs.tag }}' does not match the expected format (e.g., v1.2.3 or v1.2.3.post1 or v1.2.3rc1)"
19+
exit 1
20+
fi
21+
echo "✓ Tag format is valid: ${{ inputs.tag }}"
22+
23+
- name: Check out tag
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ inputs.tag }}
27+
submodules: true
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.10'
33+
34+
- name: Verify tag matches version.txt (CRITICAL)
35+
run: |
36+
# Extract version from tag (remove 'v' prefix)
37+
TAG_VERSION="${{ inputs.tag }}"
38+
TAG_VERSION="${TAG_VERSION#v}"
39+
40+
# Check version.txt FIRST - this is the source of truth
41+
if [ ! -f "version.txt" ]; then
42+
echo "Error: version.txt file not found!"
43+
exit 1
44+
fi
45+
46+
VERSION_TXT=$(cat version.txt | tr -d '[:space:]')
47+
48+
if [ "$TAG_VERSION" != "$VERSION_TXT" ]; then
49+
echo "❌ CRITICAL ERROR: version.txt does not match tag!"
50+
echo " Tag version: $TAG_VERSION"
51+
echo " version.txt: $VERSION_TXT"
52+
echo ""
53+
echo "Please update version.txt to match the release version before creating a release."
54+
echo "The tag should be 'v$VERSION_TXT' (e.g., if version.txt contains '1.2.3', tag should be 'v1.2.3')"
55+
exit 1
56+
fi
57+
58+
echo "✓ version.txt matches tag version: $VERSION_TXT"
59+
60+
- name: Install build dependencies
61+
run: |
62+
python -m pip install --upgrade pip
63+
pip install build twine wheel
64+
# Install dependencies required for building flashinfer-cubin
65+
pip install setuptools>=61.0 requests filelock torch tqdm
66+
67+
- name: Build flashinfer-cubin wheel
68+
run: |
69+
echo "Building flashinfer-cubin wheel..."
70+
cd flashinfer-cubin
71+
72+
# Clean any previous builds
73+
rm -rf dist build *.egg-info
74+
75+
# Build the wheel using the build module for better isolation
76+
python -m build --wheel
77+
78+
echo "✓ Build completed"
79+
ls -lh dist/
80+
81+
# Move the wheel to the root dist directory for consistency
82+
mkdir -p ../dist
83+
cp dist/*.whl ../dist/
84+
cd ..
85+
86+
- name: Check wheel contents
87+
run: |
88+
echo "Verifying wheel contents..."
89+
# Create a temp directory to extract and check wheel
90+
mkdir -p temp_wheel_check
91+
cd temp_wheel_check
92+
93+
# Extract wheel (wheels are just zip files)
94+
unzip -l ../dist/flashinfer_cubin*.whl | head -30
95+
echo "..."
96+
97+
# Check if cubins are included
98+
unzip -l ../dist/flashinfer_cubin*.whl | grep -c "\.cubin" || true
99+
100+
cd ..
101+
rm -rf temp_wheel_check
102+
echo "✓ Wheel archive created successfully"
103+
104+
- name: Store build artifacts
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: python-package-distributions
108+
path: dist/
109+
retention-days: 7
110+
111+
- name: Test installation from wheel
112+
run: |
113+
echo "Testing installation from built wheel..."
114+
python -m venv test-env
115+
source test-env/bin/activate
116+
117+
# Install the wheel
118+
pip install dist/flashinfer_cubin*.whl
119+
120+
# Test import and check for cubins
121+
python -c "
122+
import flashinfer_cubin
123+
print(f'✓ Successfully imported flashinfer_cubin')
124+
from pathlib import Path
125+
import flashinfer_cubin
126+
cubin_dir = Path(flashinfer_cubin.__file__).parent / 'cubins'
127+
if cubin_dir.exists():
128+
cubins = list(cubin_dir.rglob('*.cubin'))
129+
print(f'✓ Found {len(cubins)} cubin files in package')
130+
else:
131+
print('⚠ Warning: cubins directory not found in package')
132+
"
133+
134+
deactivate
135+
rm -rf test-env
136+
137+
- name: Check package with twine
138+
run: |
139+
echo "Running twine check..."
140+
twine check dist/flashinfer_cubin*.whl
141+
echo "✓ Package validation passed"
142+
143+
- name: Upload to PyPI
144+
env:
145+
TWINE_USERNAME: __token__
146+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
147+
run: |
148+
echo "Uploading flashinfer-cubin wheel to PyPI..."
149+
twine upload --verbose --non-interactive dist/flashinfer_cubin*.whl
150+
echo "✓ Successfully uploaded to PyPI"

0 commit comments

Comments
 (0)