Skip to content

Merge pull request #78 from swoga/renovate/github.com-prometheus-clie… #130

Merge pull request #78 from swoga/renovate/github.com-prometheus-clie…

Merge pull request #78 from swoga/renovate/github.com-prometheus-clie… #130

Workflow file for this run

name: build
on:
push:
branches:
- main
tags:
- v*
env:
GO_VERSION: '1.22.2'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/cache@v4
if: ${{ !env.ACT }}
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Vet
run: go vet ./...
- name: Test
run: go test -v ./...
build-go:
runs-on: ubuntu-latest
needs: test
strategy:
matrix:
os: [linux, windows]
arch: [386, amd64]
include:
- os: darwin
arch: amd64
- os: dragonfly
arch: amd64
- os: linux
arch: arm64
env:
OUTPUT_BINARY_EXT:
OUTPUT_ARCHIVE_EXT: .tar.gz
ARCHIVER: tar -cvzf
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: make build-go
- name: Prepare ENV for Windows
if: matrix.os == 'windows'
run: |
echo "OUTPUT_BINARY_EXT=.exe" >> $GITHUB_ENV
echo "OUTPUT_ARCHIVE_EXT=.zip" >> $GITHUB_ENV
echo "ARCHIVER=zip -r" >> $GITHUB_ENV
- name: Prepare ENV
run: |
echo "OUTPUT_BINARY=mikrotik-exporter${{ env.OUTPUT_BINARY_EXT }}" >> $GITHUB_ENV
echo "OUTPUT_ARCHIVE=mikrotik-exporter.${{ matrix.os }}-${{ matrix.arch }}${{ env.OUTPUT_ARCHIVE_EXT }}" >> $GITHUB_ENV
- name: Compress files
run: ${{ env.ARCHIVER }} ${{ env.OUTPUT_ARCHIVE }} ${{ env.OUTPUT_BINARY }} LICENSE
- name: Upload
uses: actions/upload-artifact@v4
with:
name: mikrotik-exporter.${{ matrix.os }}-${{ matrix.arch }}
path: ${{ env.OUTPUT_ARCHIVE }}
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ${{ env.OUTPUT_ARCHIVE }}
build-container:
runs-on: ubuntu-latest
needs: build-go
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/download-artifact@v4
with:
name: mikrotik-exporter.linux-amd64
- name: Decompress
run: tar -xf mikrotik-exporter.linux-amd64.tar.gz
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Login to GHCR
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Quay
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Login to Docker Hub
if: ${{ !env.ACT }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- if: startsWith(github.ref, 'refs/tags/')
run: echo "TAG=latest" >> $GITHUB_ENV
- name: Build
run: make build-container
- name: Push
if: ${{ !env.ACT }}
run: make push-container