Skip to content

Commit

Permalink
multi-platform image build (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryane authored Dec 29, 2021
1 parent 97a9770 commit 2397e7c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ on:
jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Login to Docker Hub
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Docker Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
49 changes: 40 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ builds:
- windows
- linux
- darwin
goarch:
- amd64
- arm64
# Default is `-s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.builtBy=goreleaser`.
ldflags:
- -s -w -X github.com/ryane/kfilt/cmd.Version={{.Version}} -X github.com/ryane/kfilt/cmd.GitCommit={{.ShortCommit}}
Expand All @@ -29,15 +32,43 @@ changelog:
- Merge pull request
- Merge branch
dockers:
- goos: linux
goarch: amd64
goarm: ''
image_templates:
- "ryane/{{.ProjectName}}:latest"
- "ryane/{{.ProjectName}}:{{ .Tag }}"
- image_templates:
- "ryane/{{.ProjectName}}:{{ .Tag }}-amd64"
skip_push: false
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/ryane/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/ryane/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=Apache-2.0
- image_templates:
- "ryane/{{.ProjectName}}:{{ .Tag }}-arm64v8"
goarch: arm64
skip_push: false
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- "--label=org.label-schema.schema-version=1.0"
- "--label=org.label-schema.version={{.Version}}"
- "--label=org.label-schema.name={{.ProjectName}}"
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/ryane/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/ryane/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=Apache-2.0
docker_manifests:
- name_template: "ryane/{{ .ProjectName }}:{{ .Tag }}"
image_templates:
- "ryane/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "ryane/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
- name_template: "ryane/{{ .ProjectName }}:latest"
image_templates:
- "ryane/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "ryane/{{ .ProjectName }}:{{ .Tag }}-arm64v8"

0 comments on commit 2397e7c

Please sign in to comment.