55 types : [published]
66 workflow_dispatch :
77
8+ permissions :
9+ contents : write
10+ id-token : write
11+
812jobs :
13+ build-wheels :
14+ name : Build wheels on ${{ matrix.os }} for Python ${{ matrix.python-version }}
15+ runs-on : ${{ matrix.os }}
16+ strategy :
17+ matrix :
18+ python-version : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
19+ include :
20+ # Linux x86_64 - all Python versions
21+ - os : ubuntu-latest
22+ arch : x86_64
23+ # Linux aarch64 - all Python versions
24+ - os : ubuntu-latest
25+ arch : aarch64
26+ # macOS Intel - all Python versions
27+ - os : macos-13
28+ arch : x86_64
29+ # macOS Apple Silicon - all Python versions
30+ - os : macos-14
31+ arch : arm64
32+ # Windows - all Python versions
33+ - os : windows-latest
34+ arch : x86_64
35+ steps :
36+ - name : Checkout
37+ uses : actions/checkout@v4
38+
39+ - name : Setup Python
40+ uses : actions/setup-python@v5
41+ with :
42+ python-version : ${{ matrix.python-version }}
43+
44+ - name : Setup Zig
45+ uses : goto-bus-stop/setup-zig@v2
46+ with :
47+ version : 0.14.0
48+
49+ - name : Setup uv
50+ uses : astral-sh/setup-uv@v3
51+ with :
52+ version : " latest"
53+
54+ - name : Setup QEMU (for ARM on Linux)
55+ if : runner.os == 'Linux' && matrix.arch == 'aarch64'
56+ uses : docker/setup-qemu-action@v3
57+
58+ - name : Build wheel
59+ run : uv build
60+
61+ - name : Upload wheel
62+ uses : actions/upload-artifact@v4
63+ with :
64+ name : dist-${{ matrix.os }}-${{ matrix.arch }}-py${{ matrix.python-version }}
65+ path : |
66+ dist/*.whl
67+ dist/*.tar.gz
68+ if-no-files-found : error
69+
970 publish :
71+ needs : build-wheels
1072 runs-on : ubuntu-latest
1173 steps :
1274 - name : Checkout
1375 uses : actions/checkout@v4
76+
77+ - name : Setup Python
78+ uses : actions/setup-python@v5
79+ with :
80+ python-version : " 3.11"
81+
1482 - name : Setup uv
1583 uses : astral-sh/setup-uv@v3
1684 with :
1785 version : " latest"
18- - name : Build package
19- run : uv build
86+
87+ - name : Download all wheels
88+ uses : actions/download-artifact@v4
89+ with :
90+ pattern : dist-*
91+ path : dist
92+ merge-multiple : true
93+
94+ - name : Get version
95+ id : get_version
96+ run : |
97+ VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
98+ echo "version=$VERSION" >> $GITHUB_OUTPUT
99+
100+ - name : Create platform download table
101+ run : |
102+ echo "## 📦 Platform Downloads" > platform_table.md
103+ echo "" >> platform_table.md
104+ echo "| Platform | Architecture | Python Version | Download |" >> platform_table.md
105+ echo "|----------|--------------|----------------|----------|" >> platform_table.md
106+
107+ for file in dist/*.whl; do
108+ if [[ $file =~ zigx-([0-9]+\.[0-9]+\.[0-9]+)-cp([0-9]+)-cp([0-9]+)-(.+)\.whl ]]; then
109+ version="${BASH_REMATCH[1]}"
110+ py_version="${BASH_REMATCH[2]}"
111+ platform="${BASH_REMATCH[4]}"
112+
113+ # Convert platform codes to readable names
114+ case $platform in
115+ "linux_x86_64") readable_platform="Linux" readable_arch="x86_64" ;;
116+ "linux_aarch64") readable_platform="Linux" readable_arch="ARM64" ;;
117+ "macosx_10_13_x86_64"|"macosx_11_0_x86_64") readable_platform="macOS" readable_arch="Intel" ;;
118+ "macosx_11_0_arm64") readable_platform="macOS" readable_arch="Apple Silicon" ;;
119+ "win_amd64") readable_platform="Windows" readable_arch="x86_64" ;;
120+ *) readable_platform="$platform" readable_arch="Unknown" ;;
121+ esac
122+
123+ # Convert Python version number to readable version
124+ case $py_version in
125+ "38") py_readable="3.8" ;;
126+ "39") py_readable="3.9" ;;
127+ "310") py_readable="3.10" ;;
128+ "311") py_readable="3.11" ;;
129+ "312") py_readable="3.12" ;;
130+ "313") py_readable="3.13" ;;
131+ "314") py_readable="3.14" ;;
132+ *) py_readable="$py_version" ;;
133+ esac
134+
135+ filename=$(basename "$file")
136+ echo "| $readable_platform | $readable_arch | $py_readable | [\`$filename\`](https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/$filename) |" >> platform_table.md
137+ fi
138+ done
139+
140+ echo "" >> platform_table.md
141+ cat platform_table.md
142+
143+ - name : Upload artifacts to release
144+ if : github.event_name == 'release'
145+ uses : softprops/action-gh-release@v2
146+ with :
147+ files : dist/*
148+ body_path : platform_table.md
149+ env :
150+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
151+
20152 - name : Publish to PyPI
21- run : uv publish --trusted-publishing=always
153+ run : uv publish
154+
155+ - name : Update release notes
156+ if : github.event_name == 'release'
157+ run : |
158+ # Create enhanced release notes
159+ cat << EOF > temp_notes.md
160+ # ZigX v${{ steps.get_version.outputs.version }} Release Notes
161+
162+ ## 🚀 Release
163+
164+ Welcome to ZigX v${{ steps.get_version.outputs.version }}, a high-performance Python extension that seamlessly integrates Zig's native performance with Python's ease of use!
165+
166+ ### ✨ Key Features
167+
168+ - **Direct Zig Integration**: Compile Zig code into native Python extensions without intermediate C bindings
169+ - **Automatic GIL Management**: Smart GIL release during native calls for true parallel execution
170+ - **Cross-Platform Support**: Works on Windows, macOS, and Linux
171+ - **PEP 517 Build System**: Modern Python packaging with Hatchling backend
172+ - **Type Safety**: Full mypy support with comprehensive type annotations
173+
174+ ### 📦 Installation
175+
176+ \`\`\`bash
177+ pip install zigx
178+ # or
179+ uv pip install zigx
180+ \`\`\`
181+
182+ ### 🔗 Links
183+
184+ - 📚 [Documentation](https://muhammad-fiaz.github.io/zigx)
185+ - 🐛 [Issues](${{ github.server_url }}/${{ github.repository }}/issues)
186+ - 💻 [Source](${{ github.server_url }}/${{ github.repository }})
187+
188+ ### 📦 Platform Support
189+
190+ This release includes pre-built wheels for:
191+ - Linux (x86_64, aarch64)
192+ - macOS (x86_64 Intel, arm64 Apple Silicon)
193+ - Windows (x86_64)
194+
195+ All wheels support Python versions 3.8 through 3.14.
196+
197+ ---
198+
199+ ✅ **Successfully published to PyPI!**
200+ EOF
201+ ENHANCED_NOTES=$(cat temp_notes.md)
202+ rm temp_notes.md
203+
204+ # Use GitHub CLI to update release
205+ gh release edit ${{ github.event.release.tag_name }} \
206+ --notes "$ENHANCED_NOTES" \
207+ --repo ${{ github.repository }}
208+ env :
209+ GH_TOKEN : ${{ secrets.GH_TOKEN }}
0 commit comments