cargo-semver-checks/action.yml

46 lines
1.5 KiB
YAML
Raw Normal View History

name: 'cargo-semver-checks'
2022-07-21 01:34:12 +02:00
description: 'Ensure the public API in your Rust crate follows semantic versioning'
2022-08-10 07:28:06 +02:00
branding:
icon: 'check-circle'
2022-08-10 07:28:06 +02:00
color: 'green'
inputs:
crate-name:
description: 'The crate whose API to check for semver'
required: false
default: ''
crate-target:
2022-08-07 18:36:01 +02:00
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
2022-07-21 01:41:14 +02:00
- name: Build rustdoc and check it
2022-07-21 01:57:47 +02:00
shell: bash
2022-07-21 01:41:14 +02:00
run: |
2022-07-21 02:08:54 +02:00
set -euxo pipefail
2022-07-21 01:41:14 +02:00
# Colorize output, since GitHub Actions terminals support color.
export CARGO_TERM_COLOR=always
2022-07-21 01:41:14 +02:00
export PACKAGE_NAME="${{ inputs.crate-name }}"
if [[ "$PACKAGE_NAME" == '' ]]; then
2022-07-21 02:08:54 +02:00
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"
2022-07-21 01:41:14 +02:00
fi
2022-07-21 01:41:14 +02:00
# Check for semver violations.
cargo install cargo-semver-checks --locked
cargo semver-checks check-release --package "$PACKAGE_NAME"