name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
verify:
name: Verify Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Verify version matches tag
run: |
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
TAG_VERSION=${GITHUB_REF#refs/tags/v}
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "Version mismatch: Cargo.toml has $CARGO_VERSION but tag is v$TAG_VERSION"
exit 1
fi
- name: Run tests
run: cargo test --all-features --lib
- name: Run clippy
run: cargo clippy --all-features -- -D warnings
- name: Build release
run: cargo build --release --all-features
- name: Build docs
run: cargo doc --no-deps --all-features
release:
name: Create Release
needs: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "First release"
CHANGES="Initial release"
else
CHANGES=$(git log --pretty=format:"- %s (%h)" $PREV_TAG..HEAD)
fi
echo "changes<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
generate_release_notes: true
body: |
## Changes
${{ steps.changelog.outputs.changes }}
## Installation
Add to your `Cargo.toml`:
```toml
[dependencies]
voltdb-client-rust = "${{ github.ref_name }}"
```
Or with cargo:
```bash
cargo add voltdb-client-rust
```
## Documentation
- [API Docs](https://docs.rs/voltdb-client-rust)
- [Repository](https://github.com/johnnywale/voltdb-client-rust)