yanic/.github/workflows/go.yml

94 lines
2.2 KiB
YAML

name: Golang
on:
push:
pull_request:
release:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21]
steps:
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Run tests
run: make test
- uses: codecov/codecov-action@v4
with:
file: coverage.out
lint:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21]
steps:
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: latest
skip-cache: true
args: --timeout=5m
build:
strategy:
matrix:
include:
- arch: amd64
os: linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Build
run: go build -ldflags "-X github.com/FreifunkBremen/yanic/cmd.VERSION=$(git describe --tags)" -v -o yanic_${{ matrix.arch }}_${{ matrix.os }}
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.arch }}-${{ matrix.os }}
path: yanic_*