name: Go

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    name: Build Go ${{ matrix.go }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go: [ '1.22','1.21','1.20','1.19','1.18' ]
    steps:
    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

    - name: Setup go
      uses: actions/setup-go@v1
      with:
        go-version: ${{ matrix.go }}

    - name: Get dependencies
      run: |
        go get -v -t -d ./...

    - name: Test
      run: go test ./...

    - name: Coverage
      run: |
        go test -race . -coverprofile=coverage.txt -covermode=atomic

    - name: Build
      run: cd truecli && go build -v -o truecli
