-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·211 lines (177 loc) · 6.43 KB
/
release.yml
File metadata and controls
executable file
·211 lines (177 loc) · 6.43 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
210
211
name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.2.0)'
required: true
type: string
env:
CARGO_TERM_COLOR: always
jobs:
# =============================================================================
# Build and Publish Wheels
# =============================================================================
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: dist/
retention-days: 30
# =============================================================================
# Build Source Distribution
# =============================================================================
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install maturin
run: pip install maturin
- name: Build sdist
run: maturin sdist --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/
retention-days: 30
# =============================================================================
# Publish to PyPI
# =============================================================================
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build-wheels, build-sdist]
permissions:
id-token: write # For trusted publishing
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: List distributions
run: ls -la dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: false
# =============================================================================
# Publish to TestPyPI (for testing)
# =============================================================================
publish-testpypi:
name: Publish to TestPyPI
runs-on: ubuntu-latest
needs: [build-wheels, build-sdist]
if: github.event_name == 'workflow_dispatch' # Only for manual testing
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/
# =============================================================================
# Verify Release
# =============================================================================
verify-release:
name: Verify PyPI Release
runs-on: ubuntu-latest
needs: publish-pypi
steps:
- name: Wait for PyPI
run: sleep 60
- name: Install from PyPI
run: |
pip install --upgrade pip
pip install constraint-theory
- name: Verify import
run: |
python -c "from constraint_theory import PythagoreanManifold, __version__; print(f'Version: {__version__}')"
python -c "
from constraint_theory import PythagoreanManifold
m = PythagoreanManifold(200)
x, y, noise = m.snap(0.577, 0.816)
print(f'Snap result: ({x:.4f}, {y:.4f}), noise={noise:.6f}')
assert abs(x - 0.6) < 0.01, f'Expected x≈0.6, got {x}'
assert abs(y - 0.8) < 0.01, f'Expected y≈0.8, got {y}'
print('Verification passed!')
"
- name: Run example
run: |
python -c "
from constraint_theory import PythagoreanManifold, generate_triples
# Create manifold
m = PythagoreanManifold(200)
print(f'Manifold: {m}')
print(f'States: {m.state_count}')
# Generate some triples
triples = generate_triples(50)
print(f'Generated {len(triples)} triples')
# Test batch operation
vectors = [[0.6, 0.8], [0.707, 0.707], [0.1, 0.995]]
results = m.snap_batch(vectors)
print(f'Batch results: {len(results)}')
print('All checks passed!')
"
# =============================================================================
# Create GitHub Release Notes
# =============================================================================
update-release-notes:
name: Update Release Notes
runs-on: ubuntu-latest
needs: verify-release
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- name: Extract changelog
id: changelog
run: |
# Extract the latest version's changelog
VERSION=${{ github.event.release.tag_name }}
echo "version=${VERSION}" >> $GITHUB_OUTPUT
# Try to extract changelog entry
if [ -f CHANGELOG.md ]; then
# Get the section for this version
sed -n "/## \[${VERSION#v}\]/,/## \[/p" CHANGELOG.md | head -n -1 > /tmp/release_notes.md
echo "changelog<<EOF" >> $GITHUB_OUTPUT
cat /tmp/release_notes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Update release
uses: softprops/action-gh-release@v1
with:
body: |
## Installation
```bash
pip install constraint-theory==${{ steps.changelog.outputs.version }}
```
## What's Changed
${{ steps.changelog.outputs.changelog }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.release.tag_name }}...${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}