name: Release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
release:
name: Tag and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read version from Cargo.toml
id: version
run: |
VER=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
echo "version=$VER" >> "$GITHUB_OUTPUT"
- name: Check tag doesn't already exist
run: |
if git rev-parse "refs/tags/v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag v${{ steps.version.outputs.version }} already exists"
exit 1
fi
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test --all-features
- name: Create tag
run: |
git tag "v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
generate_release_notes: true
body: |
See [CHANGELOG.md](https://github.com/dch-labs/loopctl/blob/master/CHANGELOG.md) for full details.
Published to [crates.io](https://crates.io/crates/loopctl).