From f24e21105e44ac411eb536e889b061769ac5a60a Mon Sep 17 00:00:00 2001 From: jguer Date: Tue, 17 Nov 2020 16:21:44 +0100 Subject: [PATCH] ci(builder): update ci builder --- .github/workflows/multiarch-build.yml | 46 +++++++++++++++++++++++---- Dockerfile | 18 ++++------- Makefile | 20 ++---------- ci.Dockerfile | 4 +-- 4 files changed, 50 insertions(+), 38 deletions(-) diff --git a/.github/workflows/multiarch-build.yml b/.github/workflows/multiarch-build.yml index a3fdf43..d1c163a 100644 --- a/.github/workflows/multiarch-build.yml +++ b/.github/workflows/multiarch-build.yml @@ -8,30 +8,49 @@ jobs: build-releases: strategy: matrix: - arch: ["x86_64", "armv7h", "aarch64"] + arch: + [ + "linux/amd64 x86_64", + "linux/arm/v6 armv6h", + "linux/arm/v7 armv7h", + "linux/arm64 aarch64", + ] name: Build ${{ matrix.arch }} runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest - name: Read info id: tags shell: bash run: | echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} echo ::set-output name=TAG::${GITHUB_REF/refs\/tags\//} - - name: Install dependencies - run: sudo apt update -y && sudo apt install -y qemu qemu-user-static - - name: Setup qemu-user-static - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + arch="${{ matrix.arch }}" + echo ::set-output name=PLATFORM::${arch%% *} + echo ::set-output name=ARCH::${arch##* } - name: Build ${{ matrix.arch }} release run: | mkdir artifacts - make docker-release-${{ matrix.arch }} ARCH=${{ matrix.arch }} VERSION=${{ steps.tags.outputs.version }} PREFIX="/usr" + docker buildx build --platform ${{ steps.tags.outputs.platform }} \ + --build-arg VERSION=${{ steps.tags.outputs.version }} \ + --build-arg ARCH=${{ steps.tags.outputs.arch }} \ + --build-arg PREFIX="/usr" \ + -t yay:${{ steps.tags.outputs.arch }} . --load + make docker-release ARCH=${{ steps.tags.outputs.arch }} VERSION=${{ steps.tags.outputs.version }} PREFIX="/usr" mv *.tar.gz artifacts - uses: actions/upload-artifact@v2 with: - name: yay_${{ matrix.arch }} + name: yay_${{ steps.tags.outputs.arch }} path: artifacts create_release: name: Create release from this build @@ -50,6 +69,9 @@ jobs: - uses: actions/download-artifact@v2 with: name: yay_armv7h + - uses: actions/download-artifact@v2 + with: + name: yay_armv6h - uses: actions/download-artifact@v2 with: name: yay_aarch64 @@ -83,6 +105,16 @@ jobs: asset_path: ./yay_${{ steps.tags.outputs.version }}_armv7h.tar.gz asset_name: yay_${{ steps.tags.outputs.version }}_armv7h.tar.gz asset_content_type: application/tar+gzip + - name: Upload armv6h asset + id: upload-release-asset-armv6h + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./yay_${{ steps.tags.outputs.version }}_armv6h.tar.gz + asset_name: yay_${{ steps.tags.outputs.version }}_armv6h.tar.gz + asset_content_type: application/tar+gzip - name: Upload aarch64 asset id: upload-release-asset-aarch64 uses: actions/upload-release-asset@v1 diff --git a/Dockerfile b/Dockerfile index 7b9a6bc..b1b5e9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,12 @@ -ARG BUILD_TAG=devel -FROM samip537/archlinux:${BUILD_TAG} +FROM jguer/yay-builder:latest LABEL maintainer="Jguer,joaogg3 at google mail" +ARG VERSION +ARG PREFIX +ARG ARCH + WORKDIR /app -RUN pacman -Syu --overwrite=* --needed --noconfirm \ - go git - -COPY go.mod . -COPY go.sum . - -RUN go mod download - -ENV ARCH=x86_64 COPY . . + +RUN make release VERSION=${VERSION} PREFIX=${PREFIX} ARCH=${ARCH} diff --git a/Makefile b/Makefile index a9c3d41..2a22c14 100644 --- a/Makefile +++ b/Makefile @@ -65,24 +65,8 @@ docker-release-all: make docker-release-x86_64 ARCH=x86_64 make docker-release-aarch64 ARCH=aarch64 -.PHONY: docker-release-armv7h -docker-release-armv7h: - docker build --build-arg="BUILD_TAG=arm32v7-devel" -t yay-$(ARCH):${VERSION} . - docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make release VERSION=${VERSION} PREFIX=${PREFIX} - docker cp yay-$(ARCH):/app/${PACKAGE} $(PACKAGE) - docker container rm yay-$(ARCH) - -.PHONY: docker-release-aarch64 -docker-release-aarch64: - docker build --build-arg="BUILD_TAG=arm64v8-devel" -t yay-$(ARCH):${VERSION} . - docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make release VERSION=${VERSION} PREFIX=${PREFIX} - docker cp yay-$(ARCH):/app/${PACKAGE} $(PACKAGE) - docker container rm yay-$(ARCH) - -.PHONY: docker-release-x86_64 -docker-release-x86_64: - docker build --build-arg="BUILD_TAG=devel" -t yay-$(ARCH):${VERSION} . - docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make release VERSION=${VERSION} PREFIX=${PREFIX} +docker-release: + docker create --name yay-$(ARCH) yay:${ARCH} docker cp yay-$(ARCH):/app/${PACKAGE} $(PACKAGE) docker container rm yay-$(ARCH) diff --git a/ci.Dockerfile b/ci.Dockerfile index 614384e..1f073d1 100644 --- a/ci.Dockerfile +++ b/ci.Dockerfile @@ -4,10 +4,10 @@ LABEL maintainer="Jguer,joaogg3 at google mail" ENV GO111MODULE=on WORKDIR /app -RUN pacman -Syu --overwrite=* --needed --noconfirm go fakeroot binutils gcc make git &&\ +RUN pacman -Syu --overwrite=* --needed --noconfirm go fakeroot binutils gcc make git gettext &&\ rm -rfv /var/cache/pacman/* /var/lib/pacman/sync/* -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.31.0 +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.32.2 COPY go.mod .