mirror of
https://github.com/eko/pihole-exporter.git
synced 2024-11-22 11:15:19 +01:00
Replace Travis-CI with GitHub actions and use docker buildx
This commit is contained in:
parent
6587709767
commit
dce9330523
16
.github/workflows/master.yml
vendored
16
.github/workflows/master.yml
vendored
@ -2,9 +2,11 @@ name: Build/Push (master)
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ ci ]
|
branches:
|
||||||
|
- '*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ ci ]
|
branches:
|
||||||
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@ -17,8 +19,12 @@ jobs:
|
|||||||
- uses: actions/setup-go@v1
|
- uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go_version }}
|
go-version: ${{ matrix.go_version }}
|
||||||
- run: go get -t -v ./...
|
|
||||||
- run: go test -v -race ./...
|
- name: Install go dependencies
|
||||||
|
run: go get -t -v ./...
|
||||||
|
|
||||||
|
- name: Run go tests
|
||||||
|
run: go test -v -cover -race ./...
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -39,7 +45,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Build/Push docker image (${{ matrix.os }}/${{ matrix.arch }})
|
- name: Build and 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 }}
|
||||||
|
32
.github/workflows/tag.yml
vendored
32
.github/workflows/tag.yml
vendored
@ -2,13 +2,8 @@ name: Build/Push (tag)
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ ci ]
|
tags:
|
||||||
pull_request:
|
- '*'
|
||||||
branches: [ ci ]
|
|
||||||
#on:
|
|
||||||
# push:
|
|
||||||
# tags:
|
|
||||||
# - '*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@ -71,8 +66,10 @@ jobs:
|
|||||||
release_name: ${{ github.ref }}
|
release_name: ${{ github.ref }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
outputs:
|
||||||
|
upload_url: ${{ steps.create.outputs.upload_url }}
|
||||||
|
|
||||||
push:
|
upload:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: release
|
needs: release
|
||||||
strategy:
|
strategy:
|
||||||
@ -90,17 +87,24 @@ jobs:
|
|||||||
arch: amd64
|
arch: amd64
|
||||||
- os: windows
|
- os: windows
|
||||||
arch: 386
|
arch: 386
|
||||||
|
extension: '.exe'
|
||||||
- os: windows
|
- os: windows
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
extension: '.exe'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.14
|
go-version: 1.14
|
||||||
- run: go get -t -v ./...
|
|
||||||
|
|
||||||
- run: go install github.com/mitchellh/gox
|
- name: Download go dependencies
|
||||||
- run: gox -ldflags "-s -w" -os="${{ matrix.os }}" -arch="${{ matrix.arch }}" -output="pihole_exporter-{{.OS}}-{{.Arch}}" -verbose ./...
|
run: go get -t -v ./...
|
||||||
|
|
||||||
|
- name: Install mitchellh/gox to create platform specific releases
|
||||||
|
run: go install github.com/mitchellh/gox
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
run: gox -ldflags "-s -w" -os="${{ matrix.os }}" -arch="${{ matrix.arch }}" -output="pihole_exporter-{{.OS}}-{{.Arch}}" -verbose ./...
|
||||||
|
|
||||||
- name: Upload release assets
|
- name: Upload release assets
|
||||||
id: upload-release-asset
|
id: upload-release-asset
|
||||||
@ -108,7 +112,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create.outputs.upload_url }}
|
upload_url: ${{ needs.release.outputs.upload_url }}${{ matrix.extension }}
|
||||||
asset_path: ./pihole_exporter-${{ matrix.os }}-${{ matrix.arch }}
|
asset_path: ./pihole_exporter-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.extension }}
|
||||||
asset_name: pihole_exporter-${{ matrix.os }}-${{ matrix.arch }}
|
asset_name: pihole_exporter-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.extension }}
|
||||||
asset_content_type: application/octet-stream
|
asset_content_type: application/octet-stream
|
||||||
|
42
.travis.yml
42
.travis.yml
@ -1,42 +0,0 @@
|
|||||||
language: go
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- go: 1.x
|
|
||||||
env: LATEST=true
|
|
||||||
- go: 1.9.x
|
|
||||||
- go: 1.10.x
|
|
||||||
- go: 1.11.x
|
|
||||||
- go: 1.12.x
|
|
||||||
- go: 1.13.x
|
|
||||||
- go: tip
|
|
||||||
allow_failures:
|
|
||||||
- go: tip
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- go get github.com/mitchellh/gox
|
|
||||||
|
|
||||||
install:
|
|
||||||
- export GO111MODULE=on
|
|
||||||
- go get -t -v ./...
|
|
||||||
|
|
||||||
script:
|
|
||||||
- go test -v -race ./...
|
|
||||||
- if [ "${LATEST}" = "true" ]; then gox -ldflags "-s -w" -os="linux darwin windows" -arch="386 amd64" -osarch="linux/arm" -output="pihole_exporter-{{.OS}}-{{.Arch}}" -verbose ./...; fi
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
provider: releases
|
|
||||||
skip_cleanup: true
|
|
||||||
api_key:
|
|
||||||
secure: $GITHUB_TOKEN
|
|
||||||
file:
|
|
||||||
- pihole_exporter-windows-386.exe
|
|
||||||
- pihole_exporter-windows-amd64.exe
|
|
||||||
- pihole_exporter-darwin-386
|
|
||||||
- pihole_exporter-darwin-amd64
|
|
||||||
- pihole_exporter-linux-386
|
|
||||||
- pihole_exporter-linux-amd64
|
|
||||||
- pihole_exporter-linux-arm
|
|
||||||
on:
|
|
||||||
repo: eko/pihole-exporter
|
|
||||||
tags: true
|
|
||||||
condition: $LATEST = true
|
|
@ -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 New Issue
Block a user