From 1ff4ab5c5bc83793230720b37e5065806eec36ca Mon Sep 17 00:00:00 2001 From: Kris Budde Date: Tue, 14 Dec 2021 21:22:16 +0100 Subject: [PATCH] feat: build binary files --- .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- .golangci | 2 +- .goreleaser.yml | 31 +++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- service_windows.go | 2 ++ 7 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..41775ac --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: goreleaser + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + \ No newline at end of file diff --git a/.gitignore b/.gitignore index bdd0d76..bfa181d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ rabbitmq_exporter.exe .tarballs/ coverage.out debug.test -vendor/ \ No newline at end of file +vendor/ +dist/ diff --git a/.golangci b/.golangci index 2fa84c2..72dc4c6 100644 --- a/.golangci +++ b/.golangci @@ -1,6 +1,6 @@ linters-settings: goimports: - local-prefixes: github.com/kbudde/dsa + local-prefixes: github.com/kbudde/rabbitmq_exporter golint: min-confidence: 0.8 gocyclo: diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..03b2984 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,31 @@ +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + binary: rabbitmq_exporter-{{.Version}}.{{.Target}} + targets: + - linux_amd64 + - linux_arm64 + - linux_arm_6 + - linux_arm_7 + - windows_amd64 + - darwin_amd64 + - darwin_arm64 + tags: netgo staticbuild + ldflags: + - -X main.Version={{.Version}} + - -X main.Revision={{.ShortCommit}} + - -X main.Branch={{.Branch}} + - -X main.BuildDate={{.CommitDate}} +checksum: + name_template: 'checksums.txt' +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +release: + discussion_category_name: Announcements \ No newline at end of file diff --git a/go.mod b/go.mod index e2c64d5..a9b5ae5 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/streadway/amqp v1.0.0 github.com/tkanos/gonfig v0.0.0-20210106201359-53e13348de2f - golang.org/x/sys v0.0.0-20211210111614-af8b64212486 + golang.org/x/sys v0.0.0-20211214170744-3b038e5940ed ) require ( diff --git a/go.sum b/go.sum index 2b8f156..0782add 100644 --- a/go.sum +++ b/go.sum @@ -472,8 +472,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211214170744-3b038e5940ed h1:d5glpD+GMms2DMbu1doSYibjbKasYNvnhq885nOnRz8= +golang.org/x/sys v0.0.0-20211214170744-3b038e5940ed/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/service_windows.go b/service_windows.go index e34ce15..3cb3cc7 100644 --- a/service_windows.go +++ b/service_windows.go @@ -5,6 +5,8 @@ import ( "golang.org/x/sys/windows/svc" ) +const serviceName = "rabbitmq_exporter" + func runService() chan bool { stopCh := make(chan bool) isInteractive, err := svc.IsAnInteractiveSession()