Skip to content

Update GitHub actions workflows #686

Update GitHub actions workflows

Update GitHub actions workflows #686

Workflow file for this run

name: Build
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
defaults:
run:
shell: bash
jobs:
all:
name: All
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{matrix.os}}
env:
RUSTFLAGS: --deny warnings
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# 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 /usr/local/opt/gnu-tar/libexec/gnubin > $GITHUB_PATH
- name: Install Rust Toolchain Components
uses: actions-rs/toolchain@v1
with:
components: clippy, rustfmt
override: true
target: ${{ matrix.target }}
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Info
run: |
rustup --version
cargo --version
cargo clippy --version
- name: Build
run: cargo build --all
- name: Test
run: cargo test --all
- name: Clippy
run: cargo clippy --all-targets --all-features
- name: Check for Forbidden Words
if: matrix.os == 'macos-latest'
run: |
brew install ripgrep
./bin/forbid
- name: Check Formatting
run: cargo fmt --all -- --check
- name: Check Generated
if: matrix.os == 'macos-latest'
run: |
brew install help2man
cargo run --package gen -- --bin target/debug/imdl all
git diff --no-ext-diff --exit-code
- name: Install `mdbook`
if: matrix.os != 'windows-latest'
uses: peaceiris/actions-mdbook@v2
with:
mdbook-version: 0.4.40
- name: Build Book
if: matrix.os != 'windows-latest'
run: |
cargo run --package gen -- --bin target/debug/imdl book
mdbook build book --dest-dir ../www/book
- name: Record Git Revision
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
run: git rev-parse --verify HEAD > www/head.txt
- name: Deploy Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
with:
github_token: ${{secrets.GITHUB_TOKEN}}
publish_branch: gh-pages
publish_dir: ./www
- name: Package
id: package
if: startsWith(github.ref, 'refs/tags/')
run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{matrix.target}}
- name: Publish Release Archive
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}}