lesspass 0.5.0

An efficient implementation of the LessPass password generator.
Documentation
# Action based on
# https://github.com/actions-rs/meta/blob/edeebc14493689cee04cb6d941c42c36a86e9d18/recipes/quickstart.md
on: [push, pull_request]

name: Continuous integration

jobs:
  ci:
    name: CI
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746
        with:
          profile: minimal
          toolchain: "1.70"  # MSRV
          override: true
          components: rustfmt, clippy

      - name: Tests
        uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72
        with:
          command: test  # Test debug assertions; we don't test with `--release` because it enables a lot more CPU-heavy tests.

      - name: Rustfmt
        if: success() || failure()
        uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72
        with:
          command: fmt
          args: --all -- --check

      - name: Clippy
        if: success() || failure()
        uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72
        with:
          command: clippy
          args: -- -D warnings

  version:
    name: Create tag
    needs: ci
    runs-on: ubuntu-latest
    if: ${{ github.event_name == 'push' }}
    steps:
      - uses: actions/checkout@v2
      - name: Create tag on new version
        uses: ButlerLogic/action-autotag@c3786d617002bf8f89eec2eac64b0842fd7f5826
        id: autotag
        with:
          tag_prefix: v
          root: Cargo.toml
          regex_pattern: '^version\s*=\s*"([0-9.]+)"'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    outputs:
      is-new-version: ${{ steps.autotag.outputs.created == 'yes' }}
      version: ${{ steps.autotag.outputs.version }}

  release:
    name: Release binaries
    needs: version
    if: ${{ github.event_name == 'push' && needs.version.outputs.is-new-version }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - aarch64-unknown-linux-gnu
          - x86_64-pc-windows-gnu
          - x86_64-unknown-linux-gnu
    steps:
      - uses: actions/checkout@v2

      - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746
        with:
          profile: minimal
          toolchain: stable
          override: true
          target: ${{ matrix.target }}
      - uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72
        with:
          command: build
          args: --release --target ${{ matrix.target }} --bin lesspass
          use-cross: true

      - name: Strip release binary
        if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
        run: strip "target/${{ matrix.target }}/release/lesspass"

      - name: Package binary
        shell: bash
        run: |
          BINARY_PATH="target/${{ matrix.target }}/release/lesspass"
          ARCHIVE_NAME="lesspass-${{ needs.version.outputs.version }}-${{ matrix.target }}"

          mkdir "$ARCHIVE_NAME"

          if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
            cp "$BINARY_PATH.exe" "$ARCHIVE_NAME"
            ARCHIVE="$ARCHIVE_NAME.zip"
            7z a "$ARCHIVE" "$ARCHIVE_NAME"
          else
            cp "$BINARY_PATH" "$ARCHIVE_NAME"
            ARCHIVE="$ARCHIVE_NAME.tar.gz"
            tar czf "$ARCHIVE" "$ARCHIVE_NAME"
          fi

          openssl dgst -r -sha256 -out "$ARCHIVE.sha256" "$ARCHIVE"
          openssl dgst -r -sha512 -out "$ARCHIVE.sha512" "$ARCHIVE"

          echo "ASSET=$ARCHIVE" >> $GITHUB_ENV

      - name: Create release
        uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d
        with:
          fail_on_unmatched_files: true
          tag_name: v${{ needs.version.outputs.version }}
          files: |
            ${{ env.ASSET }}
            ${{ env.ASSET }}.sha256
            ${{ env.ASSET }}.sha512
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}