Reusable GitHub Actions for Rust projects

Clone this repo:
  1. c3aecea feat: set disable-semantic-release-git default true by liulifox233 · 1 year, 1 month ago master
  2. 375b5d6 feat: add VERSION variable for cargo build by liulifox233 · 1 year, 1 month ago
  3. 461b001 feat: add extension (.exe) for windows target by liulifox233 · 1 year, 1 month ago
  4. fd44795 feat: disable tests on windows & fix binary_name on windows by liulifox233 · 1 year, 1 month ago
  5. 898027e feat: add windows target support by liulifox233 · 1 year, 1 month ago

semantic-release-action/rust

Build Status

This repository contains extremely opinionated reusable GitHub Actions workflows providing CI and CD for Rust projects.

This GitHub Action is intended to reduce duplication among very rigidly organized projects. These are not general-purpose workflows. You may find that they work for you and your development workflows out of the box, or they may not.

Continuous deployments brought to you by semantic-release.

CI

Continuous integration is provided by .github/workflows/ci.yml.

CI runs Rust tests on an ubuntu-latest runner.

Use

---
name: CI

on:
  pull_request:

jobs:
  test:
    uses: semantic-release-action/rust/.github/workflows/ci.yml@v5

Inputs

Input ParameterDefaultDescription
toolchainstableRust toolchain specification. Details
submodulesfalseWhether to checkout submodules. Details

toolchain

Specify a Rust toolchain.

submodules

Whether to checkout submodules. Use true to checkout submodules or recursive to recursively checkout submodules. This option is passed verbatim to actions/checkout, see its documentation for more details.

Release binary

Continuous deployments for Rust binaries are provided by .github/workflows/release-binary.yml.

Each deploy:

  • publishes your crate to crates.io

    This provides compatibility with cargo binstall.

  • creates or updates git tags

    Tags are of the format v1.2.3, v1.2, and v1.

  • uploads precompiled release binaries to the associated GitHub Release

  • updates a CHANGELOG.md in your git repository

    This produces a commit (currently not gpg signed).

Use

---
name: Release

on:
  push:
    branches:
      - master
      - next
      - next-major
      - beta
      - alpha
      - "[0-9]+.[0-9]+.x"
      - "[0-9]+.x"

jobs:
  release:
    uses: semantic-release-action/rust/.github/workflows/release-binary.yml@v5
    secrets:
      cargo-registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Inputs

Input ParameterDefaultDescription
targetsall supportedWhitelist of compilation targets to upload GitHub release binaries for. Details
toolchainstableRust toolchain specification. Details
disable-semantic-release-cargofalseDisable semantic-release-cargo in your release flow. Details
disable-semantic-release-gitfalseDisable @semantic-release/git in your release flow. Details
submodulesfalseWhether to checkout submodules. Details

targets

Whitelist of compilation targets to upload GitHub release binaries for. Must be a subset of supported targets:

  • aarch64-apple-darwin
  • aarch64-unknown-linux-gnu
  • aarch64-unknown-linux-musl
  • i686-unknown-linux-gnu
  • i686-unknown-linux-musl
  • x86_64-apple-darwin
  • x86_64-unknown-linux-gnu
  • x86_64-unknown-linux-musl

Separate each target with whitespace:

jobs:
  release:
    uses: semantic-release-action/rust/.github/workflows/release-binary.yml@v5
    with:
      targets: |
        aarch64-apple-darwin
        x86_64-apple-darwin
        x86_64-unknown-linux-musl
    secrets:
      cargo-registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

disable-semantic-release-cargo

Runtime option controlling the use of semantic-release-cargo. Set to true to prevent semantic-release from publishing your crate to the configured cargo registry.

disable-semantic-release-git

Runtime option controlling the use of @semantic-release/git. Set to true to prevent semantic-release from pushing artifacts to your repository. This may be required with certain repository settings, for example when requiring signed commits.

Secrets

SecretRequiredDescription
cargo-registry-tokenfalseCargo registry API token. Details

cargo-registry-token

API token with write permission for publishing your crate to your target registry.

Release library

Continuous deployments for Rust libraries are provided by .github/workflows/release-library.yml.

Each deploy:

  • publishes your crate to crates.io

    This provides compatibility with cargo binstall.

  • updates a CHANGELOG.md in your git repository

    This produces a commit (currently not gpg signed).

Use

---
name: Release

on:
  push:
    branches:
      - master
      - next
      - next-major
      - beta
      - alpha
      - "[0-9]+.[0-9]+.x"
      - "[0-9]+.x"

jobs:
  release:
    uses: semantic-release-action/rust/.github/workflows/release-library.yml@v5
    secrets:
      cargo-registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Inputs

Input ParameterDefaultDescription
toolchainstableRust toolchain specification. Details
disable-semantic-release-cargofalseDisable semantic-release-cargo in your release flow. Details
disable-semantic-release-gitfalseDisable @semantic-release/git in your release flow. Details
submodulesfalseWhether to checkout submodules. Details

Secrets

SecretRequiredDescription
cargo-registry-tokenfalseCargo registry API token. Details