name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
env:
MSRV: "1.85.0"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cargo Format Check
run: cargo fmt --check
- name: Clippy Check
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Doc Check
run: RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps --document-private-items
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Run Tests
run: cargo test --all-features
msrv:
name: MSRV Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ env.MSRV }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MSRV }}
- name: Check compilation
run: cargo check --all-features
- name: Run Tests
run: cargo test --all-features
publish-main:
name: Publish dynamodb-facade
needs: [lint, test, msrv]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish main crate
run: cargo publish
release:
name: Create GitHub Release
needs: publish-main
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract changelog section
run: |
VERSION="${GITHUB_REF_NAME#v}"
awk -v ver="$VERSION" '
/^## \[/ {
if (found) exit
split($0, a, /[\[\]]/)
if (a[2] == ver) { found=1; next }
}
found && match($0, /^\[[0-9]+\.[0-9]+\.[0-9]+\]: (.+)/, m) { link=m[1]; next }
found { print }
END { if (link) print "\n[All Changes](" link ")" }
' CHANGELOG.md | sed -e '/./,$!d' -e :a -e '/^\n*$/{$d;N;ba;}' > /tmp/release-body.md
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file /tmp/release-body.md