-
Notifications
You must be signed in to change notification settings - Fork 1
248 lines (213 loc) · 6.66 KB
/
Copy pathrelease.yml
File metadata and controls
248 lines (213 loc) · 6.66 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
prepare-release:
name: Prepare release version
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Extract version from tag
id: version
run: |
# Remove 'v' prefix from tag
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "Release version: $TAG_VERSION"
echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT
- name: Update version in Cargo.toml
run: |
VERSION="${{ steps.version.outputs.version }}"
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml
# Only commit if there are changes
if ! git diff-index --quiet HEAD --; then
git commit -m "chore: release version $VERSION"
git push origin HEAD:main
else
echo "Version already correct in Cargo.toml, skipping commit"
fi
build-wheels:
name: Build wheels on ${{ matrix.platform.os }}
needs: prepare-release
runs-on: ${{ matrix.platform.runner }}
permissions:
contents: read
strategy:
matrix:
platform:
- runner: ubuntu-latest
os: linux
target: x86_64
- runner: ubuntu-latest
os: linux
target: aarch64
- runner: macos-latest # ARM64, cross-compiles x86_64
os: macos
target: x86_64
- runner: macos-latest # ARM64
os: macos-arm
target: aarch64
- runner: windows-latest
os: windows
target: x64
steps:
- uses: actions/checkout@v4
with:
ref: main # Get the version update commit
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
working-directory: bindings-python
target: ${{ matrix.platform.target }}
command: build
args: --release --out dist --interpreter 3.11 3.12 3.13
manylinux: ${{ matrix.platform.os == 'linux' && 'auto' || '' }}
- name: Upload wheels to GitHub artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.target }}
path: bindings-python/dist
build-sdist:
name: Build source distribution
needs: prepare-release
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
working-directory: bindings-python
command: sdist
args: --out dist
- name: Upload sdist to GitHub artifacts
uses: actions/upload-artifact@v4
with:
name: sdist
path: bindings-python/dist
publish-to-pypi:
name: Publish release to PyPI
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
with:
command: upload
args: --skip-existing dist/*
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
publish-to-npm:
name: Publish WASM bindings to npm
needs: prepare-release
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build WASM package
run: |
cd bindings-wasm
wasm-pack build --target web
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
run: |
cd bindings-wasm/pkg
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
create-github-release:
name: Create GitHub Release
needs: [prepare-release, publish-to-pypi, publish-to-npm]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release v${{ needs.prepare-release.outputs.version }}
files: dist/*
draft: false
prerelease: false
bump-for-next-dev:
name: Bump version for next dev cycle
needs: [prepare-release, publish-to-pypi, publish-to-npm]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Bump to next patch version
run: |
CURRENT_VERSION="${{ needs.prepare-release.outputs.version }}"
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
MAJOR="${VERSION_PARTS[0]}"
MINOR="${VERSION_PARTS[1]}"
PATCH="${VERSION_PARTS[2]}"
NEXT_PATCH=$((PATCH + 1))
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
echo "Bumping from $CURRENT_VERSION to $NEXT_VERSION for next dev cycle"
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/" Cargo.toml
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml
git commit -m "chore: bump version to $NEXT_VERSION for next dev cycle [skip ci]"
git push