-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (141 loc) · 4.68 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (141 loc) · 4.68 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
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v0.5.1)'
required: true
jobs:
build-sdist:
name: Build Source Distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.ref }} # Explicitly checkout the tag ref, not just the commit
fetch-depth: 0 # Fetch all history for setuptools_scm to detect version from tags
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install meson-python>=0.15.0
pip install meson>=1.2.0
pip install ninja
pip install cython>=3.0
pip install tempita>=0.5.2 # Required for template processing
- name: Build source distribution
run: python -m build --sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v5
with:
name: sdist
path: dist/*.tar.gz
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-14] # macos-latest is x86_64, macos-14 is arm64
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.ref }} # Explicitly checkout the tag ref, not just the commit
fetch-depth: 0 # Fetch all history for setuptools_scm to detect version from tags
- name: Set up MSVC (Windows only)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Build wheels
uses: pypa/cibuildwheel@v2.23.4
env:
CIBW_BUILD_VERBOSITY: 1
- name: Upload wheel artifacts
uses: actions/upload-artifact@v5
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
create-release:
name: Create GitHub Release
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Download all artifacts
uses: actions/download-artifact@v5
with:
pattern: cibw-*
path: artifacts/
- name: Download sdist
uses: actions/download-artifact@v5
with:
name: sdist
path: artifacts/sdist/
- name: Prepare release files
run: |
mkdir -p release_files
# Copy wheels from all artifact directories
find artifacts/ -name '*.whl' -exec cp {} release_files/ \;
# Copy sdist
find artifacts/ -name '*.tar.gz' -exec cp {} release_files/ \;
echo "=== Release files ==="
ls -lh release_files/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release_files/*
generate_release_notes: true
draft: false
prerelease: false
publish-pypi:
name: Publish to PyPI
needs: [create-release]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v5
with:
pattern: cibw-*
path: artifacts/
- name: Download sdist
uses: actions/download-artifact@v5
with:
name: sdist
path: artifacts/sdist/
- name: Prepare distribution directory
run: |
mkdir -p dist/
# Copy wheels from all artifact directories
find artifacts/ -name '*.whl' -exec cp {} dist/ \;
# Copy sdist
find artifacts/ -name '*.tar.gz' -exec cp {} dist/ \;
- name: List all files
run: |
echo "=== Distribution files ==="
ls -lh dist/
echo "=== File count ==="
echo "Wheels: $(ls dist/*.whl 2>/dev/null | wc -l)"
echo "Sdist: $(ls dist/*.tar.gz 2>/dev/null | wc -l)"
- name: Verify wheels are valid
run: |
pip install check-wheel-contents
for wheel in dist/*.whl; do
echo "Checking $wheel"
python -m zipfile -t "$wheel" || echo "WARNING: $wheel may be corrupted"
check-wheel-contents "$wheel" || echo "WARNING: $wheel failed check"
done
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/