name: Release
on:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Set version from tag
run: |
TAG_VERSION=${{ github.event.release.tag_name }}
TAG_VERSION=${TAG_VERSION#v}
sed -i "0,/^version = .*/s//version = \"$TAG_VERSION\"/" Cargo.toml
echo "Publishing version $TAG_VERSION"
- name: Run tests
run: cargo test --all-features
- name: Publish to crates.io
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}