From 583059057ac713434bb8d071a334c30e5592c42a Mon Sep 17 00:00:00 2001 From: lspgn Date: Fri, 11 Jun 2021 09:57:59 -0700 Subject: [PATCH] feature: add arm builds --- .github/workflows/build.yml | 5 +++- .github/workflows/docker-release.yaml | 5 ++-- .github/workflows/docker.yaml | 5 ++-- .github/workflows/release.yml | 4 ++- Makefile | 41 ++++++++++++++++++--------- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a271a448..598c9ebb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,7 @@ jobs: GOOS=linux make build GOOS=darwin make build GOOS=windows EXTENSION=.exe make build + ARCH=arm64 GOARCH=arm64 GOOS=linux make build - name: Install fpm run: | @@ -41,7 +42,9 @@ jobs: sudo gem install fpm - name: Package - run: make package-deb package-rpm + run: | + make package-deb package-rpm + ARCH=arm64 make package-deb package-rpm - name: Upload Artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/docker-release.yaml b/.github/workflows/docker-release.yaml index 2db25208..03ae9ca2 100644 --- a/.github/workflows/docker-release.yaml +++ b/.github/workflows/docker-release.yaml @@ -36,5 +36,6 @@ jobs: - name: Build run: | export VERSION=$(git describe --tags --abbrev=0 HEAD) - make docker - make push-docker-release + DOCKER_SUFFIX=-amd64 make docker push-docker + DOCKER_SUFFIX=-arm64 DOCKER_CMD='buildx build --push --platform linux/arm64/v8' make docker + make docker-manifest-release diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index e5bd8f54..6de4107c 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -34,5 +34,6 @@ jobs: - name: Build run: | - make docker - make push-docker + DOCKER_SUFFIX=-amd64 make docker push-docker + DOCKER_SUFFIX=-arm64 DOCKER_CMD='buildx build --push --platform linux/arm64/v8' make docker + make docker-manifest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16fa2054..b8ad6189 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.14 + go-version: ^1.16 - name: Check out code into the Go module directory uses: actions/checkout@v1 @@ -34,6 +34,8 @@ jobs: GOOS=darwin make build GOOS=windows EXTENSION=.exe make build make package-deb package-rpm + ARCH=arm64 GOARCH=arm64 GOOS=linux make build + ARCH=arm64 make package-deb package-rpm - name: Create Release id: create_release diff --git a/Makefile b/Makefile index 16242227..2c00f338 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -EXTENSION ?= -DIST_DIR ?= dist/ -GOOS ?= linux -ARCH ?= $(shell uname -m) +EXTENSION ?= +DIST_DIR ?= dist/ +GOOS ?= linux +ARCH ?= $(shell uname -m) BUILDINFOSDET ?= DOCKER_REPO := netsampler/ @@ -11,7 +11,6 @@ ABBREV ?= $(shell git rev-parse --short HEAD) COMMIT ?= $(shell git rev-parse HEAD) TAG ?= $(shell git describe --tags --abbrev=0 HEAD) VERSION_PKG ?= $(shell echo $(VERSION) | sed 's/^v//g') -ARCH := x86_64 LICENSE := BSD-3-Clause URL := https://github.com/netsampler/goflow2 DESCRIPTION := GoFlow2: Open-Source and Scalable Network Sample Collector @@ -19,6 +18,8 @@ DATE := $(shell date +%FT%T%z) BUILDINFOS ?= ($(DATE)$(BUILDINFOSDET)) LDFLAGS ?= '-X main.version=$(VERSION) -X main.buildinfos=$(BUILDINFOS)' MAINTAINER := lspgn@users.noreply.github.com +DOCKER_CMD ?= build +DOCKER_SUFFIX ?= OUTPUT := $(DIST_DIR)goflow2-$(VERSION_PKG)-$(GOOS)-$(ARCH)$(EXTENSION) @@ -50,7 +51,7 @@ build: prepare .PHONY: docker docker: - docker build \ + docker $(DOCKER_CMD) \ --build-arg LDFLAGS=$(LDFLAGS) \ --build-arg CREATED="$(DATE)" \ --build-arg MAINTAINER="$(MAINTAINER)" \ @@ -60,18 +61,30 @@ docker: --build-arg LICENSE="$(LICENSE)" \ --build-arg VERSION="$(VERSION)" \ --build-arg REV="$(COMMIT)" \ - -t $(DOCKER_REPO)$(NAME):$(ABBREV) . + -t $(DOCKER_REPO)$(NAME):$(ABBREV)$(DOCKER_SUFFIX) . .PHONY: push-docker push-docker: - docker push $(DOCKER_REPO)$(NAME):$(ABBREV) - docker tag $(DOCKER_REPO)$(NAME):$(ABBREV) $(DOCKER_REPO)$(NAME):latest - docker push $(DOCKER_REPO)$(NAME):latest + docker push $(DOCKER_REPO)$(NAME):$(ABBREV)$(DOCKER_SUFFIX) -.PHONY: push-docker-release -push-docker-release: - docker tag $(DOCKER_REPO)$(NAME):$(ABBREV) $(DOCKER_REPO)$(NAME):$(VERSION) - docker push $(DOCKER_REPO)$(NAME):$(VERSION) +.PHONY: docker-manifest +docker-manifest: + docker manifest create $(DOCKER_REPO)$(NAME):$(ABBREV) \ + --amend $(DOCKER_REPO)$(NAME):$(ABBREV)-amd64 \ + --amend $(DOCKER_REPO)$(NAME):$(ABBREV)-arm64 + docker manifest push $(DOCKER_REPO)$(NAME):$(ABBREV) + + docker manifest create $(DOCKER_REPO)$(NAME):latest \ + --amend $(DOCKER_REPO)$(NAME):$(ABBREV)-amd64 \ + --amend $(DOCKER_REPO)$(NAME):$(ABBREV)-arm64 + docker manifest push $(DOCKER_REPO)$(NAME):latest + +.PHONY: docker-manifest-release +docker-manifest-release: + docker manifest create $(DOCKER_REPO)$(NAME):$(VERSION) \ + --amend $(DOCKER_REPO)$(NAME):$(ABBREV)-amd64 \ + --amend $(DOCKER_REPO)$(NAME):$(ABBREV)-arm64 + docker manifest push $(DOCKER_REPO)$(NAME):$(VERSION) .PHONY: package-deb package-deb: prepare