aocf 0.1.21

A crate and CLI helper tool for Advent of Code
Documentation
name: release
on:
  push:
    tags:
    - 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
  release_cli:
    needs: release_lib
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: aocf_cli
    steps:

      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

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

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y libsqlite3-dev

      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: clippy
          override: true

      - name: Build and test tool
        run: |
          cargo test --verbose
          #cargo clippy --verbose --all-features -- -D warnings
          cargo build --verbose --release

      - name: Build Debian package for tool
        id: build_deb
        run: |
          cargo install cargo-deb
          cargo deb | tee /tmp/deb_out_path # get deb path from output of `cargo deb`
          echo "path=$(cat /tmp/deb_out_path)" >> $GITHUB_OUTPUT # provide deb output path as output

      - name: Create Github release
        id: make_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
          draft: false
          prerelease: false

      - name: Upload assets to Github
        uses: actions/upload-release-asset@v1.0.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.make_release.outputs.upload_url }}
          asset_content_type: application/vnd.debian.binary-package
          asset_path: ${{ steps.build_deb.outputs.path }}
          asset_name: aocf_cli_${{ steps.get_version.outputs.VERSION }}_amd64.deb

      - name: Publish tool to crates.io
        env:
          CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
        run: |
          cargo login ${CRATES_IO_TOKEN}
          cargo publish

  release_lib:
    runs-on: ubuntu-latest
    steps:

      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

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

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y libsqlite3-dev

      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: clippy
          override: true

      - name: Build and test lib
        run: |
          cargo test --verbose
          #cargo clippy --verbose --all-features -- -D warnings
          cargo build --verbose --release

      - name: Publish lib to crates.io
        env:
          CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
        run: |
          cargo login ${CRATES_IO_TOKEN}
          cargo publish