Integrate a Rust project with semantic-release

Overview

semantic-release-cargo

Build Status

semantic-release-cargo integrates a cargo-based Rust project with semantic-release. This solves two use cases:

  1. publishing to crates.io, and
  2. compiling release binaries

Publish to crates.io

After following these instructions, you will have a semantic-release pipeline that publishes your Rust crate to crates.io.

Requirements

You must set the CARGO_REGISTRY_TOKEN environment variable.

This workflow is supported on the following systems:

System Supported?
macOS aarch64
macOS x64
Linux x64 gnu

Install

Install semantic-release-cargo with npm:

$ npm install --save-dev --save-exact @semantic-release-cargo/semantic-release-cargo

Use

Add semantic-release-cargo to your semantic-release configuration in .releaserc.json:

{
  "plugins": ["@semantic-release-cargo/semantic-release-cargo"]
}

Alternative Configuration with semantic-release-action

If you're not keen to mix npm with your Rust project, you can use the semantic-release-action.

Compile Release Binaries

After following these instructions, you will have a GitHub Actions workflow that sets the next version number in Cargo.toml and compiles your crate's release binaries.

Updating the cargo manifest with the next version number lets you reference the next version in the compiled binary, for example with the clap::crate_version macro.

The compiled binaries can be uploaded to a GitHub release using the @semantic-release/github plugin.

This workflow is supported on the following systems:

System Supported?
macOS aarch64
macOS x64
Linux aarch64
Linux x64
Linux x86

Use

In the first job, use the next-release-version Action to save the next release version as GitHub Actions outputs:

jobs:
  get-next-version:
    uses: semantic-release-action/next-release-version/.github/workflows/next-release-version.yml@v2

In the next job, use semantic-release-cargo to set the crate version before compilation:

build:
  name: Build
  runs-on: ubuntu-latest
  needs:
    - get-next-version

  steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Install semantic-release-cargo
      if: needs.get-next-version.outputs.new-release-published == 'true'
      uses: EricCrosson/install-github-release-binary@v2
      with:
        targets: semantic-release-cargo@2

    - name: Prepare semantic-release for Rust
      if: needs.get-next-version.outputs.new-release-published == 'true'
      run: semantic-release-cargo prepare ${{ needs.get-next-version.outputs.new-release-version }}

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@master

    - name: Cargo build
      run: cargo build --release --target=x86_64-unknown-linux-gnu --all-targets

Example Workflow

You can create a single GitHub Actions workflow that combines both use cases. This repository uses semantic-release-cargo with semantic-release to publish to crates.io and create a GitHub Release with precompiled binaries.

See release.yml for a working example.

Contributors License Agreement

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in semantic-release-cargo by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Acknowledgments

This repository has been forked from kettleby/semantic-release-rust. All credit goes to the original author.

Comments
  • Allow setting features for specific packages during publish

    Allow setting features for specific packages during publish

    Hi! I am looking to add this to async-stripe, but we require the user to pick a runtime when using the package and, by extension, require that a runtime is set during publishing or else the build will fail.

    I am in the process of writing this feature, but want to open an issue to track as well.

    Thanks! Alex

    released 
    opened by arlyon 3
  • fix(deps): update rust crate toml_edit to v0.15.0

    fix(deps): update rust crate toml_edit to v0.15.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | toml_edit | dependencies | minor | =0.2.0 -> =0.15.0 |


    Release Notes

    ordian/toml_edit

    v0.15.0

    Compare Source

    v0.14.4

    Compare Source

    v0.14.3

    Compare Source

    v0.14.2

    Compare Source

    v0.14.1

    Compare Source

    v0.14.0

    Compare Source

    v0.13.4

    Compare Source

    v0.13.3

    Compare Source

    v0.13.2

    Compare Source

    v0.13.1

    Compare Source

    v0.13.0

    Compare Source

    v0.12.6

    Compare Source

    v0.12.5

    Compare Source

    v0.12.4

    Compare Source

    v0.12.3

    Compare Source

    v0.12.2

    Compare Source

    v0.12.1

    Compare Source

    v0.12.0

    Compare Source

    v0.11.0

    Compare Source

    v0.10.1

    Compare Source

    v0.10.0

    Compare Source

    v0.9.1

    Compare Source

    v0.9.0

    Compare Source

    v0.8.0

    Compare Source

    v0.7.0

    Compare Source

    v0.6.0

    Compare Source

    v0.5.0

    Compare Source

    v0.4.0

    Compare Source

    v0.3.1

    Compare Source

    v0.3.0

    Compare Source

    v0.2.1

    Compare Source


    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    dependencies 
    opened by renovate[bot] 3
  • Publish features

    Publish features

    This PR allows you to specify a map with features that should be applied when building packages for publishing. It takes the format:

    [
      "@semantic-release-cargo/semantic-release-cargo",
      {
        "features": {
          "my_package": ["feat-1", "feat-2"],
          "my_other_package": ["feat-3"]
        }
      }
    ]
    

    This can also be used over the command line:

    cargo run -- publish --features my_package=feat-1,my_package=feat-2,my_other_package=feat-3
    

    Closes #48

    released 
    opened by arlyon 2
  • fix(deps): update rust crate napi-derive to v2.9.5

    fix(deps): update rust crate napi-derive to v2.9.5

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | napi-derive | dependencies | patch | =2.9.4 -> =2.9.5 |


    Release Notes

    napi-rs/napi-rs

    v2.9.5

    Compare Source

    What's Changed

    Full Changelog: https://github.com/napi-rs/napi-rs/compare/@​napi-rs/cli@​2[email protected]


    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • fix(deps): update rust crate clap to v4.1.1

    fix(deps): update rust crate clap to v4.1.1

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | clap | dependencies | minor | =4.0.32 -> =4.1.1 |


    Release Notes

    clap-rs/clap

    v4.1.1

    Compare Source

    Fixes
    • (error) Small softening attempt for "unexpected argument" error

    v4.1.0

    Compare Source

    Compatibility

    MSRV changed to 1.64.0

    For apps with custom --help and --version flags:

    • Descriptions for --help and --version changed

    When apps have errors imitating clap's error style:

    • Error message style was changed, including
      • Moving away from "did you mean" to tips
      • Leading letter is lower case
      • "For more" added some punctuation
    Features
    • ArgMatches::get_occurrences support for argument values to be grouped by their occurrence
    Fixes
    • (derive) Allow upgrade_from when arguments / subcommands are explicitly marked as required
    • (help) Try be more clearer and succinct with --help and --version (also helps with overflow)
    • (error) Try to be more clearer and succinct with error messages
    • (error) Officially adopt an error style guide

    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • fix(deps): update rust crate napi-derive to v2.9.4

    fix(deps): update rust crate napi-derive to v2.9.4

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | napi-derive | dependencies | patch | =2.9.3 -> =2.9.4 |


    Release Notes

    napi-rs/napi-rs

    v2.9.4

    Compare Source

    What's Changed

    Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.9.4


    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • chore(deps): update dependency @napi-rs/cli to v2.14.3

    chore(deps): update dependency @napi-rs/cli to v2.14.3

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @napi-rs/cli | 2.14.2 -> 2.14.3 | age | adoption | passing | confidence |


    Release Notes

    napi-rs/napi-rs

    v2.14.3

    Compare Source

    What's Changed

    New Contributors

    Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]...@​napi-rs/cli@​2.14.3


    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • fix(deps): update rust crate napi to v2.10.6

    fix(deps): update rust crate napi to v2.10.6

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | napi | dependencies | patch | =2.10.5 -> =2.10.6 |


    Release Notes

    napi-rs/napi-rs

    v2.10.6

    Compare Source

    What's Changed

    New Contributors

    Full Changelog: https://github.com/napi-rs/napi-rs/compare/@​napi-rs/cli@​2[email protected]


    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • chore(deps): update dependency @napi-rs/cli to v2.14.2

    chore(deps): update dependency @napi-rs/cli to v2.14.2

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @napi-rs/cli | 2.14.1 -> 2.14.2 | age | adoption | passing | confidence |


    Release Notes

    napi-rs/napi-rs

    v2.14.2

    Compare Source

    What's Changed

    Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]...@​napi-rs/cli@​2.14.2


    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • fix(deps): update rust crate napi to v2.10.5

    fix(deps): update rust crate napi to v2.10.5

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | napi | dependencies | patch | =2.10.4 -> =2.10.5 |


    Release Notes

    napi-rs/napi-rs

    v2.10.5

    Compare Source

    What's Changed

    New Contributors

    Full Changelog: https://github.com/napi-rs/napi-rs/compare/[email protected]@2.10.5


    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • chore(deps): update dependency semantic-release to v20.0.2

    chore(deps): update dependency semantic-release to v20.0.2

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | semantic-release | 20.0.1 -> 20.0.2 | age | adoption | passing | confidence |


    Release Notes

    semantic-release/semantic-release

    v20.0.2

    Compare Source

    Bug Fixes

    Configuration

    📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone America/Chicago, Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released dependencies 
    opened by renovate[bot] 1
  • [docs] Cargo.lock not found

    [docs] Cargo.lock not found

    Hi there, just thought I'd leave this here in case others come across the same error.

    This error can occur when a workspace member has a Cargo.lock file but the rest don't. To fix, remove this file from the MEMBER, not for the project. Workspace members use the project lockfile.

    opened by waynevanson 1
  • Installing global node package does not contain binary

    Installing global node package does not contain binary

    I noticed inside the CI job, you use ./semantic-release-cargo as a binary directly, and I'd like to do the same.

    How is this package supposed to be installed, using cargo install semantic-release-cargo? I tried installing via NPM but noticed there's no binary.

    Run yarn global add @semantic-release-cargo/semantic-release-cargo
      
    yarn global v1.22.19
    [1/4] Resolving packages...
    [2/4] Fetching packages...
    [3/4] Linking dependencies...
    [4/4] Building fresh packages...
    warning "@semantic-release-cargo/[email protected]" has no binaries
    Done in 1.15s.
    

    Is the correct way to install this package using

    opened by waynevanson 1
  • Migration Guide or Examples

    Migration Guide or Examples

    Hi there,

    Thank you so much for the work you've done here.

    It's a little vague on what has changed. On the surface it looks like a lot but it really doesn't seem like too much.

    Would you be able to add some examples or a migration guide for common use cases? The one I'm stuck on at the moment is running inside of https://github.com/cycjimmy/semantic-release-action

    opened by waynevanson 1
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Awaiting Schedule

    These updates are awaiting their schedule. Click on a checkbox to get an update now.

    • [ ] fix(deps): update rust crate napi to v2.10.7
    • [ ] chore(deps): update semantic-release-action/next-release-version action to v2

    Detected dependencies

    cargo
    Cargo.toml
    • anyhow =1.0.68
    • guppy =0.15.2
    • human-panic =1.0.3
    • itertools =0.10.5
    • log =0.4.17
    • loggerv =0.7.2
    • napi =2.10.6
    • napi-derive =2.9.5
    • serde_json =1.0.91
    • serde =1.0.152
    • clap =4.1.1
    • thiserror =1.0.38
    • toml_edit =0.17.1
    • url =2.3.1
    • assert_matches =1.5.0
    • tempfile =3.3.0
    • fs_extra =1.2.0
    • semver =1.0.16
    • napi-build =2.0.1
    test_data/cycle/Cargo.toml
    test_data/cycle/dep1/Cargo.toml
    test_data/dependencies/Cargo.toml
    test_data/git_dep/Cargo.toml
    test_data/git_dep_version/Cargo.toml
    test_data/target_dep/Cargo.toml
    github-actions
    .github/workflows/ci.yml
    • actions/checkout v3
    • taiki-e/install-action v2
    • actions/cache v3
    • actions/checkout v3
    • actions/setup-node v3
    • actions/cache v3
    • actions/cache v3
    .github/workflows/release.yml
    • semantic-release-action/next-release-version v1
    • actions/checkout v3
    • actions/cache v3
    • actions/checkout v3
    • actions/cache v3
    • taiki-e/install-action v2
    • taiki-e/install-action v2
    • actions/upload-artifact v3
    • actions/checkout v3
    • actions/cache v3
    • actions/setup-node v3
    • actions/cache v3
    • actions/upload-artifact v3
    • actions/checkout v3
    • actions/cache v3
    • actions/setup-node v3
    • actions/cache v3
    • actions/download-artifact v3
    npm
    package.json
    • @napi-rs/cli 2.14.3
    • @semantic-release/changelog 6.0.2
    • @semantic-release/exec 6.0.3
    • @semantic-release/git 10.0.1
    • semantic-release 20.0.2
    • semantic-release-export-data 1.0.1
    • semantic-release-major-tag 0.2.1

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
Releases(v2.1.0)
Owner
null
Integrate Mcfly with fzf to combine a solid command history database with a widely-loved fuzzy search UI

McFly fzf integration Integrate McFly with fzf to combine a solid command history database with a widely-loved fuzzy search UI Features: Advanced hist

null 11 Jan 25, 2023
Transform jsx/tsx files to reactive views in js/ts to use in Web Components, insert into DOM or integrate with other libraries/frameworks

viewmill Features | Installation | Getting Started | Notes | Examples viewmill is aimed to create complex UIs from a simple form of JSX. It statically

apleshkov 6 Sep 4, 2023
A tree-sitter based AST difftool to get meaningful semantic diffs

diffsitter Disclaimer diffsitter is very much a work in progress and nowhere close to production ready (yet). Contributions are always welcome! Summar

Afnan Enayet 1.3k Jan 8, 2023
Semantic find-and-replace using tree-sitter-based macro expansion

Semantic find-and-replace using tree-sitter-based macro expansion

Isaac Clayton 15 Nov 10, 2022
Split text into semantic chunks, up to a desired chunk size. Supports calculating length by characters and tokens

Large language models (LLMs) can be used for many tasks, but often have a limited context size that can be smaller than documents you might want to use. To use documents of larger length, you often have to split your text into chunks to fit within this context size.

Ben Brandt 4 May 8, 2023
Blockoli is a high-performance tool for code indexing, embedding generation and semantic search tool for use with LLMs.

blockoli ???? Blockoli is a high-performance tool for code indexing, embedding generation and semantic search tool for use with LLMs. blockoli is buil

Asterisk 76 Jul 24, 2024
Cargo subcommand `release`: everything about releasing a rust crate.

cargo release Features Ensure you are in a good state for release, including: Right branch Up-to-date with remote Clean tree Supports workspaces using

null 933 Jan 8, 2023
Rust-powered CLI tool designed to simplify and streamline the release process with help of ChatGPT

$ releasecraftsman ????‍♂️?? Automate Your Release Process with Precision and Ease. ?? Features Generate well-crafted release notes using GPT-3.5 and

Tornike Gomareli 7 Sep 21, 2023
🚀 JavaScript driver for ScyllaDB, harnessing Rust's power through napi-rs for top performance. Pre-release stage. 🧪🔧

?? JavaScript driver for ScyllaDB. Pre-release stage. ???? ⚠️ Disclaimer ⚠️ This repository and the associated npm package are currently in a ?? pre-r

Daniel Boll 16 Oct 21, 2023
(Pre-Release Software) Secure, Encrypted, P2P chat written atop Warp, IPFS, LibP2P, Dioxus and many more awesome projects and protocols.

Uplink Privacy First, Modular, P2P messaging client built atop Warp. Uplink is written in pure Rust with a UI in Dioxus (which is also written in Rust

Satellite 13 Jan 25, 2023
A gui tool written in Dioxus to make it easy to release a workspace of crates to crates.io

Easy-Release: a visual tool for releasing workspaces of libraries A work-in-progress GUI for releasing a large workspace of crates manually, but easil

Jon Kelley 13 Jan 18, 2023
Macro to print variable(s) with values nicely (stripped from release builds)

log_macro Macro to print variable(s) with values nicely (stripped from release builds) Install cargo add log_macro Use Add this to top of file: #[mac

Nikita 3 Aug 22, 2023
SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project.

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project. With just a few primary configurations, such as project name, you can get started quickly.

Gabriel Michaliszen 4 May 9, 2023
rpm (Rust project manager) is a tool that helps you to manage your rust projects

rpm rpm (Rust project manager) is a open source tool for managing your rust project in an organized way Installation # make sure you have rust install

Dilshad 4 May 4, 2023
auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, utilizing procedural macros.

Auto Rust auto-rust is an experimental project that aims to automatically generate Rust code with LLM (Large Language Models) during compilation, util

Minsky 6 May 14, 2023
A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies

cargo-temp A CLI tool that allow you to create a new rust project in a temporary directory with already installed dependencies. Install Requires Rust

Yohan Boogaert 61 Oct 31, 2022
The dead easy way to use config files in your rust project

Configr The dead easy way to use config files in your project This will load a config.toml file if it exists, otherwise it will create the needed fold

Carsten Kragelund Jørgensen 4 Jul 1, 2022
Baby's first Rust CLI project. Basic implementation of grep. Written in about 100 SLOC.

minigrep Coding project from Chapter 12 of the The Rust Programming Language book. Usage Compile and run as so minigrep QUERY FILENAME QUERY being the

Anis 2 Oct 2, 2021
This repository presents a numbers vizualizer in a polar base. This small project has been entirely made in Rust !

NumbersRepresentation This repository presents a numbers vizualizer in a polar base. This small project has been entirely made in Rust ! This is an id

Lilian 'S3l4h' Schall 3 Apr 12, 2022