Skip to content

Bump the cargo-all group with 4 updates #248

Bump the cargo-all group with 4 updates

Bump the cargo-all group with 4 updates #248

Workflow file for this run

name: CI/CD
on:
# By default, a workflow only runs when a pull_request event's activity type is opened, synchronize, or reopened.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# So we add default event types and ready_for_review type here.
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
push:
branches:
- main
tags:
- v*
env:
RUST_BACKTRACE: full
CARGO_TERM_COLOR: always
jobs:
ci:
if: github.event.pull_request.draft == false
name: Run CI tasks
runs-on: ubuntu-20.04
steps:
- uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # No semver tag.
with:
toolchain: stable
components: rustfmt,clippy
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
# This need to be done after checkout.
- uses: ./.github/actions/setup_gitleaks
- name: Check "cargo fmt"
run: cargo fmt -- --check
- name: Run "cargo check"
run: cargo check --locked --all-features --all-targets
- name: Run "cargo clippy"
run: cargo clippy --locked --all-features -- -D warnings
- name: Run "cargo test"
run: cargo test --locked --verbose --all-targets --all-features
crate-metadata:
if: startsWith(github.ref, 'refs/tags/v')
name: Extract crate metadata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Extract crate information
id: crate-metadata
shell: bash
run: |
human_version="$(cargo metadata --no-deps --format-version 1 | jq -r '"v" + .packages[0].version')"
if [ "${{ github.ref_name }}" != "${human_version}" ]; then
echo "Tag does not match version in Cargo.toml: ${{ github.ref_name }} != ${human_version}"
exit 1
fi
cargo metadata --no-deps --format-version 1 | jq -r '"name=" + .packages[0].name' | tee -a $GITHUB_OUTPUT
cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT
cargo metadata --no-deps --format-version 1 | jq -r '"msrv=" + .packages[0].rust_version' | tee -a $GITHUB_OUTPUT
outputs:
name: ${{ steps.crate-metadata.outputs.name }}
version: ${{ steps.crate-metadata.outputs.version }}
msrv: ${{ steps.crate-metadata.outputs.msrv }}
build-release:
if: startsWith(github.ref, 'refs/tags/v')
needs:
- ci
- crate-metadata
permissions:
contents: write
name: Build release
env:
BUILD_CMD: cargo
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
# To sort the matrix, use inline syntax.
- { target: aarch64-apple-darwin, os: macos-latest }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, cross: true }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest, cross: true }
- { target: x86_64-apple-darwin, os: macos-latest }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest }
steps:
- uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
with:
toolchain: stable
targets: ${{ matrix.job.target }}
- uses: taiki-e/install-action@3451569d988f3b0b3eaccd1d1b539a75ec96f192 # v2.42.14
if: matrix.job.cross == true
with:
tool: cross
- name: Overwrite build command
if: matrix.job.cross == true
shell: bash
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Build release binary
run: $BUILD_CMD build --release --locked --verbose --all-features --target=${{ matrix.job.target }}
env:
PKG_CONFIG_ALLOW_CROSS: 1
- name: Archive release binary
run: |
tar --create --gzip --verbose --file=${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz --directory=target/${{ matrix.job.target }}/release ${{ needs.crate-metadata.outputs.name }}
- name: Install coreutils for macOS runner
if: matrix.job.os == 'macos-latest'
run: brew install coreutils
- name: Calculate checksum
run: |
sha256sum ${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz > ${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz.sha256
- name: Upload release binary
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
files: |
${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz
${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz.sha256