Minor fixes and CI cleanup #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
tags: | |
- v* | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
name: CI | |
jobs: | |
build_and_test: | |
name: Rust project | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
bin: smag | |
name: smag-Linux-x86_64.tar.gz | |
- os: macOS-latest | |
bin: smag | |
name: smag-Darwin-x86_64.tar.gz | |
- os: windows-latest | |
bin: smag.exe | |
name: smag-Windows-x86_64.zip | |
env: | |
RUST_BACKTRACE: "1" | |
steps: | |
- uses: actions/checkout@main | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
# Caching: | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo index | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
- name: Run | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: run | |
args: -- --help | |
- name: Build release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: build | |
args: --release | |
- name: Package | |
if: startsWith(github.ref, 'refs/tags/') | |
shell: bash | |
run: | | |
strip target/release/${{ matrix.bin }} | |
cd target/release | |
if [[ "${{ matrix.os }}" == "windows-latest" ]] | |
then | |
7z a ../../${{ matrix.name }} ${{ matrix.bin }} | |
else | |
tar czvf ../../${{ matrix.name }} ${{ matrix.bin }} | |
fi | |
cd - | |
- name: Publish | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: false | |
files: 'smag*' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v1 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Run cargo check | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: check | |
clippy: | |
name: Clippy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v1 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
components: clippy | |
- uses: clechasseur/rs-clippy-check@v3 | |
with: | |
args: --all-features | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v1 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: Run cargo fmt | |
uses: clechasseur/rs-cargo@v2 | |
with: | |
command: fmt | |
args: --all -- --check |