Skip to content

Commit

Permalink
Merge pull request #38 from hikhvar/build-multi-arch-images
Browse files Browse the repository at this point in the history
Multi arch build
  • Loading branch information
hikhvar authored Feb 3, 2021
2 parents 4a90c02 + 04bf795 commit de1ad00
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 7 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
run: go test -cover ./...
- name: Vet
run: go vet ./...
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Login to the registries
- name: Login to Github Packages
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
Expand All @@ -29,10 +33,15 @@ jobs:
# Github Registry does not support the github actions token
- name: Login to Github Registry
run: echo ${{secrets.PERSONAL_ACCESS_TOKEN }} | docker login ghcr.io -u hikhvar --password-stdin
- name: Enable docker experimental features for docker manifests
run: |
echo '{"experimental": true}' | sudo tee -a /etc/docker/daemon.json
sudo systemctl restart docker
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_CLI_EXPERIMENTAL: enabled
32 changes: 32 additions & 0 deletions .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: release

on:
push:
branches: ["master"]
pull_request:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15.x
- name: Test
run: go test -cover ./...
- name: Vet
run: go vet ./...
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist --skip-publish
133 changes: 127 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ builds:
- amd64
- arm
- arm64
- 386
- riscv64
- ppc64le
- s390x

# GOARM to build for when GOARCH is arm.
# For more info refer to: https://golang.org/doc/install/source#environment
Expand Down Expand Up @@ -62,11 +66,128 @@ changelog:
- '^test:'

dockers:

- dockerfile: release/Dockerfile.scratch
goos: linux
goarch: amd64
use_buildx: true
build_flag_templates:
- "--platform=linux/amd64"
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-amd64"
- "hikhvar/mqtt2prometheus:latest-amd64"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-amd64"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-amd64"

- dockerfile: release/Dockerfile.scratch
goos: linux
goarch: arm64
use_buildx: true
build_flag_templates:
- "--platform=linux/arm64"
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-arm64"
- "hikhvar/mqtt2prometheus:latest-arm64"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-arm64"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-arm64"

- dockerfile: release/Dockerfile.scratch
goos: linux
goarch: arm
goarm: 6
use_buildx: true
build_flag_templates:
- "--platform=linux/arm/v6"
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-arm6"
- "hikhvar/mqtt2prometheus:latest-arm6"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-arm6"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-arm6"

- dockerfile: release/Dockerfile.scratch
goos: linux
goarch: arm
goarm: 6
use_buildx: true
build_flag_templates:
- "--platform=linux/arm/v6"
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-arm6"
- "hikhvar/mqtt2prometheus:latest-arm6"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-arm6"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-arm6"

- dockerfile: release/Dockerfile.scratch
goos: linux
goarch: arm
goarm: 7
use_buildx: true
build_flag_templates:
- "--platform=linux/arm/v7"
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-arm7"
- "hikhvar/mqtt2prometheus:latest-arm7"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-arm7"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-arm7"

- dockerfile: release/Dockerfile.scratch
goos: linux
goarch: 386
use_buildx: true
build_flag_templates:
- "--platform=linux/386"
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-386"
- "hikhvar/mqtt2prometheus:latest-386"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-386"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-386"

- dockerfile: release/Dockerfile.scratch
goos: linux
goarch: riscv64
use_buildx: true
build_flag_templates:
- "--platform=linux/riscv64"
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-riscv64"
- "hikhvar/mqtt2prometheus:latest-riscv64"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-riscv64"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-riscv64"

docker_manifests:
# Docker Registry
- name_template: hikhvar/mqtt2prometheus:{{ .Tag }}
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}-amd64"
- "hikhvar/mqtt2prometheus:{{ .Tag }}-arm64"
- "hikhvar/mqtt2prometheus:{{ .Tag }}-arm6"
- "hikhvar/mqtt2prometheus:{{ .Tag }}-arm7"
- "hikhvar/mqtt2prometheus:{{ .Tag }}-riscv64"
- "hikhvar/mqtt2prometheus:{{ .Tag }}-386"

- name_template: hikhvar/mqtt2prometheus:latest
image_templates:
- "hikhvar/mqtt2prometheus:latest-amd64"
- "hikhvar/mqtt2prometheus:latest-arm64"
- "hikhvar/mqtt2prometheus:latest-arm6"
- "hikhvar/mqtt2prometheus:latest-arm7"
- "hikhvar/mqtt2prometheus:latest-riscv64"
- "hikhvar/mqtt2prometheus:latest-386"

# Github Registry
- name_template: ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}
image_templates:
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-amd64"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-arm64"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-arm6"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-arm7"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-riscv64"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}-386"
- name_template: ghcr.io/hikhvar/mqtt2prometheus:latest
image_templates:
- "hikhvar/mqtt2prometheus:{{ .Tag }}"
- "hikhvar/mqtt2prometheus:latest"
- "docker.pkg.github.com/hikhvar/mqtt2prometheus/mqtt2prometheus:{{ .Tag }}"
- "docker.pkg.github.com/hikhvar/mqtt2prometheus/mqtt2prometheus:latest"
- "ghcr.io/hikhvar/mqtt2prometheus:{{ .Tag }}"
- "ghcr.io/hikhvar/mqtt2prometheus:latest"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-amd64"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-arm64"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-arm6"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-arm7"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-riscv64"
- "ghcr.io/hikhvar/mqtt2prometheus:latest-386"

0 comments on commit de1ad00

Please sign in to comment.