mdcat 0.22.1

cat for markdown: Show markdown documents in terminals
Documentation
name: Release

on:
  push:
    tags:
      - mdcat-*

jobs:
  build-binaries:
    runs-on: '${{ matrix.os }}'
    strategy:
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            flags: --no-default-features
          - os: macOS-latest
            target: x86_64-apple-darwin
          - os: windows-latest
            target: x86_64-pc-windows-msvc
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          target: ${{ matrix.target }}
      - uses: actions/setup-ruby@v1
      - name: install asciidoctor for manpage build
        run: gem install asciidoctor
      - name: Install musl
        run: sudo apt-get install musl-tools
        if: contains(matrix.target, 'linux-musl')
      - name: Build in release configuration
        shell: bash
        id: build
        run: |
            OUTDIR="$(cargo build --locked --target '${{ matrix.target }}' ${{ matrix.flags }} --release --message-format=json-render-diagnostics |
                jq -r 'select(.out_dir) | select(.package_id | startswith("mdcat ")) | .out_dir')"
            echo "::set-output name=outdir::$OUTDIR"
      - name: Strip binary
        run: strip 'target/${{ matrix.target }}/release/mdcat'
        if: "!contains(matrix.target, 'windows')"
      - name: Get version
        id: version
        shell: bash
        run: |
          VERSION="$(cargo pkgid | cut -d'#' -f2 | cut -d: -f2)"
          echo "::set-output name=version::$VERSION"
      - name: Build package
        id: package
        shell: bash
        run: ./scripts/package '${{ steps.version.outputs.version }}' '${{ matrix.target }}' '${{ steps.build.outputs.outdir }}'
      - name: Upload artifacts
        uses: actions/upload-artifact@v2
        with:
          name: ${{ steps.package.outputs.name }}
          path: ${{ steps.package.outputs.file }}

  create-release:
    runs-on: ubuntu-latest
    needs: build-binaries
    steps:
      - uses: actions/checkout@v2
      - name: Download artifacts
        uses: actions/download-artifact@v2
        with:
          path: ./artifacts
      - name: Aggregate assets
        run: |
          mkdir ./assets
          mv ./artifacts/*/*.{zip,tar.gz} ./assets
      - name: Compute checksums
        # We create checksum files in the parent directory to avoid checksumming the checksums
        run: |
          b2sum * > ../B2SUMS.txt
          sha512sum * > ../SHA512SUM.txt
          mv ../B2SUMS.txt ../SHA512SUM.txt .
        working-directory: assets
      - name: Get version
        id: version
        shell: bash
        run: |
          VERSION="$(cargo pkgid | cut -d'#' -f2 | cut -d: -f2)"
          echo "::set-output name=version::$VERSION"
      - name: Extract changelog
        shell: bash
        run: |
          awk -v r='${{ steps.version.outputs.version }}' \
            '/^\[[^]]*\]/{print $0}/^## \[[0-9]/ && match($0, /\[[0-9][^]]*\]/){if (r == substr($0, RSTART+1, RLENGTH-2)) { p=1; next } else { p=0 } }p' \
            CHANGELOG.md > ./CHANGELOG-release.md
          cat CHANGELOG-release.md
      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          name: mdcat-${{ steps.version.outputs.version }}
          body_path: ./CHANGELOG-release.md
          files: "./assets/*"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}