Skip to content

Commit

Permalink
Fix goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
RW21 committed Jul 2, 2022
1 parent 5107783 commit d9031e5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
65 changes: 38 additions & 27 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,54 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
project_name: switchbot-plug-exporter
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
# builds:
# - env:
# - CGO_ENABLED=0
# goos:
# - linux
# - windows
# - darwin
builds:
- env:
# - CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64

dockers:
- use: buildx
id: switchbot
goos: linux
- goos: linux
goarch: amd64
image_templates:
- "rw21/{{ .ProjectName }}:{{ .Version }}-amd64"
- "rw21/{{ .ProjectName }}:{{ .Version }}-linux-amd64"
build_flag_templates:
- "--GOARCH=amd64"
- "--GOOS=linux"
skip_push: true
- "--platform=linux/amd64"

- goos: linux
goarch: arm64
image_templates:
- "rw21/{{ .ProjectName }}:{{ .Version }}-linux-arm64"
build_flag_templates:
- "--platform=linux/arm/v6"

- goos: darwin
goarch: arm64
image_templates:
- "rw21/{{ .ProjectName }}:{{ .Version }}-darwin-arm64"

- goos: darwin
goarch: amd64
image_templates:
- "rw21/{{ .ProjectName }}:{{ .Version }}-darwin-amd64"

docker_manifests:
- name_template: rw21/{{ .ProjectName }}:{{ .Version }}
image_templates:
- "rw21/{{ .ProjectName }}:{{ .Version }}-amd64"
- "rw21/{{ .ProjectName }}:{{ .Version }}-linux-amd64"
- "rw21/{{ .ProjectName }}:{{ .Version }}-linux-arm64"
- "rw21/{{ .ProjectName }}:{{ .Version }}-darwin-arm64"
- "rw21/{{ .ProjectName }}:{{ .Version }}-darwin-amd64"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

release:
github:
owner: RW21
name: switchbot-plug-exporter
14 changes: 2 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
FROM golang:1.18 as builder

ARG GOARCH
ARG GOOS

COPY . /src
WORKDIR /src
RUN GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -o exporter .

FROM scratch
COPY --from=builder /src/exporter /exporter
EXPOSE 9101
ENTRYPOINT ["/exporter"]
COPY switchbot-plug-exporter /
ENTRYPOINT ["/switchbot-plug-exporter"]

0 comments on commit d9031e5

Please sign in to comment.