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