From ff5733c463eae2f25b8615f3bcf93668f07b7c72 Mon Sep 17 00:00:00 2001
From: altafan <pietro@vulpem.com>
Date: Mon, 8 Nov 2021 15:51:44 +0100
Subject: [PATCH 1/5] Add arm64 artifacts to releaser

---
 .goreleaser.yml | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/.goreleaser.yml b/.goreleaser.yml
index 818bc77..363cdd5 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -8,6 +8,7 @@ builds:
       - darwin
     goarch:
       - amd64
+      - arm64
     binary: feederd
 checksum:
   name_template: "checksums.txt"
@@ -40,17 +41,20 @@ archives:
 
 dockers:
   # push always either release or prerelease with a docker tag with the semver only
+  # amd64
   - skip_push: false
     dockerfile: Dockerfile
+    use: buildx
     # image templates
     image_templates:
-      - "ghcr.io/tdex-network/feederd:{{ .Tag }}"
+      - "ghcr.io/tdex-network/feederd:{{ .Tag }}-amd64"
     # GOOS of the built binaries/packages that should be used.
     goos: linux
     # GOARCH of the built binaries/packages that should be used.
     goarch: amd64
     # Template of the docker build flags.
     build_flag_templates:
+      - "--platform=linux/amd64"
       - "--pull"
       - "--label=org.opencontainers.image.created={{.Date}}"
       - "--label=org.opencontainers.image.title={{.ProjectName}}"
@@ -65,18 +69,20 @@ dockers:
       - go.sum
       - internal
       - cmd
-  # push only release with both a docker tag latest and one with the semver
-  - skip_push: auto
+  # arm64
+  - skip_push: false
     dockerfile: Dockerfile
+    use: buildx
     # image templates
     image_templates:
-      - "ghcr.io/tdex-network/feederd:latest"
+      - "ghcr.io/tdex-network/feederd:{{ .Tag }}-arm64v8"
     # GOOS of the built binaries/packages that should be used.
     goos: linux
     # GOARCH of the built binaries/packages that should be used.
-    goarch: amd64
+    goarch: arm64
     # Template of the docker build flags.
     build_flag_templates:
+      - "--platform=linux/arm64/v8"
       - "--pull"
       - "--label=org.opencontainers.image.created={{.Date}}"
       - "--label=org.opencontainers.image.title={{.ProjectName}}"
@@ -85,8 +91,22 @@ dockers:
       - "--build-arg=VERSION={{.Version}}"
       - "--build-arg=COMMIT={{.Commit}}"
       - "--build-arg=DATE={{.Date}}"
+
     extra_files:
       - go.mod
       - go.sum
       - internal
-      - cmd
\ No newline at end of file
+      - cmd
+
+docker_manifests:
+  - name_template: ghcr.io/tdex-network/feederd:{{ .Tag }}
+    image_templates:
+    - ghcr.io/tdex-network/feederd:{{ .Tag }}-amd64
+    - ghcr.io/tdex-network/feederd:{{ .Tag }}-arm64v8
+    skip_push: false
+
+  - name_template: ghcr.io/tdex-network/feederd:latest
+    image_templates:
+    - ghcr.io/tdex-network/feederd:{{ .Tag }}-amd64
+    - ghcr.io/tdex-network/feederd:{{ .Tag }}-arm64v8
+    skip_push: auto
\ No newline at end of file

From e0bab7472ad495b038e465a66f62186c12f3e4ea Mon Sep 17 00:00:00 2001
From: altafan <pietro@vulpem.com>
Date: Mon, 8 Nov 2021 16:16:32 +0100
Subject: [PATCH 2/5] Add TARGETOS and TARGETARCH args to Dockerfile

---
 Dockerfile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 6c0c381..ba60862 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,8 @@
 FROM golang:1.15.5-buster AS builder
 
+ARG TARGETOS
+ARG TARGETARCH
+
 WORKDIR /tdex-feeder
 
 COPY go.mod .
@@ -8,7 +11,7 @@ RUN go mod download
 
 COPY . .
 
-RUN GOOS=linux GOARCH=amd64 go build -o feederd-linux cmd/feederd/main.go
+RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o feederd-linux cmd/feederd/main.go
 
 WORKDIR /build
 

From 58b622f7143ea1518962583947bebea202fefc40 Mon Sep 17 00:00:00 2001
From: altafan <pietro@vulpem.com>
Date: Mon, 8 Nov 2021 16:44:18 +0100
Subject: [PATCH 3/5] Fix gh-action release workflow

---
 .github/workflows/release.yml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f8226e2..8493e08 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -7,11 +7,20 @@ on:
 jobs:
   goreleaser:
     runs-on: ubuntu-latest
+    env:
+      DOCKER_CLI_EXPERIMENTAL: "enabled"
+
+    permissions: write-all
+
     steps:
       - name: Checkout
         uses: actions/checkout@v2
         with:
           fetch-depth: 0
+
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+
       - name: Set up Go
         uses: actions/setup-go@v2
         with:

From 83efb5786108aa1a4d7ceee02842aae8029c2559 Mon Sep 17 00:00:00 2001
From: altafan <pietro@vulpem.com>
Date: Mon, 8 Nov 2021 17:16:42 +0100
Subject: [PATCH 4/5] Remove unused build args

---
 .goreleaser.yml | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/.goreleaser.yml b/.goreleaser.yml
index 363cdd5..0b574a4 100644
--- a/.goreleaser.yml
+++ b/.goreleaser.yml
@@ -60,15 +60,12 @@ dockers:
       - "--label=org.opencontainers.image.title={{.ProjectName}}"
       - "--label=org.opencontainers.image.revision={{.FullCommit}}"
       - "--label=org.opencontainers.image.version={{.Version}}"
-      - "--build-arg=VERSION={{.Version}}"
-      - "--build-arg=COMMIT={{.Commit}}"
-      - "--build-arg=DATE={{.Date}}"
-
     extra_files:
       - go.mod
       - go.sum
       - internal
       - cmd
+  
   # arm64
   - skip_push: false
     dockerfile: Dockerfile
@@ -88,10 +85,6 @@ dockers:
       - "--label=org.opencontainers.image.title={{.ProjectName}}"
       - "--label=org.opencontainers.image.revision={{.FullCommit}}"
       - "--label=org.opencontainers.image.version={{.Version}}"
-      - "--build-arg=VERSION={{.Version}}"
-      - "--build-arg=COMMIT={{.Commit}}"
-      - "--build-arg=DATE={{.Date}}"
-
     extra_files:
       - go.mod
       - go.sum

From 48aab246bc148965c48598bc457d7794df19165a Mon Sep 17 00:00:00 2001
From: altafan <pietro@vulpem.com>
Date: Mon, 8 Nov 2021 17:17:06 +0100
Subject: [PATCH 5/5] Try to remove permissions

---
 .github/workflows/release.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8493e08..888acda 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -10,8 +10,6 @@ jobs:
     env:
       DOCKER_CLI_EXPERIMENTAL: "enabled"
 
-    permissions: write-all
-
     steps:
       - name: Checkout
         uses: actions/checkout@v2