name: Release
on:
push:
tags:
- 'v*'
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- run: npm ci
- name: Build native module
run: npm run build
- run: npm run test:all
build:
name: Build
needs: test
strategy:
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: windows-latest
target: i686-pc-windows-msvc
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- run: npm ci
- name: Build native module
run: npm run build -- --target ${{ matrix.settings.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: "*.node"
if-no-files-found: error
python-wheels:
name: Python Wheels
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install maturin
run: python -m pip install --upgrade pip maturin
- name: Build Python wheel
run: python -m maturin build --release -F python
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: python-wheel-${{ matrix.os }}-py${{ matrix.python-version }}
path: target/wheels/*.whl
if-no-files-found: error
publish-crates:
name: Publish to crates.io
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish:
name: Publish
needs:
- build
- python-wheels
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- run: npm ci
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts to root
run: |
find artifacts -name "*.node" -exec cp {} . \;
- name: Move Python wheels to root
run: |
find artifacts -name "*.whl" -exec cp {} . \;
- name: Generate index.js
run: npm run build
- name: Verify package contents
run: |
ls -la index.js sombra.d.ts *.node
- name: Verify Python wheels
run: ls -la *.whl
- uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Install twine
run: python -m pip install --upgrade pip twine
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: python -m twine upload --skip-existing *.whl
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
*.node
*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List available binaries
run: |
ls -la *.node
ls -la *.whl
- name: Publish to npm
run: npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}