mirror of
https://github.com/obi1kenobi/cargo-semver-checks-action.git
synced 2024-11-22 16:09:33 +01:00
Remove unused options
This commit is contained in:
parent
1b587be276
commit
bb926a3536
3 changed files with 11 additions and 77 deletions
41
README.md
41
README.md
|
@ -1,14 +1,9 @@
|
|||
# cargo-semver-checks-action
|
||||
Lint your crate API changes for semver violations.
|
||||
|
||||
By default, this action assumes that:
|
||||
- Your cargo workspace contains a single crate which contains a library target.
|
||||
- Your releases are tagged in git as `v{major}.{minor}.{patch}`, for example `v1.2.3`.
|
||||
|
||||
Single-crate workspaces can use it as:
|
||||
```yaml
|
||||
- name: Check semver
|
||||
uses: obi1kenobi/cargo-semver-checks-action@v1
|
||||
uses: obi1kenobi/cargo-semver-checks-action@v2
|
||||
- name: Publish to crates.io
|
||||
run: # your `cargo publish` code here
|
||||
```
|
||||
|
@ -19,33 +14,15 @@ Every argument is optional.
|
|||
|
||||
| Input | Description | Default |
|
||||
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------|---------|
|
||||
| crate-name | The crate whose API to check for semver (needed only in multi-crate workspaces). | |
|
||||
| crate-target | (Deprecated) By default, check the library target of the crate. To check a different target (e.g. a binary target), set this to `--bin <NAME>`. Will be removed in future versions, as bin targets do not have library-like API to check. | `--lib` |
|
||||
| version-tag-prefix | The prefix to use for the git tag for a version; the default "v" creates tags like "v1.0.0". | `v` |
|
||||
| crate-name | The crate whose API to check for semver. If not set, all crates in the workspace are processed. | |
|
||||
|
||||
# Scenarios
|
||||
|
||||
- [Use with a different version tag format](#use-with-a-different-version-tag-format)
|
||||
- [Use in workspaces with more than one crate](#use-in-workspaces-with-more-than-one-crate)
|
||||
- [(Deprecated) Use with binary crates or crates with more than one target](#deprecated-use-with-binary-crates-or-crates-with-more-than-one-target)
|
||||
|
||||
## Use with a different version tag format
|
||||
|
||||
Change the `version-tag-prefix` setting to reflect the prefix used to create the version tag. The setting's default value `'v'` creates version tags like `v1.2.3`.
|
||||
|
||||
For example, if your versions are tagged as `1.2.3`, you can set `version-tag-prefix` to be the empty string:
|
||||
```yaml
|
||||
- name: Check semver
|
||||
uses: obi1kenobi/cargo-semver-checks-action@v1
|
||||
with:
|
||||
version-tag-prefix: ''
|
||||
- name: Publish my-crate to crates.io
|
||||
run: # your `cargo publish` code here
|
||||
```
|
||||
|
||||
## Use in workspaces with more than one crate
|
||||
|
||||
You'll need to specify which crate should be checked, and the format used for version tags for that crate:
|
||||
By default, if workspace contains multiple crates, all of them are checked against semver violations. You can specify single crate to be checked instead, along with the format used for version tags for that crate:
|
||||
- `crate-name` specifies the crate to check, and
|
||||
- `version-tag-prefix` sets the text prepended to the version number to create the git tag for that release.
|
||||
|
||||
|
@ -59,15 +36,3 @@ For example, this will check `my-crate` whose releases are tagged as `my-crate-v
|
|||
- name: Publish my-crate to crates.io
|
||||
run: # your `cargo publish` code here
|
||||
```
|
||||
|
||||
## (Deprecated) Use with binary crates or crates with more than one target
|
||||
|
||||
To check a different (non-library) target in a crate, use the `crate-target` setting:
|
||||
```yaml
|
||||
- name: Check semver for my_binary
|
||||
uses: obi1kenobi/cargo-semver-checks-action@v1
|
||||
with:
|
||||
crate-target: --bin my_binary
|
||||
- name: Publish my-crate to crates.io
|
||||
run: # your `cargo publish` code here
|
||||
```
|
||||
|
|
24
action.yml
24
action.yml
|
@ -5,17 +5,9 @@ branding:
|
|||
color: 'green'
|
||||
inputs:
|
||||
crate-name:
|
||||
description: 'The crate whose API to check for semver'
|
||||
description: 'The crate whose API to check for semver. If not set, all crates in the workspace are processed.'
|
||||
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:
|
||||
|
@ -24,7 +16,7 @@ runs:
|
|||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
- name: Build rustdoc and check it
|
||||
- name: Check for semver violations
|
||||
shell: bash
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
|
@ -32,14 +24,14 @@ runs:
|
|||
# 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")"
|
||||
# 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
|
||||
# cargo rustdoc uses the exact package name, not the "underscores" version.
|
||||
export RUSTDOC_EARLY_FLAGS="--package $PACKAGE_NAME $RUSTDOC_EARLY_FLAGS"
|
||||
export PACKAGE_OPTION="--package ${{ inputs.crate-name }}"
|
||||
fi
|
||||
|
||||
# Check for semver violations.
|
||||
cargo install cargo-semver-checks --locked
|
||||
cargo semver-checks check-release --package "$PACKAGE_NAME"
|
||||
cargo semver-checks check-release $PACKAGE_OPTION
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Script requirements:
|
||||
# - jq
|
||||
|
||||
# Fail on first error, on undefined variables, and on failures in pipelines.
|
||||
set -euo pipefail
|
||||
|
||||
# Go to the repo root directory.
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
crates="$(cargo metadata --format-version 1 | \
|
||||
jq --exit-status -r \
|
||||
'.workspace_members[] as $key | .packages[] | select(.id == $key) | .name')"
|
||||
crate_count="$(echo -e "${crates}" | wc -l)"
|
||||
|
||||
if [[ "$crate_count" == "1" ]]; then
|
||||
echo -e "${crates}"
|
||||
exit 0
|
||||
else
|
||||
echo >&2 "Multiple crates in workspace, please specify a crate in the 'crate-name' setting."
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in a new issue