cargo-semver-checks/action.yml
2023-02-27 16:42:26 -05:00

45 lines
1.5 KiB
YAML

name: 'cargo-semver-checks'
description: 'Ensure the public API in your Rust crate follows semantic versioning'
branding:
icon: 'check-circle'
color: 'green'
inputs:
crate-name:
description: 'The crate whose API to check for semver'
required: false
default: ''
crate-target:
description: 'By default, check the library target of the crate. To check a different target (e.g. a binary target), set this to `--bin <NAME>`'
required: false
default: '--lib'
version-tag-prefix:
description: 'The prefix to use for the git tag for a version; the default "v" creates tags like "v1.0.0"'
required: false
default: 'v'
runs:
using: "composite"
steps:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Build rustdoc and check it
shell: bash
run: |
set -euxo pipefail
# Colorize output, since GitHub Actions terminals support color.
export CARGO_TERM_COLOR=always
export PACKAGE_NAME="${{ inputs.crate-name }}"
if [[ "$PACKAGE_NAME" == '' ]]; then
export PACKAGE_NAME="$("$GITHUB_ACTION_PATH/find_workspace_crates.sh")"
else
# cargo rustdoc uses the exact package name, not the "underscores" version.
export RUSTDOC_EARLY_FLAGS="--package $PACKAGE_NAME $RUSTDOC_EARLY_FLAGS"
fi
# Check for semver violations.
cargo install cargo-semver-checks --locked
cargo semver-checks check-release --package "$PACKAGE_NAME"