cargo fmt #197
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
# This file is part of jinx. Copyright © 2024 jinx contributors. | |
# jinx is licensed under the GNU AGPL v3.0 or any later version. See LICENSE file for full text. | |
name: Build | |
on: | |
push: | |
paths-ignore: # ignore files that can't alter build output | |
- '**.md' | |
- .github/dependabot.yml | |
- .github/workflows/ci.yml | |
- .github/workflows/publish.yml | |
- .gitignore | |
- docs/** | |
- LICENSE | |
jobs: | |
cargo-deny: | |
# only run for pushes to tags or non-dependabot branches | |
if: startsWith(github.ref, 'refs/tags/') || (startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/dependabot/')) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: EmbarkStudios/cargo-deny-action@v1 | |
cargo-fmt: | |
# only run for pushes to tags or non-dependabot branches | |
if: startsWith(github.ref, 'refs/tags/') || (startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/dependabot/')) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Cargo | |
run: rustup component add cargo | |
- name: Install Clippy | |
run: rustup component add rustfmt | |
- uses: actions/checkout@v4 | |
- name: Format | |
run: cargo fmt --check | |
build: | |
# only run for pushes to tags or non-dependabot branches | |
if: startsWith(github.ref, 'refs/tags/') || (startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/dependabot/')) | |
strategy: | |
matrix: | |
target: | |
- runs-on: windows-latest | |
triple: x86_64-pc-windows-msvc | |
build-name: Windows | |
artifact-suffix: '' | |
suffix: .exe | |
path-separator: '\' | |
runner-can-execute: true | |
- runs-on: ubuntu-latest | |
triple: x86_64-unknown-linux-gnu | |
build-name: Linux | |
artifact-suffix: -linux | |
suffix: '' | |
path-separator: '/' | |
runner-can-execute: true | |
- runs-on: macos-latest | |
triple: x86_64-apple-darwin | |
build-name: macOS x86 | |
artifact-suffix: -mac-x86 | |
suffix: '' | |
path-separator: '/' | |
runner-can-execute: false | |
- runs-on: macos-latest | |
triple: aarch64-apple-darwin | |
build-name: macOS ARM | |
artifact-suffix: -mac-arm | |
suffix: '' | |
path-separator: '/' | |
runner-can-execute: true | |
fail-fast: false | |
name: Build ${{ matrix.target.build-name }} | |
runs-on: ${{ matrix.target.runs-on }} | |
steps: | |
- name: Install Rust target | |
run: rustup target add ${{ matrix.target.triple }} | |
- name: Install Cargo | |
run: rustup component add cargo | |
- name: Install Clippy | |
run: rustup component add clippy | |
- name: git checkout | |
uses: actions/checkout@v4 | |
- name: Setup workflow cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check | |
run: cargo clippy --target ${{ matrix.target.triple }} | |
- name: Test | |
if: matrix.target.runner-can-execute | |
run: cargo test --target ${{ matrix.target.triple }} | |
- name: Build | |
run: cargo build --release --target ${{ matrix.target.triple }} | |
- name: Upload workflow artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jinx-${{ matrix.target.triple }} | |
path: ./target/${{ matrix.target.triple }}/release/jinx${{ matrix.target.suffix }} | |
if-no-files-found: error | |
- name: Rename artifact for release # action-gh-release is incapable of renaming files, so I have to do it manually | |
if: startsWith(github.ref, 'refs/tags/') # only run for pushes to tags | |
run: | | |
cp "./target/${{ matrix.target.triple }}/release/jinx${{ matrix.target.suffix }}" "${{ runner.temp }}/jinx${{ matrix.target.artifact-suffix }}${{ matrix.target.suffix }}" | |
ls "${{ runner.temp }}" | |
file "${{ runner.temp }}${{ matrix.target.path-separator }}jinx${{ matrix.target.artifact-suffix }}${{ matrix.target.suffix }}" | |
shell: bash | |
- name: Upload release artifact | |
uses: softprops/action-gh-release@v0.1.14 | |
if: startsWith(github.ref, 'refs/tags/') # only run for pushes to tags | |
with: | |
draft: true | |
files: ${{ runner.temp }}${{ matrix.target.path-separator }}jinx${{ matrix.target.artifact-suffix }}${{ matrix.target.suffix }} | |
fail_on_unmatched_files: true |