Skip to content

Commit

Permalink
Add goreleaser and cache
Browse files Browse the repository at this point in the history
  • Loading branch information
devon-mar committed Jan 25, 2022
1 parent 884fac2 commit 1d10546
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 30 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/docker.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
"on":
push:
tags:
- "v*"

name: release
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0s

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17"

- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: success() && startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
tags: devonm/radius-exporter:latest
push: true
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ jobs:
with:
go-version: "1.17"

- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: fmt check
run: test -z $(gofmt -l .)

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
radius-exporter
radius-exporter_*
/config.yml

dist/
31 changes: 31 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
project_name: radius-exporter
builds:
- env:
- CGO_ENABLED=0
ldflags: -X main.exporterVersion=v{{.Version}} -X main.exporterSha={{.Commit}}
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
ignore:
- goos: windows
goarch: arm
archives:
- format: binary
release:
mode: append
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

0 comments on commit 1d10546

Please sign in to comment.