cli-candlestick-chart 0.4.1

A library for displaying candlestick charts right into your terminal.
Documentation
on:
  push:
    tags:
      - "*"

name: Release

jobs:
  create-release:
    name: "Create Release"
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create-release.outputs.upload_url }}
    steps:
      - name: Create Release
        id: create-release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
          draft: true
          prerelease: false

  release:
    name: "Release"
    needs: create-release
    strategy:
      matrix:
        target:
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            cross: false
            binary_path: target/x86_64-pc-windows-msvc/release/cli-candlestick-chart.exe
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            cross: false
            binary_path: target/x86_64-unknown-linux-gnu/release/cli-candlestick-chart
          - target: x86_64-apple-darwin
            os: macos-latest
            cross: false
            binary_path: target/x86_64-apple-darwin/release/cli-candlestick-chart

    runs-on: ${{ matrix.target.os }}
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Get the version
        id: get_version
        shell: bash
        run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}

      - name: Install libssl ubuntu
        id: install_build_tools
        if: matrix.target.os == 'ubuntu-latest'
        run: |
          echo ${{ matrix.target.os }}
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends libssl-dev pkg-config

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: ${{ matrix.target.target }}
          override: true

      - name: Run cargo build
        uses: actions-rs/cargo@v1
        with:
          use-cross: ${{ matrix.target.cross }}
          command: build
          args: --release --bin=cli-candlestick-chart --features=bin-app --target=${{ matrix.target.target }}

      - name: Copy release files
        shell: bash
        run: |
          mkdir package
          cp -R LICENSE README.md docs/ package/
          cp ${{ matrix.target.binary_path }} package/
      - name: Create Archive
        shell: bash
        if: matrix.target.os != 'windows-latest'
        run: |
          tar czvf cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.tar.gz -C package/ .
      - name: Create Archive (Windows)
        if: matrix.target.os == 'windows-latest'
        run: |
          cd package; 7z.exe a ../cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.zip .
      - name: Upload Release Asset
        if: matrix.target.os != 'windows-latest'
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create-release.outputs.upload_url }}
          asset_path: ./cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.tar.gz
          asset_name: cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.tar.gz
          asset_content_type: application/x-gzip

      - name: Upload Release Asset (Windows)
        if: matrix.target.os == 'windows-latest'
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create-release.outputs.upload_url }}
          asset_path: ./cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.zip
          asset_name: cli-candlestick-chart-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target.target }}.zip
          asset_content_type: application/zip

  publish:
    name: "Publish"
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true

      - name: Publish cli-candlestick-chart
        uses: actions-rs/cargo@v1
        with:
          command: publish
          args: --token ${{ secrets.CRATES_TOKEN }}