adguard-exporter/.github/workflows/master.yml
2020-12-22 18:32:19 +01:00

100 lines
2.3 KiB
YAML

name: Build/Push (master)
on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.15
- name: Install go dependencies
run: go get -t -v ./...
- name: Run go tests
run: go test -v -cover -race ./...
build-docker:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push docker image
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: ebrianne/adguard-exporter:latest
build:
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
include:
- os: linux
arch: 386
- os: linux
arch: amd64
- os: linux
arch: arm
- os: linux
arch: arm64
- os: darwin
arch: amd64
- os: freebsd
arch: 386
- os: freebsd
arch: amd64
- os: windows
arch: 386
extension: '.exe'
- os: windows
arch: amd64
extension: '.exe'
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Download go dependencies
run: go get -t -v ./...
- name: Install the needed vendors
run: GO111MODULE=on go mod vendor
- name: Create release (${{ matrix.os }}-${{ matrix.arch }})
run: CGO_ENABLED=0 GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -a -ldflags '-s -w' -o adguard_exporter-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.extension }} ./