just/.github/workflows/build.yaml
Casey Rodarmor 2909614f68
Fix build fix (#693)
Fix the conditional that gates installing GNU Tar. This should finally
fix the build errors we've been seeing.
2020-10-04 13:23:27 -07:00

131 lines
3.2 KiB
YAML

name: Build
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
env:
# Increment to invalidate github actions caches if they become corrupt.
# Errors of the form "can't find crate for `snafu_derive` which `snafu` depends on"
# can usually be fixed by incrementing this value.
CACHE_KEY_PREFIX: 4
jobs:
all:
name: All
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-2016
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-2016
target: x86_64-pc-windows-msvc
runs-on: ${{matrix.os}}
env:
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v2
# An issue with BSD Tar causes sporadic failures on macOS.
# c.f https://github.com/actions/cache/issues/403
- name: Install GNU Tar
if: matrix.os == 'macos-latest'
run: |
brew install gnu-tar
echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ env.CACHE_KEY_PREFIX }}-${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ env.CACHE_KEY_PREFIX }}-${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ env.CACHE_KEY_PREFIX }}-${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Install Main Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
components: clippy, rustfmt
override: true
- name: Version
run: |
rustup --version
cargo --version
cargo clippy --version
- name: Build
run: cargo build --all --verbose
- name: Test
run: cargo test --all --verbose
- name: Clippy
run: cargo clippy --all
- name: Lint
if: matrix.os != 'windows-2016'
run: cargo run lint
- name: Install Rustfmt Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
profile: minimal
components: rustfmt
- name: Format
run: cargo +nightly fmt --all -- --check
- name: Completion Scripts
if: matrix.os != 'windows-2016'
run: |
./bin/generate-completions
git diff --no-ext-diff --quiet --exit-code
- name: Package
id: package
if: startsWith(github.ref, 'refs/tags/')
run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{ matrix.target }}
shell: bash
- name: Publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
files: ${{ steps.package.outputs.archive }}
prerelease: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}