chore: goreleaser and buildx
This commit is contained in:
19
.github/workflows/release.yml
vendored
19
.github/workflows/release.yml
vendored
@ -27,12 +27,6 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Install Docker image multi-arch builder
|
||||
- name: Install seihon ${{ env.SEIHON_VERSION }}
|
||||
run: |
|
||||
curl -sSfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sh -s -- -b $(go env GOPATH)/bin ${SEIHON_VERSION}
|
||||
seihon --version
|
||||
|
||||
- name: Docker Login
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
@ -40,5 +34,14 @@ jobs:
|
||||
run: |
|
||||
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
||||
|
||||
- name: Deploy Docker Images (seihon)
|
||||
run: make publish-images
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
# https://goreleaser.com/ci/actions/
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }}
|
||||
|
80
.goreleaser.yml
Normal file
80
.goreleaser.yml
Normal file
@ -0,0 +1,80 @@
|
||||
project_name: whoami
|
||||
|
||||
builds:
|
||||
- binary: whoami
|
||||
goos:
|
||||
- windows
|
||||
- darwin
|
||||
- linux
|
||||
- freebsd
|
||||
- openbsd
|
||||
goarch:
|
||||
- amd64
|
||||
- '386'
|
||||
- arm
|
||||
- arm64
|
||||
goarm:
|
||||
- '7'
|
||||
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: '386'
|
||||
- goos: openbsd
|
||||
goarch: arm
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^doc:'
|
||||
- '^chore:'
|
||||
- '^chore(deps):'
|
||||
- '^test:'
|
||||
- '^tests:'
|
||||
|
||||
archives:
|
||||
- id: whoami
|
||||
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm}}v{{ .Arm }}{{ end }}'
|
||||
format: tar.gz
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- LICENSE
|
||||
|
||||
dockers:
|
||||
- use: buildx
|
||||
skip_push: true
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
dockerfile: buildx.Dockerfile
|
||||
image_templates:
|
||||
- 'traefik/whoami:dev-amd64'
|
||||
- 'traefik/whoami:latest-amd64'
|
||||
- 'traefik/whoami:{{ .Tag }}-amd64'
|
||||
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-amd64'
|
||||
build_flag_templates:
|
||||
- '--pull'
|
||||
- '--label=org.opencontainers.image.created={{.Date}}'
|
||||
- '--label=org.opencontainers.image.title={{.ProjectName}}'
|
||||
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
|
||||
- '--label=org.opencontainers.image.version={{.Version}}'
|
||||
|
||||
- use: buildx
|
||||
skip_push: true
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
dockerfile: buildx.Dockerfile
|
||||
image_templates:
|
||||
- 'traefik/whoami:dev-arm64'
|
||||
- 'traefik/whoami:latest-arm64'
|
||||
- 'traefik/whoami:{{ .Tag }}-arm64'
|
||||
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-arm64'
|
||||
build_flag_templates:
|
||||
- '--pull'
|
||||
- '--label=org.opencontainers.image.created={{.Date}}'
|
||||
- '--label=org.opencontainers.image.title={{.ProjectName}}'
|
||||
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
|
||||
- '--label=org.opencontainers.image.version={{.Version}}'
|
||||
|
@ -1,25 +1,17 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
FROM golang:1-alpine as builder
|
||||
|
||||
RUN apk --no-cache --no-progress add git ca-certificates tzdata make \
|
||||
&& update-ca-certificates \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
WORKDIR /go/whoami
|
||||
|
||||
# Download go modules
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN GOARCH={{ .GoARCH }} GOARM={{ .GoARM }} make build
|
||||
|
||||
# syntax=docker/dockerfile:1.2
|
||||
# Create a minimal container to run a Golang static binary
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /go/whoami/whoami .
|
||||
COPY whoami /
|
||||
|
||||
ENTRYPOINT ["/whoami"]
|
||||
EXPOSE 80
|
Reference in New Issue
Block a user