Skip to content

Minor fixes and CI cleanup #25

Minor fixes and CI cleanup

Minor fixes and CI cleanup #25

Workflow file for this run

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: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# Caching:
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Run
uses: actions-rs/cargo@v1
with:
command: run
args: -- --help
- name: Build release
if: startsWith(github.ref, 'refs/tags/')
uses: actions-rs/cargo@v1
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: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v1
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v1
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check