Skip to content

Add rustfmt.toml, update formatting #181

Add rustfmt.toml, update formatting

Add rustfmt.toml, update formatting #181

Workflow file for this run

name: pipeline
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: build
run: cargo test --no-run
- name: test
run: cargo test -- --nocapture --quiet
- name: formatting
run: cargo fmt --all -- --check
- name: check
run: cargo check
- name: clippy
run: cargo clippy -- -D warnings
cargo_publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: check
name: Publish Cargo Package
runs-on: ubuntu-latest
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo login $CRATES_IO_TOKEN
- run: cargo publish
github_build:
if: startsWith(github.ref, 'refs/tags/v')
needs: check
name: Build release binaries
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: git-ignore-x86_64-unknown-linux-gnu.tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: git-ignore-x86_64-unknown-linux-musl.tar.gz
- target: x86_64-apple-darwin
os: macos-latest
name: git-ignore-x86_64-apple-darwin.tar.gz
- target: aarch64-apple-darwin
os: macos-14
name: git-ignore-aarch64-apple-darwin.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
name: git-ignore-x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install -y musl-tools libssl-dev
- name: Build target
if: matrix.target != 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Build target (musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare build artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip git-ignore.exe
cp ../assets/* .
7z a ../../../${{ matrix.name }} git-ignore.exe _git-ignore git-ignore.1 git-ignore.bash git-ignore.elv git-ignore.fish _git-ignore.ps1
cd -
- name: Prepare build artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip git-ignore
cp ../assets/* .
tar czvf ../../../${{ matrix.name }} git-ignore _git-ignore git-ignore.1 git-ignore.bash git-ignore.elv git-ignore.fish _git-ignore.ps1
cd -
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
github_release:
if: startsWith(github.ref, 'refs/tags/v')
name: Create GitHub Release
needs: github_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Linux GNU artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-unknown-linux-gnu.tar.gz
path: .
- name: Download Linux MUSL artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-unknown-linux-musl.tar.gz
path: .
- name: Download Darwin artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-apple-darwin.tar.gz
path: .
- name: Download Darwin artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-aarch64-apple-darwin.tar.gz
path: .
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: git-ignore-x86_64-pc-windows-msvc.zip
path: .
- name: Print directory
run: ls -R
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: |
git-ignore-x86_64-apple-darwin.tar.gz
git-ignore-aarch64-apple-darwin.tar.gz
git-ignore-x86_64-pc-windows-msvc.zip
git-ignore-x86_64-unknown-linux-gnu.tar.gz
git-ignore-x86_64-unknown-linux-musl.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}