name: build
on:
  push:
    tags:
      - "*"
    branches:
      - master
  pull_request:
jobs:
  images:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
      - run: images/build -d

  linters:
    name: verify / ${{ matrix.run }}
    runs-on: ubuntu-latest
    timeout-minutes: 10
    strategy:
      matrix:
        run:
          - lint
          - boilerplate
          - dependencies
          - go-modules
          - docs
    steps:
      - name: Checkout
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
      - name: Install Go
        uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
        with:
          go-version-file: go.mod
      - run: make verify-${{ matrix.run }}

  test:
    name: test / crictl
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
      - name: Install Go
        uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
        with:
          go-version-file: go.mod
      - run: make test-crictl

  releases:
    name: releases / on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    timeout-minutes: 40

    strategy:
      matrix:
        os:
          [ubuntu-22.04, macos-latest] # TODO: make releases on 'linux-ppc64le' 'windows-2025'
          # Ref: https://github.com/uraimo/run-on-arch-action
    steps:
      - name: Checkout
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with:
          fetch-depth: 0
      - name: Install Go
        uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
        with:
          go-version-file: go.mod
      - name: Make release
        run: make release

  typos:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
      - uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 # v1.40.0
        with:
          config: .typos.toml

  prettier:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
      - uses: creyD/prettier_action@8c18391fdc98ed0d884c6345f03975edac71b8f0 # v4.6
        with:
          dry: true
          prettier_options: --write .
