Add GH actions workflow for building and linting #2
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
name: Build and lint | |
on: | |
pull_request: | |
branches: | |
- main | |
workflow_call: | |
inputs: | |
version: | |
type: string | |
description: Project version used for naming artifacts | |
required: true | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os-target: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
runs-on: ${{ matrix.os-target.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: 1.70.0 | |
targets: ${{ matrix.os-target.target }} | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install aarch64-unknown-linux-gnu requisites | |
run: sudo apt-get install g++-aarch64-linux-gnu -y | |
if: matrix.os-target.target == 'aarch64-unknown-linux-gnu' | |
- name: Run cargo build | |
run: cargo build --release --target ${{ matrix.os-target.target }} | |
- name: Upload artifacts for reuse in release job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tag-track_${{ inputs.version }}_${{ matrix.os-target.target }} | |
path: ${{ github.workspace }}/target/${{ matrix.os-target.target }}/release/tag-track${{ matrix.os-target.target == 'x86_64-pc-windows-msvc' && '.exe' || '' }} | |
if-no-files-found: error | |
retention-days: 5 | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: 1.70.0 | |
components: clippy,rustfmt | |
- uses: Swatinem/rust-cache@v2 | |
- name: Run clippy | |
run: cargo clippy -- -D warnings | |
- name: Run rustfmt | |
run: cargo fmt --all -- --check |