Merge pull request #260 from ouch-org/fix-completions-generation
[ouch.git] / .github / workflows / build-and-test.yml
blob47232f95d1d12d608bab9d17b2da4e7b6f9f02fd
1 name: build-and-test
3 on: [push, pull_request]
5 jobs:
6   build:
7     name: build
8     runs-on: ${{ matrix.os }}
9     strategy:
10       matrix:
11         include:
12           - target: x86_64-apple-darwin
13             os: macos-latest
14           # - target: x86_64-pc-windows-gnu
15           #   os: windows-latest
16           #   ext: .exe
17           - target: x86_64-pc-windows-msvc
18             os: windows-latest
19             ext: .exe
20           - target: x86_64-unknown-linux-gnu
21             os: ubuntu-latest
22           - target: x86_64-unknown-linux-musl
23             os: ubuntu-latest
25     steps:
26       - name: Checkout
27         uses: actions/checkout@v2
29       - name: Install dependencies (musl)
30         if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
31         run: |
32           sudo apt-get update
33           sudo apt-get install help2man musl-tools
35       - name: Build and test on stable
36         run: |
37           rustup toolchain install stable --profile minimal -t ${{ matrix.target }}
38           cargo +stable build --target ${{ matrix.target }}
39           cargo +stable test --target ${{ matrix.target }}
41       - name: Release on nightly
42         run: |
43           rustup toolchain install nightly --profile minimal -t ${{ matrix.target }}
44           cargo +nightly build --release --target ${{ matrix.target }}
45         env:
46           GEN_COMPLETIONS: 1
47           RUSTFLAGS: -Z strip=symbols
49       - name: Upload bianry
50         uses: actions/upload-artifact@v2
51         with:
52           name: ouch-${{ matrix.target }}${{ matrix.ext }}
53           path: target/${{ matrix.target }}/release/ouch${{ matrix.ext }}
55       - name: Build man page and find completions (musl)
56         if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
57         run: |
58           help2man target/${{ matrix.target }}/release/ouch > ouch.1
59           cp -r target/${{ matrix.target }}/release/build/ouch-*/out/completions .
61       - name: Upload completions (musl)
62         if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
63         uses: actions/upload-artifact@v2
64         with:
65           name: completions
66           path: completions
68       - name: Upload man page (musl)
69         if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
70         uses: actions/upload-artifact@v2
71         with:
72           name: ouch.1
73           path: ouch.1
75   clippy-rustfmt:
76     name: clippy-rustfmt
77     runs-on: ubuntu-latest
78     steps:
79       - name: Checkout
80         uses: actions/checkout@v2
82       - name: "Cargo: clippy, fmt"
83         run: |
84           rustup toolchain install stable --profile minimal -c clippy
85           rustup toolchain install nightly --profile minimal -c rustfmt
86           cargo +stable clippy -- -D warnings
87           cargo +nightly fmt -- --check