2022-07-21 00:45:54 +02:00
# cargo-semver-checks-action
2022-08-12 18:26:01 +02:00
Lint your crate API changes for semver violations.
2022-08-02 20:41:03 +02:00
By default, this action assumes that:
2022-08-07 18:23:51 +02:00
- Your cargo workspace contains a single crate which contains a library target.
2022-08-02 20:41:03 +02:00
- Your releases are tagged in git as `v{major}.{minor}.{patch}` , for example `v1.2.3` .
Single-crate workspaces can use it as:
2022-08-12 18:26:01 +02:00
```yaml
2022-08-02 20:41:03 +02:00
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v1
- name: Publish to crates.io
run: # your `cargo publish` code here
```
2022-12-31 14:44:23 +01:00
# Input options
Every argument is optional.
| Input | Description | Default |
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------|---------|
2023-01-01 17:03:18 +01:00
| 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` |
2022-12-31 14:44:23 +01:00
# 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 )
2023-01-01 17:03:18 +01:00
- [(Deprecated) Use with binary crates or crates with more than one target ](#deprecated-use-with-binary-crates-or-crates-with-more-than-one-target )
2022-12-31 14:44:23 +01:00
2022-08-12 18:26:01 +02:00
## 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` .
2022-08-02 20:41:03 +02:00
2022-08-12 18:26:01 +02:00
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
2022-08-02 20:41:03 +02:00
```
2022-08-12 18:26:01 +02:00
## 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:
- `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.
For example, this will check `my-crate` whose releases are tagged as `my-crate-v1.2.3` :
```yaml
2022-08-02 20:41:03 +02:00
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v1
with:
crate-name: my-crate
version-tag-prefix: my-crate-v
- name: Publish my-crate to crates.io
run: # your `cargo publish` code here
```
2022-08-07 18:23:51 +02:00
2023-01-01 17:03:18 +01:00
## (Deprecated) Use with binary crates or crates with more than one target
2022-08-12 18:26:01 +02:00
2022-08-07 18:23:51 +02:00
To check a different (non-library) target in a crate, use the `crate-target` setting:
2022-08-12 18:26:01 +02:00
```yaml
2022-08-07 18:23:51 +02:00
- 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
```