name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Verify the crate version matches the tag
run: |
tag="${GITHUB_REF_NAME#v}"
crate="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')"
if [ "$tag" != "$crate" ]; then
echo "::error::tag v$tag does not match Cargo.toml version $crate"
exit 1
fi
echo "releasing nusadb@$crate"
- name: Format and clippy
run: |
cargo fmt --all --check
for features in "" "tls" "async" "async-tls"; do
cargo clippy --all-targets --no-default-features --features "${features}" -- -D warnings
done
- name: Test
run: cargo test --all-features
- name: Package
run: cargo package
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish
github-release:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "${GITHUB_REF_NAME}" --generate-notes --verify-tag