Skip to content

Commit ef338fc

Browse files
arman-bdclaude
andcommitted
refactor: split release into OS-specific workflow files
Restructure release workflow for better maintainability: New structure: - _build_windows.yml - Windows-specific build configuration - _build_linux.yml - Linux-specific build configuration - _build_macos.yml - macOS-specific build configuration - release.yml - Orchestrates all builds and publishing Benefits: ✅ OS-specific settings isolated in separate files ✅ Easier to maintain and customize per platform ✅ Better code organization following DRY principle ✅ Parallel builds across all platforms ✅ Platform-specific caching strategies ✅ Clearer debugging when one platform fails Each OS workflow includes: - Platform-specific tool installation - Vendor dependency caching (with OS-specific cache keys) - Build verification steps - Optimized cibuildwheel configuration The main release.yml now simply: 1. Calls each OS-specific build workflow in parallel 2. Collects artifacts from all platforms 3. Publishes to GitHub and PyPI This matches the pattern used in _test.yml and _benchmark.yml for consistency across the project. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 087f78d commit ef338fc

4 files changed

Lines changed: 286 additions & 83 deletions

File tree

.github/workflows/_build_linux.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Build Linux Wheels
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-versions:
7+
description: 'Python versions to build for'
8+
required: false
9+
type: string
10+
default: '["3.9", "3.10", "3.11", "3.12"]'
11+
12+
jobs:
13+
build-linux:
14+
name: Build Linux Wheels
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
# Setup Go for BoringSSL build
23+
- name: Setup Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.21'
27+
cache: true
28+
29+
# Cache vendor dependencies to speed up builds
30+
- name: Restore vendor cache
31+
id: cache-vendor
32+
uses: actions/cache/restore@v4
33+
with:
34+
path: vendor
35+
key: vendor-linux-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
36+
restore-keys: |
37+
vendor-linux-
38+
39+
# Build wheels with cibuildwheel (handles manylinux containers)
40+
# Vendor dependencies are built inside the manylinux container
41+
- name: Build wheels
42+
uses: pypa/cibuildwheel@v2.22.0
43+
env:
44+
# Build for specified Python versions
45+
CIBW_BUILD: cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64
46+
# Vendor build happens inside manylinux container via before-build
47+
48+
# Save vendor cache after build
49+
- name: Save vendor cache
50+
if: steps.cache-vendor.outputs.cache-hit != 'true'
51+
uses: actions/cache/save@v4
52+
with:
53+
path: vendor
54+
key: vendor-linux-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
55+
56+
# Upload wheels as artifacts
57+
- uses: actions/upload-artifact@v4
58+
with:
59+
name: wheels-linux
60+
path: ./wheelhouse/*.whl
61+
if-no-files-found: error

.github/workflows/_build_macos.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build macOS Wheels
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-versions:
7+
description: 'Python versions to build for'
8+
required: false
9+
type: string
10+
default: '["3.9", "3.10", "3.11", "3.12"]'
11+
12+
jobs:
13+
build-macos:
14+
name: Build macOS Wheels
15+
runs-on: macos-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
# Install build tools
23+
- name: Install build dependencies
24+
run: |
25+
brew install cmake ninja go
26+
27+
# Setup Go for BoringSSL build
28+
- name: Setup Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: '1.21'
32+
cache: true
33+
34+
# Cache vendor dependencies to speed up builds
35+
- name: Restore vendor cache
36+
id: cache-vendor
37+
uses: actions/cache/restore@v4
38+
with:
39+
path: vendor
40+
key: vendor-macos-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
41+
restore-keys: |
42+
vendor-macos-
43+
44+
# Build vendor dependencies if not cached
45+
- name: Build vendor dependencies
46+
if: steps.cache-vendor.outputs.cache-hit != 'true'
47+
run: |
48+
bash scripts/setup_vendors.sh
49+
50+
# Save vendor cache for next time
51+
- name: Save vendor cache
52+
if: steps.cache-vendor.outputs.cache-hit != 'true'
53+
uses: actions/cache/save@v4
54+
with:
55+
path: vendor
56+
key: vendor-macos-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
57+
58+
# Verify vendor build
59+
- name: Verify vendor build
60+
run: |
61+
echo "=== Vendor directory contents ==="
62+
ls -la vendor/ || true
63+
echo ""
64+
echo "=== BoringSSL build ==="
65+
ls -la vendor/boringssl/build/ || true
66+
if [ -d "vendor/boringssl/build/ssl" ]; then
67+
echo " ssl:"
68+
ls -la vendor/boringssl/build/ssl/ || true
69+
fi
70+
if [ -d "vendor/boringssl/build/crypto" ]; then
71+
echo " crypto:"
72+
ls -la vendor/boringssl/build/crypto/ || true
73+
fi
74+
echo ""
75+
echo "=== nghttp2 install ==="
76+
ls -la vendor/nghttp2/install/ || true
77+
if [ -d "vendor/nghttp2/install/lib" ]; then
78+
echo " lib:"
79+
ls -la vendor/nghttp2/install/lib/ || true
80+
fi
81+
82+
# Build wheels for all Python versions
83+
- name: Build wheels
84+
uses: pypa/cibuildwheel@v2.22.0
85+
env:
86+
# Skip before-build since we already built vendors
87+
CIBW_BEFORE_BUILD: ""
88+
# Build for specified Python versions (universal2 for both Intel and Apple Silicon)
89+
CIBW_BUILD: cp39-macosx_* cp310-macosx_* cp311-macosx_* cp312-macosx_*
90+
# Use delocate to bundle dependencies
91+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel} --ignore-missing-dependencies"
92+
93+
# Upload wheels as artifacts
94+
- uses: actions/upload-artifact@v4
95+
with:
96+
name: wheels-macos
97+
path: ./wheelhouse/*.whl
98+
if-no-files-found: error
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Build Windows Wheels
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-versions:
7+
description: 'Python versions to build for'
8+
required: false
9+
type: string
10+
default: '["3.9", "3.10", "3.11", "3.12"]'
11+
12+
jobs:
13+
build-windows:
14+
name: Build Windows Wheels
15+
runs-on: windows-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
# Install build tools
23+
- name: Install build dependencies
24+
run: |
25+
choco install cmake ninja golang -y
26+
shell: bash
27+
28+
# Setup Go for BoringSSL build
29+
- name: Setup Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version: '1.21'
33+
cache: true
34+
35+
# Cache vendor dependencies to speed up builds
36+
- name: Restore vendor cache
37+
id: cache-vendor
38+
uses: actions/cache/restore@v4
39+
with:
40+
path: vendor
41+
key: vendor-windows-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
42+
restore-keys: |
43+
vendor-windows-
44+
45+
# Build vendor dependencies if not cached
46+
- name: Build vendor dependencies
47+
if: steps.cache-vendor.outputs.cache-hit != 'true'
48+
run: |
49+
bash scripts/setup_vendors.sh
50+
shell: bash
51+
52+
# Save vendor cache for next time
53+
- name: Save vendor cache
54+
if: steps.cache-vendor.outputs.cache-hit != 'true'
55+
uses: actions/cache/save@v4
56+
with:
57+
path: vendor
58+
key: vendor-windows-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
59+
60+
# Verify vendor build
61+
- name: Verify vendor build
62+
run: |
63+
echo "=== Vendor directory contents ==="
64+
ls -la vendor/ || true
65+
echo ""
66+
echo "=== BoringSSL build ==="
67+
ls -la vendor/boringssl/build/ || true
68+
if [ -d "vendor/boringssl/build/ssl/Release" ]; then
69+
echo " ssl/Release:"
70+
ls -la vendor/boringssl/build/ssl/Release/ || true
71+
fi
72+
if [ -d "vendor/boringssl/build/crypto/Release" ]; then
73+
echo " crypto/Release:"
74+
ls -la vendor/boringssl/build/crypto/Release/ || true
75+
fi
76+
echo ""
77+
echo "=== nghttp2 build ==="
78+
ls -la vendor/nghttp2/build/ || true
79+
if [ -d "vendor/nghttp2/build/lib/Release" ]; then
80+
echo " lib/Release:"
81+
ls -la vendor/nghttp2/build/lib/Release/ || true
82+
fi
83+
echo ""
84+
echo "=== zlib build ==="
85+
ls -la vendor/zlib/build/ || true
86+
if [ -d "vendor/zlib/build/Release" ]; then
87+
echo " Release:"
88+
ls -la vendor/zlib/build/Release/ || true
89+
fi
90+
shell: bash
91+
92+
# Build wheels for all Python versions
93+
- name: Build wheels
94+
uses: pypa/cibuildwheel@v2.22.0
95+
env:
96+
# Skip before-build since we already built vendors
97+
CIBW_BEFORE_BUILD: ""
98+
# Build for specified Python versions
99+
CIBW_BUILD: cp39-win_amd64 cp310-win_amd64 cp311-win_amd64 cp312-win_amd64
100+
101+
# Upload wheels as artifacts
102+
- uses: actions/upload-artifact@v4
103+
with:
104+
name: wheels-windows
105+
path: ./wheelhouse/*.whl
106+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 21 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -37,90 +37,28 @@ jobs:
3737
primary-python: "3.11"
3838
secrets: inherit
3939

40-
build-wheels:
41-
name: Build Wheels (${{ matrix.os }})
40+
# Build wheels for each platform in parallel
41+
build-windows:
42+
name: Build Windows Wheels
4243
needs: [config, test]
4344
if: always() && (needs.test.result == 'success' || needs.test.result == 'skipped')
44-
runs-on: ${{ matrix.os }}
45-
strategy:
46-
fail-fast: false
47-
matrix:
48-
os: [windows-latest]
45+
uses: ./.github/workflows/_build_windows.yml
4946

50-
steps:
51-
- uses: actions/checkout@v4
52-
with:
53-
submodules: recursive
54-
55-
# Install build tools
56-
- name: Install build dependencies (Windows)
57-
if: runner.os == 'Windows'
58-
run: |
59-
choco install cmake ninja golang -y
60-
shell: bash
61-
62-
# Setup Go for BoringSSL build
63-
- name: Setup Go
64-
uses: actions/setup-go@v5
65-
with:
66-
go-version: '1.21'
67-
cache: true
68-
69-
# Cache vendor dependencies to speed up builds
70-
- name: Restore vendor cache
71-
id: cache-vendor
72-
uses: actions/cache/restore@v4
73-
with:
74-
path: vendor
75-
key: vendor-${{ runner.os }}-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
76-
restore-keys: |
77-
vendor-${{ runner.os }}-
78-
79-
# Build vendor dependencies if not cached
80-
- name: Build vendor dependencies
81-
if: steps.cache-vendor.outputs.cache-hit != 'true'
82-
run: |
83-
bash scripts/setup_vendors.sh
84-
shell: bash
85-
86-
# Save vendor cache for next time
87-
- name: Save vendor cache
88-
if: steps.cache-vendor.outputs.cache-hit != 'true'
89-
uses: actions/cache/save@v4
90-
with:
91-
path: vendor
92-
key: vendor-${{ runner.os }}-${{ hashFiles('scripts/setup_vendors.sh') }}-v8
93-
94-
# List vendor directory to verify build
95-
- name: Verify vendor build
96-
run: |
97-
echo "=== Vendor directory contents ==="
98-
ls -la vendor/ || true
99-
echo ""
100-
echo "=== BoringSSL build ==="
101-
ls -la vendor/boringssl/build/ || true
102-
echo ""
103-
echo "=== nghttp2 build ==="
104-
ls -la vendor/nghttp2/build/ || true
105-
echo ""
106-
echo "=== zlib build ==="
107-
ls -la vendor/zlib/build/ || true
108-
shell: bash
109-
110-
- name: Build wheels
111-
uses: pypa/cibuildwheel@v2.22.0
112-
env:
113-
# Skip before-build in pyproject.toml since we already built vendors
114-
CIBW_BEFORE_BUILD: ""
47+
build-linux:
48+
name: Build Linux Wheels
49+
needs: [config, test]
50+
if: always() && (needs.test.result == 'success' || needs.test.result == 'skipped')
51+
uses: ./.github/workflows/_build_linux.yml
11552

116-
- uses: actions/upload-artifact@v4
117-
with:
118-
name: wheels-${{ matrix.os }}
119-
path: ./wheelhouse/*.whl
53+
build-macos:
54+
name: Build macOS Wheels
55+
needs: [config, test]
56+
if: always() && (needs.test.result == 'success' || needs.test.result == 'skipped')
57+
uses: ./.github/workflows/_build_macos.yml
12058

12159
publish:
12260
name: Publish Release
123-
needs: build-wheels
61+
needs: [build-windows, build-linux, build-macos]
12462
if: always() && startsWith(github.ref, 'refs/tags/v')
12563
runs-on: ubuntu-latest
12664
environment:
@@ -150,16 +88,16 @@ jobs:
15088
echo "Build Status Report"
15189
echo "===================="
15290
153-
for os in ubuntu-latest macos-latest windows-latest; do
154-
if [ -d "dist/wheels-$os" ]; then
155-
wheel_count=$(find "dist/wheels-$os" -name "*.whl" 2>/dev/null | wc -l)
91+
for platform in windows linux macos; do
92+
if [ -d "dist/wheels-$platform" ]; then
93+
wheel_count=$(find "dist/wheels-$platform" -name "*.whl" 2>/dev/null | wc -l)
15694
if [ "$wheel_count" -gt 0 ]; then
157-
echo "✅ $os: $wheel_count wheels built"
95+
echo "✅ $platform: $wheel_count wheels built"
15896
else
159-
echo "❌ $os: No wheels found"
97+
echo "❌ $platform: No wheels found"
16098
fi
16199
else
162-
echo "❌ $os: Build failed or artifacts missing"
100+
echo "❌ $platform: Build failed or artifacts missing"
163101
fi
164102
done
165103

0 commit comments

Comments
 (0)