Updated GitHub actions to use matrix
This commit is contained in:
parent
c3fc22f53c
commit
6587709767
3 changed files with 137 additions and 75 deletions
57
.github/workflows/master.yml
vendored
57
.github/workflows/master.yml
vendored
|
@ -1,47 +1,50 @@
|
||||||
name: Build and Publish (master)
|
name: Build/Push (master)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ ci ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ ci ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-amd64:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go_version: [ '1.12', '1.13', '1.14' ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build and Push Docker Image (Linux - AMD64)
|
- uses: actions/setup-go@v1
|
||||||
uses: docker/build-push-action@v1
|
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
go-version: ${{ matrix.go_version }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
- run: go get -t -v ./...
|
||||||
repository: ekofr/pihole-exporter
|
- run: go test -v -race ./...
|
||||||
tags: amd64
|
|
||||||
build_args: OS=linux,ARCH=amd64,IMAGE=scratch
|
|
||||||
|
|
||||||
build-arm32:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
needs: test
|
||||||
- uses: actions/checkout@v2
|
strategy:
|
||||||
- name: Build and Push Docker Image (Linux - ARM32)
|
matrix:
|
||||||
uses: docker/build-push-action@v1
|
include:
|
||||||
with:
|
- os: linux
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
arch: amd64
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
image: scratch
|
||||||
repository: ekofr/pihole-exporter
|
- os: linux
|
||||||
tags: arm32
|
arch: arm
|
||||||
build_args: OS=linux,ARCH=arm,IMAGE=arm32v7/alpine:3.11
|
image: arm32v7/alpine:3.11
|
||||||
|
- os: linux
|
||||||
|
arch: arm64
|
||||||
|
image: arm64v8/alpine:3.11
|
||||||
|
|
||||||
build-arm64:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build and Push Docker Image (Linux - ARM64)
|
|
||||||
|
- name: Build/Push docker image (${{ matrix.os }}/${{ matrix.arch }})
|
||||||
uses: docker/build-push-action@v1
|
uses: docker/build-push-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
repository: ekofr/pihole-exporter
|
repository: ekofr/pihole-exporter
|
||||||
tags: arm64
|
tags: ${{ matrix.arch }}
|
||||||
build_args: OS=linux,ARCH=arm64,IMAGE=arm64v8/alpine:3.11
|
build_args: OS=${{ matrix.os }},ARCH=${{ matrix.arch }},IMAGE=${{ matrix.image }}
|
||||||
|
|
||||||
|
|
135
.github/workflows/tag.yml
vendored
135
.github/workflows/tag.yml
vendored
|
@ -1,55 +1,114 @@
|
||||||
name: Build and Publish (tag)
|
name: Build/Push (tag)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
branches: [ ci ]
|
||||||
- '*'
|
pull_request:
|
||||||
|
branches: [ ci ]
|
||||||
|
#on:
|
||||||
|
# push:
|
||||||
|
# tags:
|
||||||
|
# - '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-amd64:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go_version: [ '1.12', '1.13', '1.14' ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Get the version
|
- uses: actions/setup-go@v2
|
||||||
id: get_version
|
|
||||||
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
|
|
||||||
- name: Build and Push Docker Image (Linux - AMD64)
|
|
||||||
uses: docker/build-push-action@v1
|
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
go-version: ${{ matrix.go_version }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
- run: go get -t -v ./...
|
||||||
repository: ekofr/pihole-exporter
|
- run: go test -v -race ./...
|
||||||
tags: amd64,${{ steps.get_version.outputs.TAG_NAME }}
|
|
||||||
build_args: OS=linux,ARCH=amd64,IMAGE=scratch
|
|
||||||
|
|
||||||
build-arm32:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Get the version
|
|
||||||
id: get_version
|
|
||||||
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
|
|
||||||
- name: Build and Push Docker Image (Linux - ARM32)
|
|
||||||
uses: docker/build-push-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: ekofr/pihole-exporter
|
|
||||||
tags: arm32,${{ steps.get_version.outputs.TAG_NAME }}
|
|
||||||
build_args: OS=linux,ARCH=arm,IMAGE=arm32v7/alpine:3.11
|
|
||||||
|
|
||||||
build-arm64:
|
- uses: azure/docker-login@v1
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Get the version
|
|
||||||
id: get_version
|
|
||||||
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
|
|
||||||
- name: Build and Push Docker Image (Linux - ARM64)
|
|
||||||
uses: docker/build-push-action@v1
|
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
repository: ekofr/pihole-exporter
|
|
||||||
tags: arm64,${{ steps.get_version.outputs.TAG_NAME }}
|
- name: Set up docker buildx
|
||||||
build_args: OS=linux,ARCH=arm64,IMAGE=arm64v8/alpine:3.11
|
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 }}
|
||||||
|
|
||||||
|
- name: Get the version
|
||||||
|
id: get_version
|
||||||
|
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
|
||||||
|
|
||||||
|
- name: Run docker buildx build
|
||||||
|
run: |
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
|
||||||
|
--output=type=registry \
|
||||||
|
--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
|
||||||
|
|
||||||
|
push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: linux
|
||||||
|
arch: 386
|
||||||
|
- os: linux
|
||||||
|
arch: amd64
|
||||||
|
- os: linux
|
||||||
|
arch: arm
|
||||||
|
- os: darwin
|
||||||
|
arch: 386
|
||||||
|
- os: darwin
|
||||||
|
arch: amd64
|
||||||
|
- os: windows
|
||||||
|
arch: 386
|
||||||
|
- os: windows
|
||||||
|
arch: amd64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.14
|
||||||
|
- run: go get -t -v ./...
|
||||||
|
|
||||||
|
- run: go install github.com/mitchellh/gox
|
||||||
|
- run: gox -ldflags "-s -w" -os="${{ matrix.os }}" -arch="${{ matrix.arch }}" -output="pihole_exporter-{{.OS}}-{{.Arch}}" -verbose ./...
|
||||||
|
|
||||||
|
- name: Upload release assets
|
||||||
|
id: upload-release-asset
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create.outputs.upload_url }}
|
||||||
|
asset_path: ./pihole_exporter-${{ matrix.os }}-${{ matrix.arch }}
|
||||||
|
asset_name: pihole_exporter-${{ matrix.os }}-${{ matrix.arch }}
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
|
@ -12,7 +12,7 @@ RUN apk update && \
|
||||||
|
|
||||||
RUN GO111MODULE=on go mod vendor
|
RUN GO111MODULE=on go mod vendor
|
||||||
RUN CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH go build -ldflags '-s -w' -o binary ./
|
RUN CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH go build -ldflags '-s -w' -o binary ./
|
||||||
RUN upx -f --brute binary
|
#RUN upx -f --brute binary
|
||||||
|
|
||||||
FROM $IMAGE
|
FROM $IMAGE
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue