2020-05-05 08:47:24 +02:00
|
|
|
name: Build/Push (tag)
|
2020-04-04 06:34:00 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-05-05 13:32:37 +02:00
|
|
|
tags:
|
|
|
|
- '*'
|
2020-04-04 06:34:00 +02:00
|
|
|
|
|
|
|
jobs:
|
2020-05-05 08:47:24 +02:00
|
|
|
test:
|
2020-04-04 06:34:00 +02:00
|
|
|
runs-on: ubuntu-latest
|
2020-05-05 08:47:24 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-03-02 20:44:38 +01:00
|
|
|
go_version: [ '1.20' ]
|
2020-04-04 06:34:00 +02:00
|
|
|
steps:
|
2023-03-02 20:44:38 +01:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-go@v3
|
2020-05-05 08:47:24 +02:00
|
|
|
with:
|
|
|
|
go-version: ${{ matrix.go_version }}
|
|
|
|
- run: go get -t -v ./...
|
|
|
|
- run: go test -v -race ./...
|
2020-05-04 21:02:27 +02:00
|
|
|
|
2020-12-31 08:53:26 +01:00
|
|
|
docker-build:
|
2020-05-04 21:02:27 +02:00
|
|
|
runs-on: ubuntu-latest
|
2020-05-05 08:47:24 +02:00
|
|
|
needs: test
|
2020-05-04 21:02:27 +02:00
|
|
|
steps:
|
2023-03-02 20:44:38 +01:00
|
|
|
- uses: actions/checkout@v3
|
2020-05-05 08:47:24 +02:00
|
|
|
|
|
|
|
- uses: azure/docker-login@v1
|
2020-05-04 20:50:12 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2020-05-05 08:47:24 +02:00
|
|
|
|
|
|
|
- name: Set up docker buildx
|
|
|
|
id: buildx
|
|
|
|
uses: crazy-max/ghaction-docker-buildx@v1
|
|
|
|
with:
|
|
|
|
buildx-version: latest
|
|
|
|
qemu-version: latest
|
|
|
|
|
|
|
|
- name: Docker buildx available platforms
|
|
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
|
|
|
2020-05-04 21:02:27 +02:00
|
|
|
- name: Get the version
|
|
|
|
id: get_version
|
|
|
|
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
|
2020-05-05 08:47:24 +02:00
|
|
|
|
|
|
|
- name: Run docker buildx build
|
|
|
|
run: |
|
|
|
|
docker buildx build \
|
|
|
|
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
|
2022-06-06 07:03:56 +02:00
|
|
|
--output=type=registry,push=true \
|
2020-05-05 08:47:24 +02:00
|
|
|
--tag ekofr/pihole-exporter:${{ steps.get_version.outputs.TAG_NAME }} \
|
|
|
|
.
|
|
|
|
|
|
|
|
release:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: test
|
|
|
|
steps:
|
|
|
|
- name: Create release
|
|
|
|
id: create
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ github.ref }}
|
|
|
|
release_name: ${{ github.ref }}
|
|
|
|
draft: false
|
|
|
|
prerelease: false
|
2020-05-05 13:32:37 +02:00
|
|
|
outputs:
|
|
|
|
upload_url: ${{ steps.create.outputs.upload_url }}
|
2020-05-05 08:47:24 +02:00
|
|
|
|
2020-05-05 13:32:37 +02:00
|
|
|
upload:
|
2020-05-05 08:47:24 +02:00
|
|
|
needs: release
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
2020-12-31 08:53:26 +01:00
|
|
|
- os: ubuntu-latest
|
|
|
|
goos: linux
|
|
|
|
goarch: 386
|
|
|
|
- os: ubuntu-latest
|
|
|
|
goos: linux
|
|
|
|
goarch: amd64
|
|
|
|
- os: ubuntu-latest
|
|
|
|
goos: linux
|
|
|
|
goarch: arm
|
|
|
|
- os: macos-latest
|
|
|
|
goos: darwin
|
|
|
|
goarch: amd64
|
|
|
|
- os: macos-latest
|
|
|
|
goos: darwin
|
|
|
|
goarch: arm64
|
|
|
|
- os: ubuntu-latest
|
|
|
|
goos: windows
|
|
|
|
goarch: 386
|
2020-05-05 13:32:37 +02:00
|
|
|
extension: '.exe'
|
2020-12-31 08:53:26 +01:00
|
|
|
- os: ubuntu-latest
|
|
|
|
goos: windows
|
|
|
|
goarch: amd64
|
2020-05-05 13:32:37 +02:00
|
|
|
extension: '.exe'
|
2020-12-31 08:53:26 +01:00
|
|
|
runs-on: ${{ matrix.os }}
|
2020-05-05 08:47:24 +02:00
|
|
|
steps:
|
2023-03-02 20:44:38 +01:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-go@v3
|
2020-05-05 08:47:24 +02:00
|
|
|
with:
|
2023-03-02 20:44:38 +01:00
|
|
|
go-version: '1.20'
|
2020-05-05 08:47:24 +02:00
|
|
|
|
2020-05-05 13:32:37 +02:00
|
|
|
- name: Download go dependencies
|
|
|
|
run: go get -t -v ./...
|
|
|
|
|
2021-10-18 12:35:35 +02:00
|
|
|
# Release File
|
2020-05-05 13:32:37 +02:00
|
|
|
- name: Create release
|
2020-12-31 08:53:26 +01:00
|
|
|
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags "-s -w" -o pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }} ./
|
2021-10-18 12:35:35 +02:00
|
|
|
|
2020-05-05 08:47:24 +02:00
|
|
|
- name: Upload release assets
|
|
|
|
id: upload-release-asset
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2020-05-05 13:32:37 +02:00
|
|
|
upload_url: ${{ needs.release.outputs.upload_url }}${{ matrix.extension }}
|
2020-12-31 08:53:26 +01:00
|
|
|
asset_path: ./pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}
|
|
|
|
asset_name: pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}
|
2020-05-05 08:47:24 +02:00
|
|
|
asset_content_type: application/octet-stream
|
2021-10-18 12:35:35 +02:00
|
|
|
|
|
|
|
# SHA256 Sum File
|
|
|
|
- name: Create SHA256 sum
|
|
|
|
run: sha256sum pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }} > pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}.sha256.txt
|
|
|
|
|
|
|
|
- name: Upload release assets
|
|
|
|
id: upload-release-sum-asset
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ needs.release.outputs.upload_url }}${{ matrix.extension }}.sha256.txt
|
|
|
|
asset_path: ./pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}.sha256.txt
|
|
|
|
asset_name: pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}.sha256.txt
|
|
|
|
asset_content_type: application/octet-stream
|