Skip to content

Commit

Permalink
use goreleaser for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
0x46616c6b committed Mar 21, 2021
1 parent fa33b19 commit bd53956
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 64 deletions.
70 changes: 17 additions & 53 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,26 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/[email protected]
with:
go-version: '1.16.x'
- name: Create release artifacts
run: make release
env:
GOPATH: ${{ github.workspace }}/go
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload release artifacts (Mac OS amd64)
id: upload-release-asset-mac
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Setup go
uses: actions/setup-go@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/prometheus-etherpad-exporter-darwin-amd64
asset_name: prometheus-etherpad-exporter-darwin-amd64
asset_content_type: application/octet-stream
- name: Upload release artifacts (FreeBSD amd64)
id: upload-release-asset-freebsd
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
go-version: 1.16.x

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/prometheus-etherpad-exporter-freebsd-amd64
asset_name: prometheus-etherpad-exporter-freebsd-amd64
asset_content_type: application/octet-stream
- name: Upload release artifacts (Linux amd64)
id: upload-release-asset-linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Release
uses: goreleaser/goreleaser-action@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/prometheus-etherpad-exporter-linux-amd64
asset_name: prometheus-etherpad-exporter-linux-amd64
asset_content_type: application/octet-stream
- name: Upload release artifacts (shasums)
id: upload-release-asset-sha512sums
uses: actions/upload-release-asset@v1
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/sha512sums.txt
asset_name: sha512sums.txt
asset_content_type: application/octet-stream
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
dist/
34 changes: 34 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarm:
- 6
- 7
ldflags:
- -s -w
dockers:
-
goos: linux
goarch: amd64
image_templates:
- "systemli/prometheus-etherpad-exporter:{{ .Tag }}"
- "systemli/prometheus-etherpad-exporter:{{ .Major }}"
- "systemli/prometheus-etherpad-exporter:{{ .Major }}.{{ .Minor }}"
- "systemli/prometheus-etherpad-exporter:latest"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
10 changes: 2 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16.2-alpine as builder
FROM alpine:3.12 as builder

WORKDIR /go/src/github.com/systemli/prometheus-etherpad-exporter

Expand All @@ -14,18 +14,12 @@ RUN adduser \
--uid "${UID}" \
"${USER}"

ADD . /go/src/github.com/systemli/prometheus-etherpad-exporter
RUN go get -d -v && \
go mod download && \
go mod verify && \
CGO_ENABLED=0 go build -ldflags="-w -s" -o /prometheus-etherpad-exporter


FROM scratch

COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /prometheus-etherpad-exporter /prometheus-etherpad-exporter
COPY prometheus-etherpad-exporter /prometheus-etherpad-exporter

USER appuser:appuser

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ release:
shasum -a 512 build/* > build/sha512sums.txt

docker:
$(GOBUILD) -o $(BINARY_NAME) -v
docker build --rm --force-rm --no-cache -t systemli/prometheus-jitsi-meet-exporter .

.PHONY: all vet test coverage clean build run release docker
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/systemli/prometheus-etherpad-exporter
go 1.16

require (
github.com/google/go-cmp v0.5.5 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/google/go-cmp v0.5.5
github.com/sirupsen/logrus v1.8.1
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
)
5 changes: 4 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

0 comments on commit bd53956

Please sign in to comment.