name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update versions from tag
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "Updating to version: $VERSION"
# Update pyproject.toml
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
# Update Cargo.toml package version only
awk -v ver="$VERSION" '
/^\[package\]/ { in_package = 1 }
in_package && /^version = / && !done {
sub(/version = ".*"/, "version = \"" ver "\"");
done = 1
}
/^\[/ && !/^\[package\]/ { in_package = 0 }
{ print }
' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build Python wheels
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --sdist --out dist
manylinux: auto
- name: Upload to PyPI
run: |
pip install --upgrade maturin
maturin upload dist/* --non-interactive
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish to crates.io
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/*.whl
dist/*.tar.gz