fetch_unroll 0.3.0

Simple utilities for fetching and unrolling .tar.gz archives
Documentation
name: Rust
on:
  push:
    branches:
      - master
    tags:
      - '[0-9]+.[0-9]+.[0-9]+'
  pull_request:
jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Setup Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          components: rustfmt
          default: true
          override: true
      - name: Cargo cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-rust_stable-${{ hashFiles('**/Cargo.lock') }}
      - name: Format
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

  doc:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Setup Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          profile: minimal
          components: rust-docs
          default: true
          override: true
      - name: Cargo cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-rust_nightly-${{ hashFiles('**/Cargo.lock') }}
      - name: Build cache
        uses: actions/cache@v2
        with:
          path: target
          key: ${{ runner.os }}-build-rust_nightly-doc-${{ hashFiles('**/Cargo.lock') }}
      - name: Documentation
        uses: actions-rs/cargo@v1
        env:
          DOCS_RS: 1
        with:
          command: doc

  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
        with:
          submodules: true
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          profile: minimal
          components: clippy
          default: true
          override: true
      - name: Cargo cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-rust_nightly-${{ hashFiles('**/Cargo.lock') }}
      - name: Build cache
        uses: actions/cache@v2
        with:
          path: target
          key: ${{ runner.os }}-build-rust_nightly-check-${{ hashFiles('**/Cargo.lock') }}
      - uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all --all-features

  test:
    needs:
      - format
      - doc
      - check
    strategy:
      fail-fast: ${{ startsWith(github.ref, 'refs/tags/') }}
      matrix:
        include:
          # Test targets
          - task: targets
            os: ubuntu-latest
            rust: stable
            target: i686-unknown-linux-gnu
          - task: targets
            os: ubuntu-latest
            rust: stable
            target: x86_64-unknown-linux-gnu
          - task: targets
            os: macos-latest
            rust: stable
            target: x86_64-apple-darwin
          - task: targets
            os: windows-latest
            rust: stable
            target: i686-pc-windows-gnu
          - task: targets
            os: windows-latest
            rust: stable
            target: x86_64-pc-windows-gnu
          - task: targets
            os: windows-latest
            rust: stable
            target: i686-pc-windows-msvc
          - task: targets
            os: windows-latest
            rust: stable
            target: x86_64-pc-windows-msvc
          # Test channels
          - task: channels
            os: ubuntu-latest
            rust: stable
            target: x86_64-unknown-linux-gnu
          - task: channels
            os: ubuntu-latest
            rust: beta
            target: x86_64-unknown-linux-gnu
          - task: channels
            os: ubuntu-latest
            rust: nightly
            target: x86_64-unknown-linux-gnu
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Setup cross linux toolchain
        if: contains(matrix.target, '-linux-') && !startsWith(matrix.target, 'x86_64-')
        run: |
          case "${{ matrix.target }}" in
            i686-*) SYSTEM_ARCH=i386 ;;
          esac
          GCC_TARGET=$(printf "${{ matrix.target }}" | sed 's/-unknown-/-/' | sed 's/arm[^-]*/arm/g')
          ENV_TARGET=$(printf "${{ matrix.target }}" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
          sudo dpkg --add-architecture ${SYSTEM_ARCH}
          sudo apt-get update -y
          sudo apt-get install -y libc6-dev:${SYSTEM_ARCH} gcc-${GCC_TARGET}
          echo "CARGO_TARGET_${ENV_TARGET}_LINKER=${GCC_TARGET}-gcc" >> $GITHUB_ENV
      - name: Prepare env for windows
        if: startsWith(matrix.os, 'windows') && endsWith(matrix.target, '-gnu')
        run: |
          echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
          echo "C:\msys64\mingw32\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
          echo "CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
          echo "CC_i686_pc_windows_gnu=i686-w64-mingw32-gcc" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
      - name: Setup Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.rust }}
          target: ${{ matrix.target }}
          profile: minimal
          components: rustfmt
          default: true
          override: true
      - name: Cargo cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-rust_${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
      - name: Build cache
        uses: actions/cache@v2
        with:
          path: target
          key: ${{ runner.os }}-build-rust_${{ matrix.rust }}-target_${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --target ${{ matrix.target }}
      - name: Test
        uses: actions-rs/cargo@v1
        env:
          RUST_BACKTRACE: 1
        with:
          command: test
          args: --all --target ${{ matrix.target }}

  publish:
    if: github.repository == 'katyo/fetch_unroll' && startsWith(github.ref, 'refs/tags/')
    needs:
      - format
      - doc
      - check
      - test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Setup Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
      - name: Publish crates
        uses: katyo/publish-crates@v1
        with:
          registry-token: ${{ secrets.CRATES_TOKEN }}
          args: --no-verify
          #dry-run: true