name: Uringy CI/CD
on:
push:
branches: [ master ]
paths-ignore:
- macros/**
jobs:
unit_test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: unit-test
- name: Unit test
run: cargo test
build_timings:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: unit-timings
- name: Download Cargo dependencies
run: cargo fetch
- name: Time cold build
run: cargo build --release --timings
- name: Upload timings report
uses: actions/upload-artifact@v3
with:
name: build_timings_report
path: target/cargo-timings/cargo-timing.html
verify_msrv:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: verify-msrv
- name: Verify whether MSRV is satisfiable
run: |
cargo install cargo-msrv
cargo msrv verify
deploy_to_crates_io:
needs:
- unit_test
- verify_msrv
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
key: deploy-to-crates-io
- name: Determine whether current version is already deployed
run: |
cargo install cargo-get
CRATE_VERSION=$(cargo get package.version | tr -d '\n')
VERSION_EXISTS=$(curl -s https://crates.io/api/v1/crates/uringy | jq '.versions | map(.num) | contains(["'$CRATE_VERSION'"])')
echo "VERSION_EXISTS=$VERSION_EXISTS" >> $GITHUB_OUTPUT
echo $(curl -s https://crates.io/api/v1/crates/uringy | jq '.versions | map(.num)')
echo $CRATE_VERSION $VERSION_EXISTS
id: whether-deployed
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_ACCESS_TOKEN }}
if: ${{ steps.whether-deployed.outputs.VERSION_EXISTS == 'false' }}
- name: Publish to crates.io
run: cargo publish
if: ${{ steps.whether-deployed.outputs.VERSION_EXISTS == 'false' }}