caniuse-rs 0.1.11

A command line client for caniuse.com, written in Rust.
name: Release to crates.io and GitHub Releases
on:
  push:
    tags:
      - 'v*'

jobs:
  lint-with-clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - uses: actions-rs/cargo@v1
        with:
          command: clippy

  build-linux:
    runs-on: ubuntu-latest
    needs: lint-with-clippy
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: Install Targets
        run: make install-targets-linux
      - name: Build Linux
        id: build-linux
        run: |
          make build-linux
      - name: Upload Artifact
        uses: actions/upload-artifact@v2
        with:
          name: caniuse-linux-x86
          path: ./caniuse-linux-x86

  build-macos-x86:
    runs-on: macos-11
    needs: lint-with-clippy
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: Install Targets
        run: make install-targets-mac-x86
      - name: Build MacOS
        id: build-macos-x86
        run: |
          make build-macos-x86
      - name: Upload Artifact
        uses: actions/upload-artifact@v2
        with:
          name: caniuse-macos-x86
          path: ./caniuse-macos-x86

  build-macos-arm:
    runs-on: macos-11
    needs: lint-with-clippy
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: Install Targets
        run: make install-targets-mac-arm
      - name: Build MacOS
        id: build-macos-arm
        run: |
          make build-macos-arm
      - name: Upload Artifact
        uses: actions/upload-artifact@v2
        with:
          name: caniuse-macos-arm
          path: ./caniuse-macos-arm

  build-alfred-workflows:
    runs-on: macos-11
    needs: [build-macos-x86, build-macos-arm]
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: Download MacOS x86 Build Artifact
        uses: actions/download-artifact@v2
        with:
          name: caniuse-macos-x86
      - name: Download MacOS ARM Build Artifact
        uses: actions/download-artifact@v2
        with:
          name: caniuse-macos-arm
      - name: Create Alfred Workflow File
        id: build-alfred-workflows
        run: |
          make WORKFLOW_FILE_NAME="caniuse-macos-x86.alfredworkflow" CANIUSE_BIN="caniuse-macos-x86" alfred-workflow
          make WORKFLOW_FILE_NAME="caniuse-macos-arm.alfredworkflow" CANIUSE_BIN="caniuse-macos-arm" alfred-workflow
      - name: Upload MacOS x86 Alfred Workflow File
        uses: actions/upload-artifact@v2
        with:
          name: alfred-workflow-x86
          path: caniuse-macos-x86.alfredworkflow
      - name: Upload MacOS ARM Alfred Workflow File
        uses: actions/upload-artifact@v2
        with:
          name: alfred-workflow-arm
          path: caniuse-macos-arm.alfredworkflow

  create-github-release:
    runs-on: ubuntu-latest
    needs: [build-linux, build-macos-x86, build-macos-arm, build-alfred-workflows]
    steps:
      - uses: actions/checkout@v2
      - name: Download MacOS x86 Build Artifact
        uses: actions/download-artifact@v2
        with:
          name: caniuse-macos-x86
      - name: Download MacOS ARM Build Artifact
        uses: actions/download-artifact@v2
        with:
          name: caniuse-macos-arm
      - name: Download Linux x86 Build Artifact
        uses: actions/download-artifact@v2
        with:
          name: caniuse-linux-x86
      - name: Download x86 Alfred Workflow File
        uses: actions/download-artifact@v2
        with:
          name: alfred-workflow-x86
      - name: Download ARM Alfred Workflow File
        uses: actions/download-artifact@v2
        with:
          name: alfred-workflow-arm
      - name: Make Binaries Executable
        run: |
          chmod +x caniuse-macos-x86
          chmod +x caniuse-macos-arm
          chmod +x caniuse-linux-x86
      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          generate_release_notes: true
          fail_on_unmatched_files: true
          files: |
            caniuse-macos-x86
            caniuse-macos-x86.alfredworkflow
            caniuse-macos-arm
            caniuse-macos-arm.alfredworkflow
            caniuse-linux-x86

  cargo-publish:
    runs-on: ubuntu-latest
    needs: create-github-release
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: Cargo Publish
        env:
          CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
        run: make publish