mdpage 0.1.3

Simple documentation tool
Documentation
name: release

on:
  push:
    tags:
      - v*

jobs:
  
  github_build:
    name: Deploy Release
    strategy:
      matrix:
        target:
          - x86_64-unknown-linux-gnu
          - x86_64-apple-darwin
          - x86_64-pc-windows-msvc
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            name: mdpage-x86_64-unknown-linux-gnu.tar.gz
          - target: x86_64-apple-darwin
            os: macOS-latest
            name: mdpage-x86_64-apple-darwin.tar.gz
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            name: mdpage-x86_64-pc-windows-msvc.zip
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@master
      
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          target: ${{ matrix.target }}
      
      - name: Build target
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --target ${{ matrix.target }}

      - name: Prepare build artifacts [Windows]
        if: matrix.os == 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          strip mdpage.exe
          7z a ../../../${{ matrix.name }} mdpage.exe
          cd -
            
      - name: Prepare build artifacts [-nix]
        if: matrix.os != 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          strip mdpage
          tar czvf ../../../${{ matrix.name }} mdpage
          cd -

      - name: Upload build artifact
        uses: actions/upload-artifact@v1
        with:
          name: ${{ matrix.name }}
          path: ${{ matrix.name }}

  github_release:
    name: Create GitHub Release
    needs: github_build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      # These can be squashed when https://github.com/actions/download-artifact/issues/6 is closed
      - name: Download releases from github_build
        uses: actions/download-artifact@v1
        with:
          name: mdpage-x86_64-unknown-linux-gnu.tar.gz
          path: .
      - name: Download releases from github_build
        uses: actions/download-artifact@v1
        with:
          name: mdpage-x86_64-apple-darwin.tar.gz
          path: .
      - name: Download releases from github_build
        uses: actions/download-artifact@v1
        with:
          name: mdpage-x86_64-pc-windows-msvc.zip
          path: .

      - name: Generate checksums
        run: for file in mdpage-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done

      - name: Generate release notes
        run: |
          # Temporary fix for https://github.com/actions/setup-go/issues/14
          export PATH=$PATH:$(go env GOPATH)/bin
          go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
          # git-chglog -c .chglog/config.yml $(git describe --tags) > RELEASE.md
          git-chglog -c .chglog/config.yml $(git describe --tags) > RELEASE.md

      - name: Create GitHub release ${{ matrix.target }}
        uses: softprops/action-gh-release@v1
        with:
          files: |
            mdpage-x86_64-unknown-linux-gnu.tar.gz
            mdpage-x86_64-unknown-linux-gnu.tar.gz.sha256
            mdpage-x86_64-apple-darwin.tar.gz
            mdpage-x86_64-apple-darwin.tar.gz.sha256
            mdpage-x86_64-pc-windows-msvc.zip
            mdpage-x86_64-pc-windows-msvc.zip.sha256
          body_path: RELEASE.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  # Publish to Crates.io
  cargo_publish:
    name: Publish Cargo Package
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - run: cargo login $CRATES_IO_TOKEN
      - run: cargo publish
    env:
      CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}