name: Nightly Build
on:
  schedule:
    - cron: '0 2 * * *' # run at 2 AM UTC

jobs:
  build:
    name: Nightly Build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          # - stable
          - nightly
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.rust }}
          override: true
          components: rustfmt, clippy

      - uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --features "sqlite"

      - uses: actions-rs/cargo@v1
        with:
          command: test

      - name: Get current date
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

      - uses: meeDamian/github-release@2.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          name: Nightly Build ${{ steps.date.outputs.date }}
          tag: nightly
          body: >
            This is an automatically generated release
          files: >
            target/release/reasonable
            target/release/bricksql
          gzip: false
          allow_override: true
