mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-21 23:29:38 +00:00
workflows/Makefile: build Docker image for MacOS
We build multiarch linux/amd64 and linux/arm64, because MacOS runner can't build docker images and even if it could that'd be linux/amd64 while we want linux/arm64 for Apple CPUs. Unfortunately, given the way GitHub workflows work we can't avoid using a Makefile helper, there is no easy way to set variables conditionally and/or use some logic to affect their contents. We reintroduce build_image_wsc as well here because Windows images can't be built with buildx using GitHub runners.
This commit is contained in:
parent
4822728f5d
commit
b8b85ce911
2 changed files with 46 additions and 5 deletions
40
.github/workflows/build.yml
vendored
40
.github/workflows/build.yml
vendored
|
@ -66,10 +66,39 @@ jobs:
|
|||
build_image:
|
||||
needs: build_cli
|
||||
name: Build Docker image
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04, windows-2022]
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up QEMU
|
||||
if: runner.os != 'Windows'
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Set vars
|
||||
id: setvars
|
||||
run: make gh-docker-vars
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: false
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
REPO=${{ steps.setvars.outputs.repo }}
|
||||
VERSION=${{ steps.setvars.outputs.version }}
|
||||
tags: ${{ steps.setvars.outputs.repo }}:${{ steps.setvars.outputs.version }}${{ steps.setvars.outputs.suffix }}
|
||||
|
||||
build_image_wsc:
|
||||
needs: build_cli
|
||||
name: Build Docker image (Windows Server Core)
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -100,6 +129,9 @@ jobs:
|
|||
ref: ${{ github.event.inputs.ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
# For proper `deps` make target execution.
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
|
|
11
Makefile
11
Makefile
|
@ -25,7 +25,7 @@ IMAGE_REPO=nspccdev/neo-go
|
|||
# All of the targets are phony here because we don't really use make dependency
|
||||
# tracking for files
|
||||
.PHONY: build $(BINARY) deps image docker/$(BINARY) image-latest image-push image-push-latest clean-cluster \
|
||||
test vet lint fmt cover
|
||||
test vet lint fmt cover version gh-docker-vars
|
||||
|
||||
build: deps
|
||||
@echo "=> Building binary"
|
||||
|
@ -92,6 +92,15 @@ deps:
|
|||
@CGO_ENABLED=0 \
|
||||
go mod tidy -v
|
||||
|
||||
version:
|
||||
@echo $(VERSION)
|
||||
|
||||
gh-docker-vars:
|
||||
@echo "::set-output name=file::$(D_FILE)"
|
||||
@echo "::set-output name=version::$(VERSION)"
|
||||
@echo "::set-output name=repo::$(REPO)"
|
||||
@echo "::set-output name=suffix::$(IMAGE_SUFFIX)"
|
||||
|
||||
test:
|
||||
@go test ./... -cover
|
||||
|
||||
|
|
Loading…
Reference in a new issue