name: Release
on:
push:
tags: ["v*.*.*"]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches the workspace version
run: |
tag="${GITHUB_REF_NAME#v}"
for p in geomcore geomcore-py; do
v="$(cargo metadata --no-deps --format-version 1 \
| jq -r --arg p "$p" '.packages[] | select(.name == $p) | .version')"
if [ "$v" != "$tag" ]; then
echo "::error::$p is at version $v but the tag is $tag"
exit 1
fi
done
- run: cargo test
- run: cargo test --doc
build-wheels:
needs: check
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64
- os: ubuntu-latest
target: aarch64
- os: windows-latest
target: x64
- os: macos-latest
target: universal2-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --manifest-path geomcore-py/Cargo.toml
manylinux: auto
- uses: actions/upload-artifact@v4
with:
name: dist-wheel-${{ matrix.os }}-${{ matrix.target }}
path: dist
build-sdist:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path geomcore-py/Cargo.toml
- uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist
publish-pypi:
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/geomcore
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
publish-crates-io:
needs: check
runs-on: ubuntu-latest
environment: crates-io
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish to crates.io (skipped if the version is already there)
run: |
v="${GITHUB_REF_NAME#v}"
if curl -fsS -A "geomcore-release-workflow" \
"https://crates.io/api/v1/crates/geomcore/$v" >/dev/null 2>&1; then
echo "geomcore $v is already on crates.io; skipping publish"
else
cargo publish -p geomcore
fi
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
github-release:
needs: [publish-pypi, publish-crates-io]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist
- run: gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --generate-notes
env:
GH_TOKEN: ${{ github.token }}