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

37 lines
1.1 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. If not set, all crates in the workspace are processed.'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Check for semver violations
shell: bash
run: |
set -euxo pipefail
# Colorize output, since GitHub Actions terminals support color.
export CARGO_TERM_COLOR=always
# If crate to check is specified, pass it to cargo-semver-checks,
# otherwise use `--workspace` option.
if [[ "${{ inputs.crate-name }}" == '' ]]; then
export PACKAGE_OPTION="--workspace"
else
export PACKAGE_OPTION="--package ${{ inputs.crate-name }}"
fi
# Check for semver violations.
cargo install cargo-semver-checks --locked
cargo semver-checks check-release $PACKAGE_OPTION