clyde 0.4.0

A cross-platform package manager for prebuilt applications
Documentation
name: Build

on:
  pull_request:
  push:
    branches:
      # Only build on pushes to the main branch, otherwise branches pushed for PR
      # are built twice
      - main
    tags:
  workflow_dispatch:

jobs:
  lint:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3

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

      - name: Run static checks
        run: ci/run-static-checks

  build:
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-20.04
          - macos-11
          - windows-2019

    runs-on: ${{ matrix.os }}

    defaults:
      run:
        shell: bash

    steps:
      - uses: actions/checkout@v3
        with:
          # Use `fetch-depth: 0` otherwise `git describe` does not see valid
          # tags, causing ci/create-archive to create snapshot archives. This
          # also requires the "Fix actions/checkout bug" step below to work.
          fetch-depth: 0

      # See https://github.com/actions/checkout/issues/290#issuecomment-680260080
      - name: Fix actions/checkout bug
        run: git fetch --force --tags

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

      - name: Build
        run: ci/build-app

      - name: Run tests
        run: ci/run-tests

      - name: Create archive
        run: ci/create-archive

      - name: Upload artifacts
        uses: actions/upload-artifact@v3
        with:
          name: artifacts
          path: |
            artifacts/*.gz
            artifacts/*.zip

  server-upload:
    needs:
      - lint
      - build
    runs-on: ubuntu-20.04
    if: github.ref == 'refs/heads/main'

    steps:
      - uses: actions/checkout@v2

      - name: Download artifacts
        uses: actions/download-artifact@v3
        with:
          name: artifacts
          path: artifacts

      - name: Upload to builds.agateau.com
        run: ci/upload-build clyde artifacts/*.gz artifacts/*.zip
        env:
          UPLOAD_USERNAME: ${{ secrets.UPLOAD_USERNAME }}
          UPLOAD_PRIVATE_KEY: ${{ secrets.UPLOAD_PRIVATE_KEY }}
          UPLOAD_HOSTNAME: ${{ secrets.UPLOAD_HOSTNAME }}