scriptrs 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. scriptrs-0.5.0/.gitattributes +4 -0
  2. scriptrs-0.5.0/.github/workflows/ci.yml +106 -0
  3. scriptrs-0.5.0/.github/workflows/package.yml +524 -0
  4. scriptrs-0.5.0/.gitignore +6 -0
  5. scriptrs-0.5.0/CHANGELOG.md +81 -0
  6. scriptrs-0.5.0/Cargo.lock +1014 -0
  7. scriptrs-0.5.0/Cargo.toml +112 -0
  8. scriptrs-0.5.0/LICENSE +201 -0
  9. scriptrs-0.5.0/PKG-INFO +184 -0
  10. scriptrs-0.5.0/README.md +768 -0
  11. scriptrs-0.5.0/assets/icon.svg +14 -0
  12. scriptrs-0.5.0/crates/scriptrs-python/Cargo.lock +1305 -0
  13. scriptrs-0.5.0/crates/scriptrs-python/Cargo.toml +45 -0
  14. scriptrs-0.5.0/crates/scriptrs-python/LICENSE +201 -0
  15. scriptrs-0.5.0/crates/scriptrs-python/README.md +152 -0
  16. scriptrs-0.5.0/crates/scriptrs-python/src/audio.rs +155 -0
  17. scriptrs-0.5.0/crates/scriptrs-python/src/lib.rs +114 -0
  18. scriptrs-0.5.0/crates/scriptrs-python/src/pipeline.rs +402 -0
  19. scriptrs-0.5.0/crates/scriptrs-python/src/results.rs +116 -0
  20. scriptrs-0.5.0/crates/scriptrs-python/src/samples.rs +93 -0
  21. scriptrs-0.5.0/crates/scriptrs-python/tests/conftest.py +58 -0
  22. scriptrs-0.5.0/crates/scriptrs-python/tests/data/librispeech-1089-134686-0007.wav +0 -0
  23. scriptrs-0.5.0/crates/scriptrs-python/tests/test_scriptrs.py +170 -0
  24. scriptrs-0.5.0/deny.toml +32 -0
  25. scriptrs-0.5.0/examples/cuda_bench.rs +487 -0
  26. scriptrs-0.5.0/examples/inspect_coreml_compute/macos.rs +397 -0
  27. scriptrs-0.5.0/examples/inspect_coreml_compute/main.rs +18 -0
  28. scriptrs-0.5.0/examples/quantize_native.rs +48 -0
  29. scriptrs-0.5.0/examples/scheduler_bench.rs +508 -0
  30. scriptrs-0.5.0/examples/stream_bench.rs +289 -0
  31. scriptrs-0.5.0/examples/transcribe_wav.rs +364 -0
  32. scriptrs-0.5.0/greptile.json +3 -0
  33. scriptrs-0.5.0/justfile +155 -0
  34. scriptrs-0.5.0/pyproject.toml +64 -0
  35. scriptrs-0.5.0/python/scriptrs/__init__.py +251 -0
  36. scriptrs-0.5.0/python/scriptrs/_cuda.py +97 -0
  37. scriptrs-0.5.0/python/scriptrs/_errors.py +30 -0
  38. scriptrs-0.5.0/python/scriptrs/_native.pyi +80 -0
  39. scriptrs-0.5.0/python/scriptrs/cli.py +103 -0
  40. scriptrs-0.5.0/python/scriptrs/py.typed +0 -0
  41. scriptrs-0.5.0/src/backend/host_loop.rs +463 -0
  42. scriptrs-0.5.0/src/backend/policy.rs +355 -0
  43. scriptrs-0.5.0/src/backend.rs +65 -0
  44. scriptrs-0.5.0/src/config.rs +13 -0
  45. scriptrs-0.5.0/src/constants.rs +25 -0
  46. scriptrs-0.5.0/src/coreml/array.rs +280 -0
  47. scriptrs-0.5.0/src/coreml/runtime.rs +107 -0
  48. scriptrs-0.5.0/src/coreml.rs +752 -0
  49. scriptrs-0.5.0/src/cuda/batcher.rs +345 -0
  50. scriptrs-0.5.0/src/cuda/decoder/tests/filter.rs +341 -0
  51. scriptrs-0.5.0/src/cuda/decoder/tests.rs +224 -0
  52. scriptrs-0.5.0/src/cuda/decoder.rs +1266 -0
  53. scriptrs-0.5.0/src/cuda/encoder/attention.rs +1014 -0
  54. scriptrs-0.5.0/src/cuda/encoder/quantized.rs +890 -0
  55. scriptrs-0.5.0/src/cuda/encoder/stream.rs +832 -0
  56. scriptrs-0.5.0/src/cuda/encoder.rs +1452 -0
  57. scriptrs-0.5.0/src/cuda/fp16.rs +128 -0
  58. scriptrs-0.5.0/src/cuda/kernels/attention.rs +246 -0
  59. scriptrs-0.5.0/src/cuda/kernels/decode.rs +782 -0
  60. scriptrs-0.5.0/src/cuda/kernels/stream.rs +836 -0
  61. scriptrs-0.5.0/src/cuda/kernels.rs +943 -0
  62. scriptrs-0.5.0/src/cuda/lt.rs +537 -0
  63. scriptrs-0.5.0/src/cuda/model.rs +717 -0
  64. scriptrs-0.5.0/src/cuda/ptx/attention.sm80.ptx +5556 -0
  65. scriptrs-0.5.0/src/cuda/ptx/decode.sm75.ptx +6427 -0
  66. scriptrs-0.5.0/src/cuda/ptx/encoder.sm75.ptx +10880 -0
  67. scriptrs-0.5.0/src/cuda/ptx/quant.sm75.ptx +1015 -0
  68. scriptrs-0.5.0/src/cuda/quant.rs +688 -0
  69. scriptrs-0.5.0/src/cuda/stored.rs +423 -0
  70. scriptrs-0.5.0/src/cuda/streaming/prompt.rs +168 -0
  71. scriptrs-0.5.0/src/cuda/streaming.rs +421 -0
  72. scriptrs-0.5.0/src/cuda/test_support.rs +75 -0
  73. scriptrs-0.5.0/src/cuda.rs +228 -0
  74. scriptrs-0.5.0/src/decode.rs +293 -0
  75. scriptrs-0.5.0/src/deployment.rs +596 -0
  76. scriptrs-0.5.0/src/error.rs +117 -0
  77. scriptrs-0.5.0/src/frontend/stream.rs +271 -0
  78. scriptrs-0.5.0/src/frontend.rs +529 -0
  79. scriptrs-0.5.0/src/language.rs +603 -0
  80. scriptrs-0.5.0/src/lib.rs +218 -0
  81. scriptrs-0.5.0/src/long_form/execute.rs +714 -0
  82. scriptrs-0.5.0/src/long_form/merge.rs +228 -0
  83. scriptrs-0.5.0/src/long_form/planner.rs +1424 -0
  84. scriptrs-0.5.0/src/long_form/vad.rs +493 -0
  85. scriptrs-0.5.0/src/long_form.rs +1761 -0
  86. scriptrs-0.5.0/src/model.rs +346 -0
  87. scriptrs-0.5.0/src/model_io.rs +291 -0
  88. scriptrs-0.5.0/src/models/hub.rs +439 -0
  89. scriptrs-0.5.0/src/models.rs +672 -0
  90. scriptrs-0.5.0/src/native/silero.rs +730 -0
  91. scriptrs-0.5.0/src/native/spec.rs +834 -0
  92. scriptrs-0.5.0/src/native/weights.rs +335 -0
  93. scriptrs-0.5.0/src/native.rs +10 -0
  94. scriptrs-0.5.0/src/pipeline.rs +346 -0
  95. scriptrs-0.5.0/src/preprocessing.rs +493 -0
  96. scriptrs-0.5.0/src/scheduler.rs +1094 -0
  97. scriptrs-0.5.0/src/streaming.rs +593 -0
  98. scriptrs-0.5.0/src/test_support.rs +162 -0
  99. scriptrs-0.5.0/src/types.rs +49 -0
  100. scriptrs-0.5.0/src/vocab.rs +388 -0
  101. scriptrs-0.5.0/tests/scheduled.rs +338 -0
@@ -0,0 +1,4 @@
1
+ # LF in every checkout, Windows included: the PTX kernels are embedded with
2
+ # include_str!, so CRLF would change what a Windows build ships to the driver
3
+ * text=auto eol=lf
4
+ *.wav binary
@@ -0,0 +1,106 @@
1
+ name: CI
2
+
3
+ on:
4
+ workflow_dispatch: {}
5
+ push:
6
+ branches:
7
+ - master
8
+ pull_request:
9
+ branches:
10
+ - master
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ # a new push to a pull request supersedes its running checks
16
+ concurrency:
17
+ group: ci-${{ github.ref }}
18
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19
+
20
+ env:
21
+ CARGO_TERM_COLOR: always
22
+ RUSTFLAGS: -D warnings
23
+
24
+ jobs:
25
+ # the same gates as `just check`, through its recipes so the two stay in step
26
+ lint:
27
+ name: Format and dependencies
28
+ runs-on: ubuntu-24.04
29
+ steps:
30
+ - uses: actions/checkout@v6
31
+
32
+ - name: Install Rust toolchain
33
+ uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
34
+ with:
35
+ toolchain: stable
36
+ components: rustfmt
37
+
38
+ # a prebuilt cargo-deny instead of cargo-deny-action, whose Docker build fails
39
+ # whenever Docker Hub rate-limits the runner
40
+ - name: Install just and cargo-deny
41
+ uses: taiki-e/install-action@86f7a0ffb25f40114606501a311ebcfaf882ea32 # v2.88.0
42
+ with:
43
+ tool: just,cargo-deny@0.20.2
44
+
45
+ # `just fmt` and `just python-lint` run ruff through uvx
46
+ - name: Install uv
47
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
48
+
49
+ # `just fmt` rewrites files, so any diff it leaves means the code wasn't formatted
50
+ - name: Format
51
+ run: |
52
+ just fmt
53
+ git diff --exit-code
54
+
55
+ - name: Python lints
56
+ run: just python-lint
57
+
58
+ - name: No ONNX Runtime
59
+ run: just no-ort
60
+
61
+ - name: Advisories, licenses and sources
62
+ run: just deny
63
+
64
+ check:
65
+ name: Clippy and tests (${{ matrix.name }})
66
+ runs-on: ${{ matrix.os }}
67
+ strategy:
68
+ fail-fast: false
69
+ matrix:
70
+ include:
71
+ # builds the CUDA backend; a GitHub runner has no GPU, and the tests that
72
+ # need one are ignored by default
73
+ - name: Linux x86_64
74
+ os: ubuntu-24.04
75
+ - name: macOS arm64
76
+ os: macos-15
77
+ # the CUDA backend and the Python bindings' CUDA path, as on Linux; there is
78
+ # no GPU here either
79
+ - name: Windows x86_64
80
+ os: windows-2025
81
+ steps:
82
+ - uses: actions/checkout@v6
83
+
84
+ - name: Install Rust toolchain
85
+ uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
86
+ with:
87
+ toolchain: stable
88
+ components: clippy
89
+
90
+ - name: Install just
91
+ uses: taiki-e/install-action@86f7a0ffb25f40114606501a311ebcfaf882ea32 # v2.88.0
92
+ with:
93
+ tool: just
94
+
95
+ - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
96
+
97
+ - name: Clippy
98
+ run: just clippy
99
+
100
+ # docs.rs builds on Linux with every feature, so the CUDA docs only build here
101
+ - name: Docs as docs.rs builds them
102
+ if: runner.os == 'Linux'
103
+ run: just doc
104
+
105
+ - name: Test
106
+ run: just test --all-features
@@ -0,0 +1,524 @@
1
+ # Build, test and publish scriptrs: the Python wheels and sdist, the crate, and a
2
+ # GitHub release, all from one version tag
3
+ #
4
+ # To release:
5
+ # 1. set the version in Cargo.toml and crates/scriptrs-python/Cargo.toml
6
+ # 2. rename the CHANGELOG.md "Unreleased" section to "[X.Y.Z] - YYYY-MM-DD" and
7
+ # update the compare links at the bottom
8
+ # 3. merge, then tag the merge commit and push the tag:
9
+ # git tag vX.Y.Z
10
+ # git push origin vX.Y.Z
11
+ #
12
+ # The tag publishes to TestPyPI and installs that release. The pypi environment then
13
+ # waits for a reviewer, and once approved the workflow publishes the Python package to
14
+ # PyPI, then the crate to crates.io, then a GitHub release with the tag's CHANGELOG.md
15
+ # entry as its notes and the wheels and sdist attached. A tag whose version or
16
+ # changelog entry is wrong fails before anything is published. PyPI, TestPyPI and
17
+ # crates.io all trust this workflow through OIDC, so no token is stored. Every publish
18
+ # skips files already uploaded, so "Re-run failed jobs" finishes a partial release
19
+
20
+ name: Package
21
+
22
+ on:
23
+ workflow_dispatch: {}
24
+ push:
25
+ branches:
26
+ - master
27
+ tags:
28
+ - "v*"
29
+ pull_request:
30
+ branches:
31
+ - master
32
+
33
+ permissions:
34
+ contents: read
35
+
36
+ env:
37
+ CARGO_TERM_COLOR: always
38
+ RUSTFLAGS: -D warnings
39
+
40
+ jobs:
41
+ # the crate as crates.io receives it, built as a dependency with each feature set
42
+ crate:
43
+ name: Crate
44
+ runs-on: ubuntu-24.04
45
+ steps:
46
+ - uses: actions/checkout@v6
47
+
48
+ - name: Install Rust toolchain
49
+ uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
50
+ with:
51
+ toolchain: stable
52
+
53
+ - name: Install just
54
+ uses: taiki-e/install-action@86f7a0ffb25f40114606501a311ebcfaf882ea32 # v2.88.0
55
+ with:
56
+ tool: just
57
+
58
+ - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
59
+
60
+ - name: Package and build as a dependency
61
+ run: just package
62
+
63
+ # one abi3 wheel per platform with the backend that platform runs; the Linux and
64
+ # Windows wheels build without a GPU or CUDA toolkit because CUDA is loaded at run
65
+ # time
66
+ wheels:
67
+ name: Wheel (${{ matrix.name }})
68
+ runs-on: ${{ matrix.os }}
69
+ strategy:
70
+ fail-fast: false
71
+ matrix:
72
+ include:
73
+ - name: Linux x86_64, CUDA
74
+ os: ubuntu-24.04
75
+ target: x86_64-unknown-linux-gnu
76
+ manylinux: "2_28"
77
+ rustflags: -D warnings
78
+ - name: macOS arm64, Core ML
79
+ os: macos-15
80
+ target: aarch64-apple-darwin
81
+ manylinux: "off"
82
+ rustflags: -D warnings
83
+ # the C runtime is linked statically, so the extension runs without the
84
+ # Visual C++ redistributable whichever Python loads it. RUSTFLAGS replaces the
85
+ # per-target flags rather than adding to them, so each target spells out its
86
+ # full set
87
+ - name: Windows x86_64, CUDA
88
+ os: windows-2025
89
+ target: x86_64-pc-windows-msvc
90
+ manylinux: "off"
91
+ rustflags: -D warnings -C target-feature=+crt-static
92
+ env:
93
+ RUSTFLAGS: ${{ matrix.rustflags }}
94
+ steps:
95
+ - uses: actions/checkout@v6
96
+
97
+ # a Windows checkout without symlink support writes the LICENSE symlink as a text
98
+ # file holding its target, which maturin would ship in the wheel as the license;
99
+ # removing it first keeps cp from writing through a real symlink onto itself
100
+ - name: Resolve the LICENSE symlink
101
+ if: runner.os == 'Windows'
102
+ shell: bash
103
+ run: |
104
+ rm -f crates/scriptrs-python/LICENSE
105
+ cp LICENSE crates/scriptrs-python/LICENSE
106
+
107
+ - name: Build wheel
108
+ uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
109
+ with:
110
+ command: build
111
+ target: ${{ matrix.target }}
112
+ manylinux: ${{ matrix.manylinux }}
113
+ args: --release --locked --out dist -m crates/scriptrs-python/Cargo.toml
114
+ # tag builds are published, so they never reuse objects from the shared cache
115
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
116
+
117
+ - name: Check wheel size
118
+ shell: bash
119
+ run: |
120
+ set -euo pipefail
121
+ # PyPI rejects files over 100 MB unless the project's limit is raised
122
+ limit=$((90 * 1000 * 1000))
123
+ for wheel in dist/*.whl; do
124
+ size="$(wc -c < "$wheel")"
125
+ echo "$(basename "$wheel"): $size bytes"
126
+ test "$size" -le "$limit"
127
+ done
128
+
129
+ # CUDA must load at run time and the C runtime is static, so the extension may
130
+ # import only Python's stable ABI and Windows system DLLs
131
+ - name: Check the extension's imports
132
+ if: runner.os == 'Windows'
133
+ shell: bash
134
+ run: |
135
+ set -euo pipefail
136
+ unpacked="$RUNNER_TEMP/wheel"
137
+ mkdir -p "$unpacked"
138
+ # 7-Zip ships on the runner image, and a wheel is a zip
139
+ 7z x -y dist/*.whl -o"$unpacked" > /dev/null
140
+ ext="$(find "$unpacked" -name '_native*.pyd' -print -quit)"
141
+ test -n "$ext"
142
+ rustup component add llvm-tools
143
+ readobj="$(cygpath -u "$(rustc --print sysroot)")/lib/rustlib/x86_64-pc-windows-msvc/bin/llvm-readobj.exe"
144
+ # a Windows tool's output ends lines with CRLF
145
+ imports="$("$readobj" --coff-imports "$ext" | tr -d '\r' | sed -n 's/^ *Name: //p' | sort -u)"
146
+ echo "$imports"
147
+ if grep -Eiv '^(python3|kernel32|ntdll|advapi32|bcrypt|bcryptprimitives|ws2_32|userenv|secur32|crypt32|ole32|oleaut32|shell32|user32|synchronization|api-ms-win-core-[a-z0-9-]+)\.dll$' <<< "$imports"; then
148
+ echo "the extension imports a DLL outside Python and Windows itself" >&2
149
+ exit 1
150
+ fi
151
+
152
+ - name: Upload wheel
153
+ uses: actions/upload-artifact@v7
154
+ with:
155
+ name: python-wheel-${{ matrix.target }}
156
+ path: dist/*.whl
157
+
158
+ sdist:
159
+ name: Sdist
160
+ runs-on: ubuntu-24.04
161
+ steps:
162
+ - uses: actions/checkout@v6
163
+
164
+ # release tags are named after the scriptrs version, so a bindings version that
165
+ # lags behind fails here on the pull request instead of at publish time
166
+ - name: Check the bindings version matches scriptrs
167
+ run: |
168
+ set -euo pipefail
169
+ crate=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
170
+ bindings=$(sed -n 's/^version = "\(.*\)"/\1/p' crates/scriptrs-python/Cargo.toml | head -1)
171
+ if [ "$crate" != "$bindings" ]; then
172
+ echo "crates/scriptrs-python is $bindings but scriptrs is $crate; bump crates/scriptrs-python/Cargo.toml"
173
+ exit 1
174
+ fi
175
+
176
+ - name: Build sdist
177
+ uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
178
+ with:
179
+ command: sdist
180
+ args: --out dist -m crates/scriptrs-python/Cargo.toml
181
+
182
+ - name: Install Rust toolchain
183
+ uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
184
+ with:
185
+ toolchain: stable
186
+
187
+ - name: Install uv
188
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
189
+
190
+ # pip builds the sdist on platforms without a wheel, so build it the same way,
191
+ # outside the checkout; the runner has no GPU, so check the import only
192
+ - name: Install sdist into a fresh environment
193
+ shell: bash
194
+ working-directory: ${{ runner.temp }}
195
+ run: |
196
+ set -euo pipefail
197
+ uv venv --python 3.12 sdist-venv
198
+ uv pip install --python sdist-venv "$GITHUB_WORKSPACE"/dist/*.tar.gz
199
+ sdist-venv/bin/python -c "import scriptrs; print(scriptrs.__version__, scriptrs.BACKEND)"
200
+ sdist-venv/bin/scriptrs --version
201
+
202
+ - name: Upload sdist
203
+ uses: actions/upload-artifact@v7
204
+ with:
205
+ name: python-sdist
206
+ path: dist/*.tar.gz
207
+
208
+ tests:
209
+ name: Tests (${{ matrix.platform.name }}, Python ${{ matrix.python }})
210
+ needs: wheels
211
+ runs-on: ${{ matrix.platform.os }}
212
+ strategy:
213
+ fail-fast: false
214
+ matrix:
215
+ platform:
216
+ # a GitHub runner has no NVIDIA driver, so this checks that the CUDA wheel
217
+ # imports and fails cleanly before downloading a model
218
+ - name: Linux x86_64
219
+ os: ubuntu-24.04
220
+ target: x86_64-unknown-linux-gnu
221
+ # transcribes with Core ML; Parakeet v2 alone keeps the download near 0.5 GB
222
+ - name: macOS arm64
223
+ os: macos-15
224
+ target: aarch64-apple-darwin
225
+ # no NVIDIA driver either, so the same checks as on Linux
226
+ - name: Windows x86_64
227
+ os: windows-2025
228
+ target: x86_64-pc-windows-msvc
229
+ # the one abi3 wheel serves every version, so test the oldest and the newest
230
+ python: ["3.11", "3.14"]
231
+ env:
232
+ SCRIPTRS_TEST_MODELS: parakeet/v2
233
+ steps:
234
+ - uses: actions/checkout@v6
235
+
236
+ - name: Install uv
237
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
238
+
239
+ - name: Download wheel
240
+ uses: actions/download-artifact@v8
241
+ with:
242
+ name: python-wheel-${{ matrix.platform.target }}
243
+ path: dist
244
+
245
+ - name: Install wheel into a fresh environment
246
+ shell: bash
247
+ run: |
248
+ set -euo pipefail
249
+ uv venv --python ${{ matrix.python }} .venv-wheel
250
+ uv pip install --python .venv-wheel dist/*.whl pytest numpy
251
+
252
+ - name: Run tests
253
+ shell: bash
254
+ working-directory: crates/scriptrs-python
255
+ run: |
256
+ set -euo pipefail
257
+ # Windows venvs keep the interpreter in Scripts, not bin
258
+ python=../../.venv-wheel/bin/python
259
+ if [ "$RUNNER_OS" = Windows ]; then python=../../.venv-wheel/Scripts/python.exe; fi
260
+ "$python" -m pytest -rA
261
+
262
+ # checks a tag before anything is published: the crate's version must match it, and
263
+ # CHANGELOG.md needs its entry, which becomes the GitHub release notes
264
+ release-check:
265
+ name: Check the tag
266
+ if: startsWith(github.ref, 'refs/tags/v')
267
+ runs-on: ubuntu-24.04
268
+ steps:
269
+ - uses: actions/checkout@v6
270
+
271
+ # the GitHub release reads its notes with parse-changelog, so the same parser
272
+ # checks the entry here
273
+ - name: Install parse-changelog
274
+ uses: taiki-e/install-action@86f7a0ffb25f40114606501a311ebcfaf882ea32 # v2.88.0
275
+ with:
276
+ tool: parse-changelog
277
+
278
+ - name: Check the version and changelog
279
+ shell: bash
280
+ run: |
281
+ set -euo pipefail
282
+ version="${GITHUB_REF_NAME#v}"
283
+ crate=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
284
+ if [ "$crate" != "$version" ]; then
285
+ echo "Cargo.toml is $crate but the tag is $GITHUB_REF_NAME"
286
+ exit 1
287
+ fi
288
+ notes="$(parse-changelog CHANGELOG.md "$version")"
289
+ if [ -z "$notes" ]; then
290
+ echo "the CHANGELOG.md entry for $version is empty"
291
+ exit 1
292
+ fi
293
+
294
+ # a v* tag publishes to TestPyPI, installs that release, and only then publishes to
295
+ # PyPI; each index trusts this workflow and environment, so no token is stored
296
+ testpypi-publish:
297
+ name: Publish to TestPyPI
298
+ if: startsWith(github.ref, 'refs/tags/v')
299
+ needs: [release-check, crate, wheels, sdist, tests]
300
+ runs-on: ubuntu-24.04
301
+ environment:
302
+ name: testpypi
303
+ url: https://test.pypi.org/project/scriptrs/
304
+ permissions:
305
+ id-token: write
306
+ steps:
307
+ - name: Download wheels and sdist
308
+ uses: actions/download-artifact@v8
309
+ with:
310
+ pattern: python-*
311
+ path: dist
312
+ merge-multiple: true
313
+
314
+ - name: Check files match the tag
315
+ shell: bash
316
+ run: |
317
+ set -euo pipefail
318
+ version="${GITHUB_REF_NAME#v}"
319
+ ls -la dist
320
+ # the Linux, macOS and Windows wheels and the sdist
321
+ test "$(find dist -type f | wc -l)" -eq 4
322
+ for file in dist/*; do
323
+ case "$(basename "$file")" in
324
+ "scriptrs-${version}"-*.whl | "scriptrs-${version}.tar.gz") ;;
325
+ *) echo "$file does not match tag $GITHUB_REF_NAME"; exit 1 ;;
326
+ esac
327
+ done
328
+
329
+ - name: Publish
330
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
331
+ with:
332
+ repository-url: https://test.pypi.org/legacy/
333
+ skip-existing: true
334
+
335
+ testpypi-install:
336
+ name: Install from TestPyPI (${{ matrix.name }})
337
+ needs: testpypi-publish
338
+ runs-on: ${{ matrix.os }}
339
+ strategy:
340
+ fail-fast: false
341
+ matrix:
342
+ include:
343
+ - name: Linux x86_64
344
+ os: ubuntu-24.04
345
+ - name: macOS arm64
346
+ os: macos-15
347
+ - name: Windows x86_64
348
+ os: windows-2025
349
+ steps:
350
+ - uses: actions/checkout@v6
351
+
352
+ - name: Install uv
353
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
354
+
355
+ - name: Install the release and transcribe
356
+ shell: bash
357
+ run: |
358
+ set -euo pipefail
359
+ version="${GITHUB_REF_NAME#v}"
360
+ uv venv --python 3.12 .venv-release
361
+ # a new release can take a few minutes to appear in the index. Anyone can
362
+ # upload to TestPyPI, so nothing else is installed from it: these checks
363
+ # never load cuBLAS, the one dependency
364
+ for attempt in 1 2 3 4 5 6 7 8 9 10; do
365
+ if uv pip install --python .venv-release --no-cache --no-deps --only-binary scriptrs \
366
+ --index-url https://test.pypi.org/simple/ "scriptrs==${version}"; then
367
+ break
368
+ fi
369
+ test "$attempt" -lt 10
370
+ sleep 30
371
+ done
372
+ # Windows venvs keep their programs in Scripts, not bin
373
+ bin=.venv-release/bin
374
+ if [ "$RUNNER_OS" = Windows ]; then bin=.venv-release/Scripts; fi
375
+ "$bin/python" -c "import scriptrs; print(scriptrs.__version__, scriptrs.BACKEND)"
376
+ # only the macOS runner has a backend that can transcribe
377
+ if [ "$RUNNER_OS" = "macOS" ]; then
378
+ text="$("$bin/scriptrs" transcribe --model parakeet/v2 crates/scriptrs-python/tests/data/librispeech-1089-134686-0007.wav)"
379
+ printf '%s\n' "$text"
380
+ grep -qi 'indifference' <<< "$text"
381
+ fi
382
+
383
+ # the pypi environment's reviewer approves the release here, before anything
384
+ # outside TestPyPI is published
385
+ pypi-publish:
386
+ name: Publish to PyPI
387
+ needs: testpypi-install
388
+ runs-on: ubuntu-24.04
389
+ environment:
390
+ name: pypi
391
+ url: https://pypi.org/project/scriptrs/
392
+ permissions:
393
+ id-token: write
394
+ steps:
395
+ - name: Download wheels and sdist
396
+ uses: actions/download-artifact@v8
397
+ with:
398
+ pattern: python-*
399
+ path: dist
400
+ merge-multiple: true
401
+
402
+ - name: Publish
403
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
404
+ with:
405
+ skip-existing: true
406
+
407
+ crates-publish:
408
+ name: Publish to crates.io
409
+ needs: pypi-publish
410
+ runs-on: ubuntu-24.04
411
+ environment:
412
+ name: crates-io
413
+ url: https://crates.io/crates/scriptrs
414
+ permissions:
415
+ id-token: write
416
+ steps:
417
+ - uses: actions/checkout@v6
418
+
419
+ - name: Install Rust toolchain
420
+ uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
421
+ with:
422
+ toolchain: stable
423
+
424
+ # a rerun after a later job failed finds this version already published
425
+ - name: Check crates.io for this version
426
+ id: version
427
+ shell: bash
428
+ run: |
429
+ set -euo pipefail
430
+ version="${GITHUB_REF_NAME#v}"
431
+ status="$(curl -sS -o /dev/null -w '%{http_code}' -A 'scriptrs-release (github.com/avencera/scriptrs)' \
432
+ "https://crates.io/api/v1/crates/scriptrs/$version")"
433
+ case "$status" in
434
+ 200) echo "scriptrs $version is already on crates.io"; echo "publish=false" >> "$GITHUB_OUTPUT" ;;
435
+ 404) echo "publish=true" >> "$GITHUB_OUTPUT" ;;
436
+ *) echo "crates.io answered HTTP $status" >&2; exit 1 ;;
437
+ esac
438
+
439
+ - name: Get a crates.io token
440
+ if: steps.version.outputs.publish == 'true'
441
+ id: auth
442
+ uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6
443
+
444
+ - name: Publish
445
+ if: steps.version.outputs.publish == 'true'
446
+ env:
447
+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
448
+ run: cargo publish --locked -p scriptrs
449
+
450
+ # the release starts as a draft and is published only once its files are attached
451
+ github-release:
452
+ name: GitHub release
453
+ needs: crates-publish
454
+ runs-on: ubuntu-24.04
455
+ permissions:
456
+ contents: write
457
+ steps:
458
+ - uses: actions/checkout@v6
459
+ with:
460
+ persist-credentials: false
461
+
462
+ - name: Download wheels and sdist
463
+ uses: actions/download-artifact@v8
464
+ with:
465
+ pattern: python-*
466
+ path: dist
467
+ merge-multiple: true
468
+
469
+ # create-gh-release-action deletes a release that already exists, so a rerun
470
+ # leaves a published release alone and finishes a draft instead of recreating it
471
+ - name: Check for an existing release
472
+ id: existing
473
+ env:
474
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
475
+ shell: bash
476
+ run: |
477
+ set -euo pipefail
478
+ if draft="$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json isDraft --jq .isDraft 2> view.err)"; then
479
+ if [ "$draft" = true ]; then state=draft; else state=published; fi
480
+ elif grep -q 'release not found' view.err; then
481
+ state=none
482
+ else
483
+ # any other failure could hide a release the next step would delete
484
+ cat view.err >&2
485
+ exit 1
486
+ fi
487
+ echo "the $GITHUB_REF_NAME release is $state"
488
+ echo "state=$state" >> "$GITHUB_OUTPUT"
489
+
490
+ - name: Create a draft release
491
+ if: steps.existing.outputs.state == 'none'
492
+ uses: taiki-e/create-gh-release-action@eba8ea96c86cca8a37f1b56e94b4d13301fba651 # v1.11.0
493
+ with:
494
+ draft: true
495
+ # the tag's CHANGELOG.md entry becomes the release notes
496
+ changelog: CHANGELOG.md
497
+
498
+ # --clobber replaces files a failed run already attached. The release becomes
499
+ # latest only when no published stable release has a higher version, so a
500
+ # maintenance release of an older line leaves the newest one as latest
501
+ - name: Attach the wheels and sdist, then publish
502
+ if: steps.existing.outputs.state != 'published'
503
+ env:
504
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
505
+ shell: bash
506
+ run: |
507
+ set -euo pipefail
508
+ gh release upload "$GITHUB_REF_NAME" dist/* --clobber --repo "$GITHUB_REPOSITORY"
509
+
510
+ version="${GITHUB_REF_NAME#v}"
511
+ latest=false
512
+ if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
513
+ # a plain assignment, so set -e stops the step when the lookup fails
514
+ # instead of marking this release latest against an empty list
515
+ releases="$(gh release list --repo "$GITHUB_REPOSITORY" --exclude-drafts --exclude-pre-releases \
516
+ --limit 1000 --json tagName --jq '.[].tagName')"
517
+ newest="$(
518
+ printf '%s\n' "$releases" "$GITHUB_REF_NAME" \
519
+ | sed 's/^v//' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1
520
+ )"
521
+ if [ "$newest" = "$version" ]; then latest=true; fi
522
+ fi
523
+ echo "marking $GITHUB_REF_NAME latest: $latest"
524
+ gh release edit "$GITHUB_REF_NAME" --draft=false --latest="$latest" --repo "$GITHUB_REPOSITORY"
@@ -0,0 +1,6 @@
1
+ /target
2
+ /dev-tools
3
+ /fixtures/models
4
+ /.venv
5
+ /**/__pycache__
6
+ /crates/*/target