-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (169 loc) · 5.68 KB
/
Copy pathrelease.yml
File metadata and controls
178 lines (169 loc) · 5.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
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
test:
uses: ./.github/workflows/test.yml
# Verify the tag version matches Cargo.toml before publishing anything
verify:
name: Verify version
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: All package manifests agree
run: bash scripts/check-versions.sh
- name: Check tag matches workspace version
run: |
TAG="${GITHUB_REF_NAME#v}"
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
if [ "$TAG" != "$CARGO_VERSION" ]; then
echo "Tag v$TAG does not match Cargo.toml version $CARGO_VERSION"
exit 1
fi
crates-io:
name: Publish to crates.io
needs: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo publish -p nj --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
pypi-build:
name: Build wheels (${{ matrix.target }})
needs: verify
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64
manylinux: auto
- os: ubuntu-latest
target: aarch64
manylinux: auto
- os: macos-latest
target: universal2-apple-darwin
- os: windows-latest
target: x86_64
steps:
- uses: actions/checkout@v4
- run: cp README.md python/README.md
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: PyO3/maturin-action@v1
with:
command: build
# Nightly toolchain: the published wheels enable `nj/simd`, which uses
# the unstable `portable_simd` feature for the explicit core::simd
# distance kernel (~5-7x faster distance computation than scalar).
# End users install the prebuilt wheel and never need nightly themselves.
# Pinned for reproducible releases — keep in sync with the `simd-nightly`
# job in test.yml; bump both together. The sdist (built on stable) keeps
# the autovectorized scalar kernel, so source installs need no nightly.
rust-toolchain: nightly-2026-06-02
# `--features` is listed in full (not just the simd delta) so the build is
# correct whether maturin merges with or replaces `[tool.maturin] features`.
# The crate is built with pyo3's `abi3-py310` feature, so a single
# stable-ABI wheel per platform covers CPython 3.10+ — no per-minor
# interpreter list needed.
args: >
--release
--out dist
--features pyo3/extension-module,nj/parallel,nj/simd
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
working-directory: python
- uses: actions/upload-artifact@v4
with:
name: wheels-${{matrix.os}}-${{ matrix.target }}
path: python/dist
pypi-sdist:
name: Build sdist
needs: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cp README.md python/README.md
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: python
- uses: actions/upload-artifact@v4
with:
name: sdist
path: python/dist
pypi-publish:
name: Publish to PyPI
needs: [pypi-build, pypi-sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/nj_py
permissions:
id-token: write # required for OIDC trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: Create GitHub release
needs: [crates-io, pypi-publish, npm]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract version
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
body: |
| Registry | Package |
|----------|---------|
| crates.io | https://crates.io/crates/nj/${{ steps.version.outputs.version }} |
| PyPI | https://pypi.org/project/nj_py/${{ steps.version.outputs.version }}/ |
| npm | https://www.npmjs.com/package/@holmrenser/nj/v/${{ steps.version.outputs.version }} |
npm:
name: Publish to npm
needs: verify
runs-on: ubuntu-latest
permissions:
id-token: write # required for OIDC trusted publishing
contents: read # required to checkout code
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
with:
workspaces: wasm -> wasm/target
- uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: https://registry.npmjs.org
- run: cp README.md wasm/README.md
- run: npm ci
working-directory: wasm
- run: CARGO_TARGET_DIR=target npm run build
working-directory: wasm
- run: npm publish --access public --provenance
working-directory: wasm